Professional Documents
Culture Documents
With Java”
Lecture - 11
nlp-ai@cse.iitb
Contents for Today’s Lecture
nlp-ai@cse.iitb
Problem
Write a Java program that finds out the root & suffix of the given noun
plural in English. Also print the morphology rule applied for forming
the plural.
Sample input & output –
Input: boys
Output:
root = boy
suffix = s
Morphology rule = [[W]] [[W][s]]
Input: indices
Output:
root = index
suffix = ices
Morphology rule = [[W][ex]] [[W][ices]]
nlp-ai@cse.iitb
Plurals in English
Example Morphology Rule
• boy boys • W Ws
• bus buses • W Wes
• lady ladies • Wy Wies
• leaf leaves • Wf Wves
• datum data • Wum Wa
• formula formulae • W We
• index indices • Wex Wices
• matrix matrices • Wx Wces
• radius radii • Wus Wi
• cherub cherubim • W Wim
nlp-ai@cse.iitb
Algorithm
nlp-ai@cse.iitb
Required Methods of String class
nlp-ai@cse.iitb
Required Methods of String class… continued
2. String substring(int beginIndex, int endIndex)
Returns a new string that is a substring of the current string. The
substring begins at the specified beginIndex and extends to the
character at index endIndex - 1. It will give error (throw exception) if
the beginIndex is negative, or endIndex is larger than the length the
string, or beginIndex is larger than endIndex.
Parameters:
beginIndex - the beginning index, inclusive.
endIndex - the ending index, exclusive.
eg. If s = “mississippi” then
s.substring(0,4) will return “miss”
s.substring(6,9) will return “sip”
s.substring(0,11) will return “mississippi”
s.substring(0,0) will return “”
nlp-ai@cse.iitb
Required Methods of String class… continued
nlp-ai@cse.iitb
Required Methods of String class… continued
nlp-ai@cse.iitb
Core Part of the Program
nlp-ai@cse.iitb
Some Testing
1. matrix matrices
2. life lives
3. analysis analyses
4. criterion criteria
Does the program work for these examples?
If yes, how?
If no, why?
nlp-ai@cse.iitb
Assignment
1. Do the morphological analysis of the following inflected verbs
in English and write a Java program that finds out the root &
suffix of the given inflected verb. Also print the morphology
rule that is applied.
fetch fetches, fetching, fetched
carry carries, carrying, carried
enjoy enjoys, enjoying, enjoyed
burn burns, burning, burnt
beat beats, beating, beaten
forbid forbids, forbidding, forbided, forbidden
blow blows, blowing, blowed, blown
save saves, saving, saved
nlp-ai@cse.iitb
Assignment … continued
say says, saying, said
drop drops, dropping, dropped
admit admits, admitting, admitted
repel repels, repelling, repelled
dog dogs, dogging, dogged
can cans, canning, canned
spur spurs, spurring, spurred
stem stems, stemming, stemmed
stab stabs, stabbing, stabbed
kid kids, kidding, kidded
mimic mimics, mimicking, mimicked
nlp-ai@cse.iitb
To Remind
nlp-ai@cse.iitb
End
Thank you
nlp-ai@cse.iitb