(self, token)
return self.stm
Stemming a word token using the ISRI stemmer.
Stemming a word token using the ISRI stemmer.
Stemming a word token using the ISRI stemmer .
def stem(self, token):
        """
        Stemming a word token using the ISRI stemmer.
        """

        self.stm = token
        self.norm(1)       #  remove diacritics which representing Arabic short vowels
        if self.stm in self.stop_words: return self.stm     # exclude stop words from being processed
        self.pre32()        # remove length three and length two prefixes in this order
        self.suf32()        # remove length three and length two suffixes in this order
        self.waw()          # remove connective ‘و’ if it precedes a word beginning with ‘و’
        self.norm(2)       # normalize initial hamza to bare alif
        if len(self.stm) <= 3: return self.stm     # return stem if less than or equal to three

        if len(self.stm) == 4:       # length 4 word
            self.pro_w4()
            return self.stm
        elif len(self.stm) == 5:     # length 5 word
            self.pro_w53()
            self.end_w5()
            return self.stm
        elif len(self.stm) == 6:     # length 6 word
            self.pro_w6()
            self.end_w6()
            return self.stm
        elif len(self.stm) == 7:     # length 7 word
            self.suf1()
            if len(self.stm) == 7:
                self.pre1()
            if len(self.stm) == 6:
                self.pro_w6()
                self.end_w6()
                return self.stm
        return self.stm
def stem ( self , token ) : self . stm = token self . norm ( 1 ) #  remove diacritics which representing Arabic short vowels if self . stm in self . stop_words : return self . stm # exclude stop words from being processed self . pre32 ( ) # remove length three and length two prefixes in this order self . suf32 ( ) # remove length three and length two suffixes in this order self . waw ( ) # remove connective ‘و’ if it precedes a word beginning with ‘و’ self . norm ( 2 ) # normalize initial hamza to bare alif if len ( self . stm ) <= 3 : return self . stm # return stem if less than or equal to three if len ( self . stm ) == 4 : # length 4 word self . pro_w4 ( ) return self . stm elif len ( self . stm ) == 5 : # length 5 word self . pro_w53 ( ) self . end_w5 ( ) return self . stm elif len ( self . stm ) == 6 : # length 6 word self . pro_w6 ( ) self . end_w6 ( ) return self . stm elif len ( self . stm ) == 7 : # length 7 word self . suf1 ( ) if len ( self . stm ) == 7 : self . pre1 ( ) if len ( self . stm ) == 6 : self . pro_w6 ( ) self . end_w6 ( ) return self . stm return self . stm