@Test public void testMultiFilter() throws IOException { final String[] types = new String[] {person, organization}; filter = new NameSampleTypeFilter(types, sampleStream(text)); NameSample ns = filter.read(); Map<String, List<Span>> collect = Arrays.stream(ns.getNames()) .collect(Collectors.groupingBy(Span::getType)); Assert.assertEquals(2, collect.size()); Assert.assertEquals(2, collect.get(person).size()); Assert.assertEquals(1, collect.get(organization).size()); }
public NameSample read() throws IOException { NameSample sample = samples.read(); if (sample != null) { List<Span> filteredNames = new ArrayList<>(); for (Span name : sample.getNames()) { if (types.contains(name.getType())) { filteredNames.add(name); } } return new NameSample(sample.getId(), sample.getSentence(), filteredNames.toArray(new Span[filteredNames.size()]), null, sample.isClearAdaptiveDataSet()); } else { return null; } }
NameSampleTypeFilter extends FilterObjectStream<NameSample, NameSample> { public NameSample read() throws IOException { NameSample sample = samples.read(); if (sample != null) { List<Span> filteredNames = new ArrayList<>(); for (Span name : sample.getNames()) { if (types.contains(name.getType())) { filteredNames.add(name); } } return new NameSample(sample.getId(), sample.getSentence(), filteredNames.toArray(new Span[filteredNames.size()]), null, sample.isClearAdaptiveDataSet()); } else { return null; } } }
NameSampleTypeFilter extends FilterObjectStream<NameSample, NameSample> { public NameSample read() throws IOException { NameSample sample = samples.read(); if (sample != null) { List<Span> filteredNames = new ArrayList<>(); for (Span name : sample.getNames()) { if (types.contains(name.getType())) { filteredNames.add(name); } } return new NameSample(sample.getId(), sample.getSentence(), filteredNames.toArray(new Span[filteredNames.size()]), null, sample.isClearAdaptiveDataSet()); } else { return null; } } NameSampleTypeFilter(String[] types, ObjectStream<NameSample> samples);  NameSampleTypeFilter(Set<String> types, ObjectStream<NameSample> samples); }
NameSampleTypeFilter extends FilterObjectStream<NameSample, NameSample> { public NameSample read() throws IOException { NameSample sample = samples.read(); if (sample != null) { List<Span> filteredNames = new ArrayList<>(); for (Span name : sample.getNames()) { if (types.contains(name.getType())) { filteredNames.add(name); } } return new NameSample(sample.getId(), sample.getSentence(), filteredNames.toArray(new Span[filteredNames.size()]), null, sample.isClearAdaptiveDataSet()); } else { return null; } } NameSampleTypeFilter(String[] types, ObjectStream<NameSample> samples);  NameSampleTypeFilter(Set<String> types, ObjectStream<NameSample> samples); NameSample read(); }
NameSampleTypeFilter extends FilterObjectStream<NameSample, NameSample> { public NameSample read() throws IOException { NameSample sample = samples.read(); if (sample != null) { List<Span> filteredNames = new ArrayList<>(); for (Span name : sample.getNames()) { if (types.contains(name.getType())) { filteredNames.add(name); } } return new NameSample(sample.getId(), sample.getSentence(), filteredNames.toArray(new Span[filteredNames.size()]), null, sample.isClearAdaptiveDataSet()); } else { return null; } } NameSampleTypeFilter(String[] types, ObjectStream<NameSample> samples);  NameSampleTypeFilter(Set<String> types, ObjectStream<NameSample> samples); NameSample read();  }