/** * Checks if could create a NameSample without NameTypes, generate the * string representation and validate it. */ @Test public void testNoTypesToString() { String nameSampleStr = createSimpleNameSample(false).toString(); Assert.assertEquals("<START> U . S . <END> President <START> Barack Obama <END>" + " is considering " + "sending additional American forces to <START> Afghanistan <END> .", nameSampleStr); }
reducedNames, false); System.out.println(nameSample.toString());
/** * Checks that if the name is the last token in a sentence it is still outputed * correctly. */ @Test public void testNameAtEnd() { String[] sentence = new String[] { "My", "name", "is", "Anna" }; NameSample sample = new NameSample(sentence, new Span[]{new Span(3, 4)}, false); Assert.assertEquals("My name is <START> Anna <END>", sample.toString()); }
/** * Test serialization of unsorted sequential spans. */ @Test public void testUnsortedSequentialSpans() { String[] sentence = {"A", "Place", "a", "time", "A", "Person", "."}; Span[] names = {new Span(0, 2, "Place"), new Span(4, 6, "Person"), new Span(2, 4, "Time")}; NameSample nameSample = new NameSample(sentence, names, false); Assert.assertEquals( "<START:Place> A Place <END> <START:Time> a time <END> <START:Person> A Person <END> .", nameSample.toString()); }
/** * Test serialization of sequential spans. */ @Test public void testSequentialSpans() { String[] sentence = {"A", "Place", "a", "time", "A", "Person", "."}; Span[] names = {new Span(0, 2, "Place"), new Span(2, 4, "Time"), new Span(4, 6, "Person")}; NameSample nameSample = new NameSample(sentence, names, false); Assert.assertEquals( "<START:Place> A Place <END> <START:Time> a time <END> <START:Person> A Person <END> .", nameSample.toString()); }
/** * Checks if could create a NameSample with NameTypes, generate the * string representation and validate it. */ @Test public void testWithTypesToString() throws Exception { String nameSampleStr = createSimpleNameSample(true).toString(); Assert.assertEquals("<START:Location> U . S . <END> President <START:Person>" + " Barack Obama <END> " + "is considering sending additional American forces to <START:Location> Afghanistan <END> .", nameSampleStr); NameSample parsedSample = NameSample.parse("<START:Location> U . S . <END> " + "President <START:Person> Barack Obama <END> is considering sending " + "additional American forces to <START:Location> Afghanistan <END> .", false); Assert.assertEquals(createSimpleNameSample(true), parsedSample); }
sb.append(nameSample.toString()).append("\n");
.toArray(new Span[allSpans.size()])); NameSample nameSample = new NameSample(tokens, allSpansArray, isClearAdaptiveData); sb.append(nameSample.toString()).append("\n");
reducedNames, false); System.out.println(nameSample.toString());
reducedNames, false); System.out.println(nameSample.toString());