- PowerPoint PPT Presentation

About This Presentation
Title:

Description:

Title Introduction to Programming With Java Author: umesh Last modified by: umesh Created Date: 9/9/2004 5:51:15 PM Document presentation format – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 16
Provided by: Ume3
Category:
Tags: leaf | morphology

less

Transcript and Presenter's Notes

Title:


1
Introduction to Programming With Java
Lecture - 11 UMESH PATIL (umesh_at_cse.iitb.ac.in)
nlp-ai_at_cse.iitb
2
Contents for Todays Lecture
  • Programming practice Program for morphological
    analysis of English nouns.

nlp-ai_at_cse.iitb
3
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 ? Ws Input indices
Output root index suffix ices
Morphology rule Wex ? Wices
nlp-ai_at_cse.iitb
4
Plurals in English
  • Example
  • boy ? boys
  • bus ? buses
  • lady ? ladies
  • leaf ? leaves
  • datum ? data
  • formula ? formulae
  • index ? indices
  • matrix ? matrices
  • radius ? radii
  • cherub ? cherubim
  • Morphology Rule
  • W ? Ws
  • W ? Wes
  • Wy ? Wies
  • Wf ? Wves
  • Wum ? Wa
  • W ? We
  • Wex ? Wices
  • Wx ? Wces
  • Wus ? Wi
  • W ? Wim

nlp-ai_at_cse.iitb
5
Algorithm
  1. Read the input word
  2. Find the suffix
  3. Remove suffix get the root
  4. If needed, prepare the correct rooteg. indices ?
    ind ? ind ex index
  5. Print the output

nlp-ai_at_cse.iitb
6
Required Methods of String class
  • boolean endsWith(String suffix)Returns true if
    the string ends with the specified suffix false
    otherwise. Parameters the String suffix.
  • eg. If s indices thens.endsWith(ices) will
    return trues.endsWith(s) will return
    trues.endsWith() will return
    trues.endsWith(indices) will return
    trueButs.endsWith(ice) will return false

nlp-ai_at_cse.iitb
7
Required Methods of String class continued
  • 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.ParametersbeginIndex - the beginning
    index, inclusive.endIndex - the ending index,
    exclusive.
  • eg. If s mississippi thens.substring(0,4)
    will return misss.substring(6,9) will return
    sips.substring(0,11) will return
    mississippis.substring(0,0) will return

nlp-ai_at_cse.iitb
8
Required Methods of String class continued
  • int lastIndexOf(String str)Returns the index
    within the current string of the rightmost
    occurrence of the specified substring. If str
    does not occur as a substring, -1 is
    returned.Parameters str - the substring to
    search for.
  • eg. If s mississippi thens.lastIndexOf(is)
    will return 4s.lastIndexOf(i) will return
    10s.lastIndexOf() will return
    11s.lastIndexOf(mississippi) will return
    0Ands.lastIndexOf(abc) will return -1

nlp-ai_at_cse.iitb
9
Required Methods of String class continued
  • String concat(String str)Returns a string after
    concatenating the specified string, ie. str, to
    the end of the current string.Parametersstr -
    the string that is concatenated to the end of the
    current string.
  • eg. if s man thens.concat(go) will return
    mangos.concat() will return man
  • Detailed explanation of the String class.

nlp-ai_at_cse.iitb
10
Core Part of the Program
Suppose input word indices if
(word.endsWith("ices")) // word indices
suffix "ices" i word.lastIndexOf("ices") /
/ i 3 root word.substring(0,i) // root
ind root root.concat("ex") // root
index morphRule "Wex ?
Wices"
nlp-ai_at_cse.iitb
11
Some Testing
  • matrix ? matrices
  • life ? lives
  • analysis ? analyses
  • criterion ? criteria
  • Does the program work for these examples?
  • If yes, how?
  • If no, why?

nlp-ai_at_cse.iitb
12
Assignment
  • 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_at_cse.iitb
13
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_at_cse.iitb
14
To Remind
The best way to learn programming is writing a
lot of programs on your own.
nlp-ai_at_cse.iitb
15
End
Thank you ?
nlp-ai_at_cse.iitb
Write a Comment
User Comments (0)
About PowerShow.com