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

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


   
    private List<ChunkedExtraction> getExtractions(ChunkedSentence sent, int... args) {
        List<Range> ranges = getRanges(args);
        List<ChunkedExtraction> extrs = new ArrayList<ChunkedExtraction>();
        for (Range r : ranges) {
            extrs.add(new ChunkedExtraction(sent, r));
        }
        return extrs;
    }
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

    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

        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

        Iterable<ChunkedExtraction> extrIter = extractor.extract(sent1);
        List<ChunkedExtraction> extrs = new ArrayList<ChunkedExtraction>();
        Iterables.addAll(extrs, extrIter);
        Assert.assertEquals(1, extrs.size());

        ChunkedExtraction extr = extrs.get(0);
        Assert.assertEquals("was a professor of Law at", extr.toString());
    }
View Full Code Here

            while (m.find()) {
                int start = m.start();
                int length = m.end() - start;
                Range r = new Range(start, length);
                ChunkedExtraction extr = new ChunkedExtraction(sentence, r);
                results.add(extr);
            }
            return results;

        } catch (SequenceException e) {
View Full Code Here

        ChunkedArgumentExtraction arg1 = extr.getArgument1();
        out.println(arg1.getTokensAsString());
        out.println(arg1.getRange().getStart() + " "
                + arg1.getRange().getLength());

        ChunkedExtraction rel = extr.getRelation();
        out.println(rel.getTokensAsString());
        out.println(rel.getRange().getStart() + " "
                + rel.getRange().getLength());

        ChunkedArgumentExtraction arg2 = extr.getArgument2();
        out.println(arg2.getTokensAsString());
        out.println(arg2.getRange().getStart() + " "
                + arg2.getRange().getLength());
View Full Code Here

            }
            List<Range> mergedRanges = mergeOverlapping(ranges);
            List<ChunkedExtraction> result = new ArrayList<ChunkedExtraction>(
                    mergedRanges.size());
            for (Range r : mergedRanges) {
                ChunkedExtraction extr = new ChunkedExtraction(sent, r);
                result.add(extr);
            }
            return result;
        } else {
            return extrList;
View Full Code Here

        }
        return false;
    }

    private boolean npBeforeArg1(ChunkedBinaryExtraction e) {
        ChunkedExtraction arg1 = e.getArgument1();
        int start = arg1.getRange().getStart();
        if (start == 0) {
            return false;
        } else {
            ChunkedSentence sent = arg1.getSentence();
            return sent.getChunkTags().get(start - 1).endsWith("-NP");
        }

    }
View Full Code Here

TOP

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

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.