Page 1 of 1

PYTHON QUESTION! Stemming is a process of converting any given words to its root form (whatever that may be). There are

Posted: Wed Apr 27, 2022 3:49 pm
by answerhappygod
PYTHON QUESTION!
Stemming is a process of converting any given words to its root
form (whatever that may be). There are many good stemmers out
there, but here, we will write our own stemmer.
Write a function pos(sentence) (no, it stands for pretty
okay stemmer as titled) which takes an input parameter
sentence (type string), and returns a string that stemmed all words
from the given sentence. Each word should be stemmed as much as
possible. The following stemming rules are implemented (list is
quite long with exceptions, so take time to digest):
Note1: vowels contain letter 'y'.
Note2: As you can see, not all stemming rules would actually
result in proper root word (e.g., cutt, supposedly -> suppos
etc.), but this will do for this assignment.
Note3: Use the 'POS Checker' on Moodle to check various cases to
see if your function output matches the expected output (Try think
of as many cases as you need!).
For example the code must past all these tests:
Test
Expected
stemmed = pos('it\'s name was theirs\' to say and with gaps they
smelled gas and this was not okay.')
print(stemmed)
it name was their to say and with gap they smell gas and this
was not okay.
stemmed = pos("I went to BTS concert with my bonus pay and I
cried there as my heart melted away from their singing, it was
utterly beautiful I just felt possessed")
#note, singing, has a comma at the end!
print(stemmed)
I went to BTS concert with my bonus pay and I cri there as my
heart melt away from their singing, it was utt beautiful I just
felt possess
stemmed = pos("The consensus chopped off last Friday while the
voters were tied down flying without counting properly so wasn't a
great day after all")
print(stemmed)
The consensus chopp off last Friday while the vot were tie down
f without count prop so wasn't a great day aft all
stemmed = pos("today is a lovely day while my CMPS was not the
best and it's days are over but oh well what could be done about it
right?")
print(stemmed)
today is a love day while my CMPS was not the best and it days
are ov but oh well what could be done about it right?