Package edu.stanford.nlp.ling.tokensregex

Examples of edu.stanford.nlp.ling.tokensregex.PhraseTable$PhraseMatch


          "Col. W",
          "Jibril"
  );

  public void testPhraseTable() throws Exception {
    PhraseTable phraseTable = new PhraseTable();
    phraseTable.normalize = true;
    phraseTable.caseInsensitive = true;
    phraseTable.addPhrases(phrases);
    List<PhraseTable.PhraseMatch> matched = phraseTable.findAllMatches(testText);
    assertTrue(matched != null);
    assertEquals(12, matched.size());
    // Test lookup
    PhraseTable.Phrase p = phraseTable.lookupNormalized("COL.");
    assertEquals("Col.", p.getText());
  }
View Full Code Here


    PhraseTable.Phrase p = phraseTable.lookupNormalized("COL.");
    assertEquals("Col.", p.getText());
  }

  public void testIterator() throws Exception {
    PhraseTable phraseTable = new PhraseTable();
    phraseTable.caseInsensitive = true;
    phraseTable.addPhrases(phrases);

    Set<String> origPhrases = new HashSet<String>();
    origPhrases.addAll(phrases);
    Set<String> iteratedPhrases = new HashSet<String>();
    Iterator<PhraseTable.Phrase> iterator = phraseTable.iterator();
    while (iterator.hasNext()) {
      iteratedPhrases.add(iterator.next().getText());
    }
    Set<String> intersection = CollectionUtils.intersection(origPhrases, iteratedPhrases);
    Collection<String> inOrigNotInIterated = CollectionUtils.diff(origPhrases, intersection);
View Full Code Here

    assertTrue("In iterated but not in original: " + inIteratedNotInOrig, inIteratedNotInOrig.isEmpty());
  }

  public void testFindMatches() throws Exception {
    String text = "Who is Col. Jibril Rajoub";
    PhraseTable phraseTable = new PhraseTable();
    phraseTable.caseInsensitive = true;
    phraseTable.addPhrases(phrases);
    List<PhraseTable.PhraseMatch> matched = phraseTable.findMatches(text, 2, 5, true);
    assertTrue(matched != null);
    assertEquals(2, matched.size());
  }
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.ling.tokensregex.PhraseTable$PhraseMatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.