@Test public void testWithoutNameTypes() throws Exception { InputStreamFactory in = new ResourceAsStreamFactory(getClass(), "/opennlp/tools/namefind/AnnotatedSentences.txt"); NameSampleDataStream ds = new NameSampleDataStream( new PlainTextByLineStream(in, StandardCharsets.ISO_8859_1)); NameSample ns = ds.read(); String[] expectedNames = { "Alan McKennedy", "Julie", "Marie Clara", "Stefanie Schmidt", "Mike", "Stefanie Schmidt", "George", "Luise", "George Bauer", "Alisa Fernandes", "Alisa", "Mike Sander", "Stefan Miller", "Stefan Miller", "Stefan Miller", "Elenor Meier", "Gina Schneider", "Bruno Schulz", "Michel Seile", "George Miller", "Miller", "Peter Schubert", "Natalie" }; List<String> names = new ArrayList<>(); List<Span> spans = new ArrayList<>(); while (ns != null) { for (Span nameSpan : ns.getNames()) { names.add(sublistToString(ns.getSentence(), nameSpan)); spans.add(nameSpan); } ns = ds.read(); } ds.close(); assertEquals(expectedNames.length, names.size()); assertEquals(createDefaultSpan(6,8), spans.get(0)); assertEquals(createDefaultSpan(3,4), spans.get(1)); assertEquals(createDefaultSpan(1,3), spans.get(2)); assertEquals(createDefaultSpan(4,6), spans.get(3)); assertEquals(createDefaultSpan(1,2), spans.get(4)); assertEquals(createDefaultSpan(4,6), spans.get(5)); assertEquals(createDefaultSpan(2,3), spans.get(6)); assertEquals(createDefaultSpan(16,17), spans.get(7)); assertEquals(createDefaultSpan(18,20), spans.get(8)); assertEquals(createDefaultSpan(0,2), spans.get(9)); assertEquals(createDefaultSpan(0,1), spans.get(10)); assertEquals(createDefaultSpan(3,5), spans.get(11)); assertEquals(createDefaultSpan(3,5), spans.get(12)); assertEquals(createDefaultSpan(10,12), spans.get(13)); assertEquals(createDefaultSpan(1,3), spans.get(14)); assertEquals(createDefaultSpan(6,8), spans.get(15)); assertEquals(createDefaultSpan(6,8), spans.get(16)); assertEquals(createDefaultSpan(8,10), spans.get(17)); assertEquals(createDefaultSpan(12,14), spans.get(18)); assertEquals(createDefaultSpan(1,3), spans.get(19)); assertEquals(createDefaultSpan(0,1), spans.get(20)); assertEquals(createDefaultSpan(2,4), spans.get(21)); assertEquals(createDefaultSpan(5,6), spans.get(22)); }
public NameSample read() throws IOException { String token = samples.read(); boolean isClearAdaptiveData = false; while (token != null && token.trim().length() == 0) { isClearAdaptiveData = true; token = samples.read(); } if (token != null) { return NameSample.parse(token, isClearAdaptiveData); } else { return null; } }
NameSampleDataStream extends FilterObjectStream<String, NameSample> { public NameSample read() throws IOException { String token = samples.read(); boolean isClearAdaptiveData = false; while (token != null && token.trim().length() == 0) { isClearAdaptiveData = true; token = samples.read(); } if (token != null) { return NameSample.parse(token, isClearAdaptiveData); } else { return null; } } }
NameSampleDataStream extends FilterObjectStream<String, NameSample> { public NameSample read() throws IOException { String token = samples.read(); boolean isClearAdaptiveData = false; while (token != null && token.trim().length() == 0) { isClearAdaptiveData = true; token = samples.read(); } if (token != null) { return NameSample.parse(token, isClearAdaptiveData); } else { return null; } } NameSampleDataStream(ObjectStream<String> in); }
NameSampleDataStream extends FilterObjectStream<String, NameSample> { public NameSample read() throws IOException { String token = samples.read(); boolean isClearAdaptiveData = false; while (token != null && token.trim().length() == 0) { isClearAdaptiveData = true; token = samples.read(); } if (token != null) { return NameSample.parse(token, isClearAdaptiveData); } else { return null; } } NameSampleDataStream(ObjectStream<String> in); NameSample read(); }
NameSampleDataStream extends FilterObjectStream<String, NameSample> { public NameSample read() throws IOException { String token = samples.read(); boolean isClearAdaptiveData = false; while (token != null && token.trim().length() == 0) { isClearAdaptiveData = true; token = samples.read(); } if (token != null) { return NameSample.parse(token, isClearAdaptiveData); } else { return null; } } NameSampleDataStream(ObjectStream<String> in); NameSample read(); static final String START_TAG_PREFIX; static final String START_TAG; static final String END_TAG; }