1 / 12

MAF API

Julien Nioche Univ. Sheffield LIRICS.MAF API : a quick overview Lirics Barcelona Meeting 21 / 06 / 05. API Implementation for the GATE PRs. GATE. MAF API. Clients. XML Document. // sample code to list all strings that has been annotated // as noun in the text

tuan
Download Presentation

MAF API

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Julien NiocheUniv. SheffieldLIRICS.MAF API : a quick overviewLirics Barcelona Meeting21 / 06 / 05

  2. API Implementation for the GATE PRs GATE MAF API Clients XML Document

  3. // sample code to list all strings that has been annotated // as noun in the text MAF doc = liricsDocImpl.getMAF(); WordFormSet wfs = doc.getAllWordForms(); wfs = wfs.getWordFormsWithFeatureID(“pos@noun”); Iterator<WordForm> iter = wfs.getIterator(); while(iter.hasNext()) { WordForm wf = iter.next(); TokenSet tkSet = wf.getAllTokens(); Iterator<Token> tkIter = tkSet.iterator(); while(tkIter.hasNext()) { Token token = tkIter.next(); System.out.print(token.getTokenString()); System.out.print(“ “); } System.out.println(); }

  4. // sample code to list all strings that has been annotated // as noun in the text MAF doc = liricsDocImpl.getMAF(); WordFormSet wfs = doc.getAllWordForms(); wfs = wfs.getWordFormsWithFeatureID(“pos@noun”); Iterator<WordForm> iter = wfs.getIterator(); while(iter.hasNext()) { WordForm wf = iter.next(); TokenSet tkSet = wf.getAllTokens(); Iterator<Token> tkIter = tkSet.iterator(); while(tkIter.hasNext()) { Token token = tkIter.next(); System.out.print(token.getTokenString()); System.out.print(“ “); } System.out.println(); } From LiricsDocumentImpl Find out the MAF Information

  5. All wordForms in MAF document will have MAF information attached // sample code to list all strings that has been annotated // as noun in the text MAF doc = liricsDocImpl.getMAF(); WordFormSet wfs = doc.getAllWordForms(); wfs = wfs.getWordFormsWithFeatureID(“pos@noun”); Iterator<WordForm> iter = wfs.getIterator(); while(iter.hasNext()) { WordForm wf = iter.next(); TokenSet tkSet = wf.getAllTokens(); Iterator<Token> tkIter = tkSet.iterator(); while(tkIter.hasNext()) { Token token = tkIter.next(); System.out.print(token.getTokenString()); System.out.print(“ “); } System.out.println(); }

  6. // sample code to list all strings that has been annotated // as noun in the text MAF doc = liricsDocImpl.getMAF(); WordFormSet wfs = doc.getAllWordForms(); wfs = wfs.getWordFormsWithFeatureID(“pos@noun”); Iterator<WordForm> iter = wfs.getIterator(); while(iter.hasNext()) { WordForm wf = iter.next(); TokenSet tkSet = wf.getAllTokens(); Iterator<Token> tkIter = tkSet.iterator(); while(tkIter.hasNext()) { Token token = tkIter.next(); System.out.print(token.getTokenString()); System.out.print(“ “); } System.out.println(); } Find out only those wordForms which have feature “pos” and value “noun”

  7. // sample code to list all strings that has been annotated // as noun in the text MAF doc = liricsDocImpl.getMAF(); WordFormSet wfs = doc.getAllWordForms(); wfs = wfs.getWordFormsWithFeatureID(“pos@noun”); Iterator<WordForm> iter = wfs.getIterator(); while(iter.hasNext()) { WordForm wf = iter.next(); TokenSet tkSet = wf.getAllTokens(); Iterator<Token> tkIter = tkSet.iterator(); while(tkIter.hasNext()) { Token token = tkIter.next(); System.out.print(token.getTokenString()); System.out.print(“ “); } System.out.println(); } Obtain an iterator for such wordForms

  8. // sample code to list all strings that has been annotated // as noun in the text MAF doc = liricsDocImpl.getMAF(); WordFormSet wfs = doc.getAllWordForms(); wfs = wfs.getWordFormsWithFeatureID(“pos@noun”); Iterator<WordForm> iter = wfs.getIterator(); while(iter.hasNext()) { WordForm wf = iter.next(); TokenSet tkSet = wf.getAllTokens(); Iterator<Token> tkIter = tkSet.iterator(); while(tkIter.hasNext()) { Token token = tkIter.next(); System.out.print(token.getTokenString()); System.out.print(“ “); } System.out.println(); } Consider one wordForm at a time

  9. // sample code to list all strings that has been annotated // as noun in the text MAF doc = liricsDocImpl.getMAF(); WordFormSet wfs = doc.getAllWordForms(); wfs = wfs.getWordFormsWithFeatureID(“pos@noun”); Iterator<WordForm> iter = wfs.getIterator(); while(iter.hasNext()) { WordForm wf = iter.next(); TokenSet tkSet = wf.getAllTokens(); Iterator<Token> tkIter = tkSet.iterator(); while(tkIter.hasNext()) { Token token = tkIter.next(); System.out.print(token.getTokenString()); System.out.print(“ “); } System.out.println(); } For each wordForm find out all underlying tokens

  10. // sample code to list all strings that has been annotated // as noun in the text MAF doc = liricsDocImpl.getMAF(); WordFormSet wfs = doc.getAllWordForms(); wfs = wfs.getWordFormsWithFeatureID(“pos@noun”); Iterator<WordForm> iter = wfs.getIterator(); while(iter.hasNext()) { WordForm wf = iter.next(); TokenSet tkSet = wf.getAllTokens(); Iterator<Token> tkIter = tkSet.iterator(); while(tkIter.hasNext()) { Token token = tkIter.next(); System.out.print(token.getTokenString()); System.out.print(“ “); } System.out.println(); } Obtain an Iterator to iterate through all tokens

  11. // sample code to list all strings that has been annotated // as noun in the text MAF doc = liricsDocImpl.getMAF(); WordFormSet wfs = doc.getAllWordForms(); wfs = wfs.getWordFormsWithFeatureID(“pos@noun”); Iterator<WordForm> iter = wfs.getIterator(); while(iter.hasNext()) { WordForm wf = iter.next(); TokenSet tkSet = wf.getAllTokens(); Iterator<Token> tkIter = tkSet.iterator(); while(tkIter.hasNext()) { Token token = tkIter.next(); System.out.print(token.getTokenString()); System.out.print(“ “); } System.out.println(); } Considering one Token at a time

  12. // sample code to list all strings that has been annotated // as noun in the text MAF doc = liricsDocImpl.getMAF(); WordFormSet wfs = doc.getAllWordForms(); wfs = wfs.getWordFormsWithFeatureID(“pos@noun”); Iterator<WordForm> iter = wfs.getIterator(); while(iter.hasNext()) { WordForm wf = iter.next(); TokenSet tkSet = wf.getAllTokens(); Iterator<Token> tkIter = tkSet.iterator(); while(tkIter.hasNext()) { Token token = tkIter.next(); System.out.print(token.getTokenString()); System.out.print(“ “); } System.out.println(); } Finally printing the token value

More Related