Package edu.washington.cs.knowitall.nlp.extraction

Examples of edu.washington.cs.knowitall.nlp.extraction.SpanExtraction


    }
   
    @Test
    public void test1() {
        List<Range> ranges = getRanges(0,2, 2,3, 5,1);
        SpanExtraction extr =
            new SpanExtraction(sent, ranges);
       
        assertEquals(3, extr.getNumFields());
        assertEquals("John Smith", extr.getField(0).toString());
        assertEquals("John Smith", extr.getField("field0").toString());
        assertEquals("was born in", extr.getField(1).toString());
        assertEquals("was born in", extr.getField("field1").toString());
        assertEquals("Detroit", extr.getField(2).toString());
        assertEquals("Detroit", extr.getField("field2").toString());
       
        List<String> fieldNames = new ArrayList<String>(3);
        fieldNames.add("arg1");
        fieldNames.add("rel");
        fieldNames.add("arg2");
        extr = new SpanExtraction(sent, ranges, fieldNames);
       
        assertEquals("John Smith", extr.getField("arg1").toString());
        assertEquals("was born in", extr.getField("rel").toString());
        assertEquals("Detroit", extr.getField("arg2").toString());
    }
View Full Code Here


    }
   
    @Test
    public void test3() {
        List<ChunkedExtraction> extrs = getExtractions(sent, 0,2, 2,3, 5,1);
        SpanExtraction extr =
            new SpanExtraction(extrs);
       
        assertEquals(3, extr.getNumFields());
        assertEquals("John Smith", extr.getField(0).toString());
        assertEquals("John Smith", extr.getField("field0").toString());
        assertEquals("was born in", extr.getField(1).toString());
        assertEquals("was born in", extr.getField("field1").toString());
        assertEquals("Detroit", extr.getField(2).toString());
        assertEquals("Detroit", extr.getField("field2").toString());
       
        List<String> fieldNames = new ArrayList<String>(3);
        fieldNames.add("arg1");
        fieldNames.add("rel");
        fieldNames.add("arg2");
        extr = new SpanExtraction(extrs, fieldNames);
       
        assertEquals("John Smith", extr.getField("arg1").toString());
        assertEquals("was born in", extr.getField("rel").toString());
        assertEquals("Detroit", extr.getField("arg2").toString());
    }
View Full Code Here

   
    @Test
    public void test4() {
        List<ChunkedExtraction> extrs = getExtractions(sent, 0,2, 2,3);
        extrs.add(new ChunkedExtraction(sameSent, new Range(5,1)));
        new SpanExtraction(extrs);
        assertTrue(true);
    }
View Full Code Here

   
    @Test(expected=IllegalArgumentException.class)
    public void test5() {
        List<ChunkedExtraction> extrs = getExtractions(sent, 0,2, 2,3);
        extrs.add(new ChunkedExtraction(otherSent, new Range(5,1)));
        new SpanExtraction(extrs);
    }
View Full Code Here

    }
   
    @Test
    public void test6() {
        List<Range> ranges = getRanges(0,2, 2,3, 5,1);
        SpanExtraction extr = new SpanExtraction(sent, ranges);
        List<String> expected = split("B-field0 I-field0 B-field1 I-field1 I-field1 B-field2 O O O");
        assertEquals(expected, extr.toBIOLayer());
       
        extr = new SpanExtraction(sent, ranges, split("arg1 rel arg2"));
        expected = split("B-arg1 I-arg1 B-rel I-rel I-rel B-arg2 O O O");
        assertEquals(expected, extr.toBIOLayer());
    }
View Full Code Here

    @Test
    public void testExtract1() throws Exception {
        RegexGroupExtractor extractor = new RegexGroupExtractor("(B-NP_np I-NP_np*) is_tok the_tok mayor_tok of_tok (B-NP_np I-NP_np*)");
        List<SpanExtraction> extrs = extract(extractor, sents.get(0));
        assertEquals(1, extrs.size());
        SpanExtraction extr = extrs.get(0);
        assertEquals(2, extr.getNumFields());
        assertEquals("Mike", extr.getField(0).getTokensAsString());
        assertEquals("Seattle", extr.getField(1).getTokensAsString());
    }
View Full Code Here

    @Test
    public void testExtract2() throws Exception {
        RegexGroupExtractor extractor = new RegexGroupExtractor("(B-NP_np I-NP_np*) is_tok the_tok (NN_pos) of_tok (B-NP_np I-NP_np*)");
        List<SpanExtraction> extrs = extract(extractor, sents.get(0));
        assertEquals(1, extrs.size());
        SpanExtraction extr = extrs.get(0);
        assertEquals(3, extr.getNumFields());
        assertEquals("Mike", extr.getField(0).getTokensAsString());
        assertEquals("mayor", extr.getField(1).getTokensAsString());
        assertEquals("Seattle", extr.getField(2).getTokensAsString());
    }
View Full Code Here

                if (start < 0 || end < 0)
                    break;
                fieldRanges.add(new Range(start, len));
            }
            if (fieldRanges.size() > 0) {
                SpanExtraction extr = new SpanExtraction(sent, fieldRanges);
                results.add(extr);
            }
        }
        return results;
    }
View Full Code Here

TOP

Related Classes of edu.washington.cs.knowitall.nlp.extraction.SpanExtraction

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.