@Test public void testDropOverlappingSpans() { Span[] spans = new Span[] {new Span(1, 10), new Span(1,11), new Span(1,11), new Span(5, 15)}; Span[] remainingSpan = NameFinderME.dropOverlappingSpans(spans); Assert.assertEquals(new Span(1, 11), remainingSpan[0]); }
public static Span[] dropOverlappingSpans(Span[] spans) { List<Span> sortedSpans = new ArrayList<>(spans.length); Collections.addAll(sortedSpans, spans); Collections.sort(sortedSpans); Iterator<Span> it = sortedSpans.iterator(); Span lastSpan = null; while (it.hasNext()) { Span span = it.next(); if (lastSpan != null) { if (lastSpan.intersects(span)) { it.remove(); span = lastSpan; } } lastSpan = span; } return sortedSpans.toArray(new Span[sortedSpans.size()]); }
NameFinderME implements TokenNameFinder { public static Span[] dropOverlappingSpans(Span[] spans) { List<Span> sortedSpans = new ArrayList<>(spans.length); Collections.addAll(sortedSpans, spans); Collections.sort(sortedSpans); Iterator<Span> it = sortedSpans.iterator(); Span lastSpan = null; while (it.hasNext()) { Span span = it.next(); if (lastSpan != null) { if (lastSpan.intersects(span)) { it.remove(); span = lastSpan; } } lastSpan = span; } return sortedSpans.toArray(new Span[sortedSpans.size()]); } }
NameFinderME implements TokenNameFinder { public static Span[] dropOverlappingSpans(Span[] spans) { List<Span> sortedSpans = new ArrayList<>(spans.length); Collections.addAll(sortedSpans, spans); Collections.sort(sortedSpans); Iterator<Span> it = sortedSpans.iterator(); Span lastSpan = null; while (it.hasNext()) { Span span = it.next(); if (lastSpan != null) { if (lastSpan.intersects(span)) { it.remove(); span = lastSpan; } } lastSpan = span; } return sortedSpans.toArray(new Span[sortedSpans.size()]); } NameFinderME(TokenNameFinderModel model); }
NameFinderME implements TokenNameFinder { public static Span[] dropOverlappingSpans(Span[] spans) { List<Span> sortedSpans = new ArrayList<>(spans.length); Collections.addAll(sortedSpans, spans); Collections.sort(sortedSpans); Iterator<Span> it = sortedSpans.iterator(); Span lastSpan = null; while (it.hasNext()) { Span span = it.next(); if (lastSpan != null) { if (lastSpan.intersects(span)) { it.remove(); span = lastSpan; } } lastSpan = span; } return sortedSpans.toArray(new Span[sortedSpans.size()]); } NameFinderME(TokenNameFinderModel model); Span[] find(String[] tokens); Span[] find(String[] tokens, String[][] additionalContext); void clearAdaptiveData(); void probs(double[] probs); double[] probs(); double[] probs(Span[] spans); static TokenNameFinderModel train(String languageCode, String type,
          ObjectStream<NameSample> samples, TrainingParameters trainParams,
          TokenNameFinderFactory factory); static Span[] dropOverlappingSpans(Span[] spans); }
NameFinderME implements TokenNameFinder { public static Span[] dropOverlappingSpans(Span[] spans) { List<Span> sortedSpans = new ArrayList<>(spans.length); Collections.addAll(sortedSpans, spans); Collections.sort(sortedSpans); Iterator<Span> it = sortedSpans.iterator(); Span lastSpan = null; while (it.hasNext()) { Span span = it.next(); if (lastSpan != null) { if (lastSpan.intersects(span)) { it.remove(); span = lastSpan; } } lastSpan = span; } return sortedSpans.toArray(new Span[sortedSpans.size()]); } NameFinderME(TokenNameFinderModel model); Span[] find(String[] tokens); Span[] find(String[] tokens, String[][] additionalContext); void clearAdaptiveData(); void probs(double[] probs); double[] probs(); double[] probs(Span[] spans); static TokenNameFinderModel train(String languageCode, String type,
          ObjectStream<NameSample> samples, TrainingParameters trainParams,
          TokenNameFinderFactory factory); static Span[] dropOverlappingSpans(Span[] spans); static final int DEFAULT_BEAM_SIZE; static final String START; static final String CONTINUE; static final String OTHER; }