Package edu.washington.cs.knowitall.sequence

Examples of edu.washington.cs.knowitall.sequence.LayeredTokenPattern.matcher()


  @Test
  public void testMatcher1() throws SequenceException {
    String patternStr = "There_w are_w CD_p [B-NP_n I-NP_n]+ (IN_p [B-NP_n I-NP_n]+)*";
    LayeredTokenPattern pat = new LayeredTokenPattern(patternStr);
    LayeredTokenMatcher m = pat.matcher(seq);
    assertTrue(m.find());
    assertEquals(0, m.start());
    assertEquals(6, m.end());
  }
 
View Full Code Here


 
  @Test
  public void testMatcher2() throws SequenceException {
    String patternStr = "B-NP_n I-NP_n*";
    LayeredTokenPattern pat = new LayeredTokenPattern(patternStr);
    LayeredTokenMatcher m = pat.matcher(seq);
    assertTrue(m.find());
    assertEquals(2, m.start());
    assertEquals(4, m.end());
    assertTrue(m.find());
    assertEquals(5, m.start());
View Full Code Here

 
  @Test
  public void testMatcher3() throws SequenceException {
    String patternStr = "B-NP_n I-NP_n* ._p?$";
    LayeredTokenPattern pat = new LayeredTokenPattern(patternStr);
    LayeredTokenMatcher m = pat.matcher(seq);
    assertTrue(m.find());
    assertEquals(5, m.start());
    assertEquals(7, m.end());
    assertFalse(m.find());
  }
View Full Code Here

 
  @Test
  public void testMatcher4() throws SequenceException {
    String patternStr = "...";
    LayeredTokenPattern pat = new LayeredTokenPattern(patternStr);
    LayeredTokenMatcher m = pat.matcher(seq);
    assertTrue(m.find());
    assertEquals(0, m.start());
    assertEquals(3, m.end());
    assertTrue(m.find());
    assertEquals(3, m.start());
View Full Code Here

  public void testMatcher6() throws Exception {

    String patternStr = "B-NP_np I-NP_np* from_word the_word B-NP_np I-NP_np*";
    LayeredTokenPattern pattern = new LayeredTokenPattern(patternStr);
    OpenNlpSentenceChunker chunker = new OpenNlpSentenceChunker();   
    pattern.matcher(chunker.chunkSentence("Hello, world."));
   
  }
}
View Full Code Here

                WORD, PREP);
        final LayeredTokenPattern pattern = new LayeredTokenPattern(patternStr);
        return new Predicate<ChunkedBinaryExtraction>() {
            public boolean apply(ChunkedBinaryExtraction e) {
                try {
                    LayeredTokenMatcher m = pattern.matcher(e.getRelation());
                    int n = 0;
                    while (m.find())
                        n++;
                    return n == 1;
                } catch (SequenceException ex) {
View Full Code Here

TOP
Copyright © 2015 www.massapi.com. 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.