Package edu.washington.cs.knowitall.nlp

Examples of edu.washington.cs.knowitall.nlp.ChunkedSentence


    @Before
    public void setUp() throws Exception {
        String[] tokens = "John Smith was born in Detroit in March .".split(" ");
        String[] pos = "NNP NNP VBD VBN IN NNP IN NNP .".split(" ");
        String[] np = "B-NP I-NP O O O B-NP O B-NP O".split(" ");
        sent = new ChunkedSentence(tokens, pos, np);
        sameSent = sent.clone();
        tokens[0] = "Joe";
        otherSent = new ChunkedSentence(tokens, pos, np);
    }
View Full Code Here


    List<String> tokens = Arrays.asList(tokensStr.split(" "));
    List<String> posTags = Arrays.asList(posTagsStr.split(" "));
    List<String> npChunkTags = new ArrayList<String>(posTags.size());
    for (int i = 0; i < posTags.size(); i++) npChunkTags.add("O");
   
    ChunkedSentence sent = new ChunkedSentence(tokens, posTags, npChunkTags);
    ChunkedExtraction extr = new ChunkedExtraction(sent, new Range(0, posTags.size()));
   
    NormalizedField normField = normalizer.normalizeField(extr);
    String resultStr = normField.toString();
    assertEquals(expectedStr, resultStr);
View Full Code Here

    public void setUp() throws Exception {
       
        List<String> tokens = Arrays.asList("The President of the United States and black shoes and blue".split(" "));
        List<String> posTags = Arrays.asList("DT NNP IN DT NNP NNP CC JJ NNS CC JJ".split(" "));
        List<String> npChunkTags = Arrays.asList("O O O O O O O O O O O".split(" "));
        sent = new ChunkedSentence(tokens, posTags, npChunkTags);
       
        field1 = new ChunkedExtraction(sent, new Range(0, 6));
        field2 = new ChunkedExtraction(sent, new Range(7, 2));
        field3 = new ChunkedExtraction(sent, new Range(10, 1));
       
View Full Code Here

    public static ChunkedSentence asSentence(String tokensStr, String posTagsStr, String npChunkTagsStr) throws Exception {
        String[] tokens = tokensStr.split(" ");
        String[] posTags = posTagsStr.split(" ");
        String[] npChunkTags = npChunkTagsStr.split(" ");
        return new ChunkedSentence(tokens, posTags, npChunkTags);
    }
View Full Code Here

    private String prep = "[IN_pos TO_pos]";


    @Before
    public void setUp() throws Exception {
        sent1 = new ChunkedSentence(
                new String[] { "Obama", "was", "a", "professor", "of", "Law", "at", "UChicago", "." },
                new String[] { "NNP", "VBD", "DT", "NN", "IN", "NN", "IN", "NNP", "." },
                new String[] { "B-NP", "O", "B-NP", "I-NP", "I-NP", "I-NP", "O", "B-NP", "O" }
        );
    }
View Full Code Here

    e3.addMapper(new MergeOverlappingMapper());
  }
 
  @Test
  public void testMerge() throws Exception {
    ChunkedSentence sent = new ChunkedSentence(
      new String[] { "He", "wants", "to", "go", "to", "the", "store", "." },
            new String[] { "PRP", "VBZ", "TO", "VB", "TO", "DT", "NN", "." },
            new String[] { "B-NP", "O", "O", "O", "O", "B-NP", "I-NP", "O" }
        );
   
View Full Code Here

        expectedRanges.add(new Range(16, 2)); // the wake
        expectedRanges.add(new Range(19, 3)); // this unthinkable tragedy

        OpenNlpChunkedSentenceParser reader = new OpenNlpChunkedSentenceParser();
        reader.attachOfs(false);
        ChunkedSentence sent = reader.parseSentence(sentStr);

        ArrayList<Range> gotRanges = new ArrayList<Range>();
        Iterables.addAll(gotRanges, sent.getNpChunkRanges());

        assertEquals(expectedLength, sent.getLength());
        assertArrayEquals(expectedPos, sent.getPosTags().toArray());
        assertArrayEquals(expectedToks, sent.getTokens().toArray());
        assertEquals(expectedRanges, gotRanges);


    }
View Full Code Here

   
    private static void addSentExtr(String a, String b, String c,
            int xs, int xl, int rs, int rl, int ys, int yl, double conf,
            String docId) throws Exception {
       
        ChunkedSentence sent = toSent(a,b,c);
        sentences.add(sent);
        ChunkedBinaryExtraction extr = toExtr(sent, xs,xl, rs,rl, ys,yl);
        extr.setProperty("docId", docId);
        extr.setProperty("conf", Double.toString(conf));
        extractions.add(extr);
View Full Code Here

        return Arrays.asList(s.split(" "));
    }
   
    private static ChunkedSentence toSent(String toks, String pos,
            String chunks) throws Exception {
        return new ChunkedSentence(split(toks), split(pos), split(chunks));
    }
View Full Code Here

        if (fields.size() < 1) {
            throw new IllegalArgumentException("must have at least 1 field");
        }

        for (int i = 0; i < fields.size(); i++) {
            ChunkedSentence sent1 = fields.get(i).getSentence();
            ChunkedSentence sent2 = fields.get((i + 1) % fields.size())
                    .getSentence();
            if (!sent1.equals(sent2)) {
                throw new IllegalArgumentException(
                        "fields must come from the same sentence");
            }
View Full Code Here

TOP

Related Classes of edu.washington.cs.knowitall.nlp.ChunkedSentence

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.