Package edu.washington.cs.knowitall.commonlib

Examples of edu.washington.cs.knowitall.commonlib.Range


   
    private List<Range> getRanges(int... args) {
        assert args.length % 2 == 0;
        List<Range> result = new ArrayList<Range>(args.length/2);
        for (int i = 0; i < args.length; i += 2) {
            Range range = new Range(args[i], args[i+1]);
            result.add(range);
        }
        return result;
    }
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

        BIOLayeredSequence seq = new BIOLayeredSequence(input.size());
        seq.addSpanLayer("x", input);
       
        List<Range> ranges = seq.getSpans("x");
        assertEquals(2, ranges.size());
        assertEquals(new Range(1,2), ranges.get(0));
        assertEquals(new Range(5,2), ranges.get(1));
       
        ranges = new ArrayList<Range>(seq.getSpans("x", "X"));
        assertEquals(1, ranges.size());
        assertEquals(new Range(1,2), ranges.get(0));
       
        ranges = new ArrayList<Range>(seq.getSpans("x", "Y"));
        assertEquals(1, ranges.size());
        assertEquals(new Range(5,2), ranges.get(0));
       
        ranges = new ArrayList<Range>(seq.getSpans("x", "Z"));
        assertEquals(0, ranges.size());
       
    }
View Full Code Here

   
    @Test
    public void test4() throws SequenceException {
        BIOLayeredSequence seq = new BIOLayeredSequence(5);
        List<Range> ranges = new ArrayList<Range>();
        ranges.add(new Range(1,2));
        ranges.add(new Range(3,1));
        seq.addSpanLayerRanges("layer", "X", ranges);
        assertEquals(2, seq.getSpans("layer").size());
        List<String> expected = split("O B-X I-X B-X O");
        assertEquals(expected, seq.getLayer("layer"));
    }
View Full Code Here

   
    @Test(expected=IndexOutOfBoundsException.class)
    public void test5() throws SequenceException {
        BIOLayeredSequence seq = new BIOLayeredSequence(5);
        List<Range> ranges = new ArrayList<Range>();
        ranges.add(new Range(1,10));
        seq.addSpanLayerRanges("layer", "X", ranges);
    }
View Full Code Here

   
    @Test(expected=SequenceException.class)
    public void test6() throws SequenceException {
        BIOLayeredSequence seq = new BIOLayeredSequence(5);
        List<Range> ranges = new ArrayList<Range>();
        ranges.add(new Range(1,2));
        ranges.add(new Range(2,1));
        seq.addSpanLayerRanges("layer", "X", ranges);
    }
View Full Code Here

    @Test
    public void test7() throws SequenceException {
        BIOLayeredSequence seq = new BIOLayeredSequence(5);
        List<Range> ranges = new ArrayList<Range>();
        ranges.add(new Range(0,2));
        ranges.add(new Range(3,2));
        seq.addSpanLayerRanges("layer", "X", ranges);
        List<String> expected = split("B-X I-X O B-X I-X");
        assertEquals(expected, seq.getLayer("layer"));
    }
View Full Code Here

TOP

Related Classes of edu.washington.cs.knowitall.commonlib.Range

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.