Python Natural Language Processing
上QQ阅读APP看书,第一时间看更新

Inflectional morphemes

Inflection morphemes are suffixes that are added to a word to assign particular grammatical property to that word. Inflectional morphemes are considered to be grammatical markers that indicate tense, number, POS, and so on. So, in more simple language, we can say that inflectional morphemes are identified as types of morpheme that modify the verb tense, aspect, mood, person, number (singular and plural), gender, or case, without affecting the words meaning or POS.

Here's some examples:

  • In the word dogs, -s changes the number of dog. -s converts dog from singular to plural form of it
  • The word expected contains -ed, which is an inflectional morpheme that modifies the verb tense

Here is the code for generating the stem from morphemes. We are using the nltk and polyglot libraries. You can find the code on this link: https://github.com/jalajthanaki/NLPython/blob/master/ch3/3_1_wordsteam.py

See the code snippets in Figure 3.5 and Figure 3.6:

Figure 3.5: Generating stems from morphemes using NLTK

Now, let's see how the polyglot library has been used refer to Figure 3.6:

Figure 3.6: Generating stems from morphemes using the polyglot library

The output of the code snippet is displayed in Figure 3.7:

Figure 3.7: Output of code snippets in Figure 3.5 and Figure 3.6