Package edu.washington.cs.knowitall.sequence

Examples of edu.washington.cs.knowitall.sequence.LayeredTokenPattern


  }

  @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

  }
 
  @Test(expected=SequenceException.class)
  public void testMatcher5() throws SequenceException {
    String patternStr = "^ [^A_x B_x] C_x $";
    @SuppressWarnings("unused")
    LayeredTokenPattern pat = new LayeredTokenPattern(patternStr);
  }
View Full Code Here

 
  @Test(expected=SequenceException.class)
  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

    for (String str: split) results.add(str);
    return results;
  }
 
  public List<String> extract(String patternStr, String test) throws SequenceException {
    LayeredTokenPattern pattern = new LayeredTokenPattern(patternStr);
    RegexTagger tagger = new RegexTagger(pattern, "R");
    List<String> testList = listize(test);
    SimpleLayeredSequence seq = new SimpleLayeredSequence(testList.size());
    seq.addLayer("w", testList);
    return tagger.tag(seq);
View Full Code Here

    public RegexGroupExtractor(LayeredTokenPattern pattern) {
        this.pattern = pattern;
    }

    public RegexGroupExtractor(String patternStr) {
        this(new LayeredTokenPattern(patternStr));
    }
View Full Code Here

     * @throws SequenceException
     *             if unable to compile pattern
     */
    public RegexExtractor(String patternString) throws SequenceException {
        this.patternString = patternString;
        this.pattern = new LayeredTokenPattern(patternString);
    }
View Full Code Here

     */
    private Predicate<ChunkedBinaryExtraction> relIsVWP()
            throws SequenceException {
        final String patternStr = String.format("(%s (%s+ (%s)+))+", VERB,
                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

Related Classes of edu.washington.cs.knowitall.sequence.LayeredTokenPattern

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.