@Test public void testDecodePairFirst() { List<String> encoded = Arrays.asList(B_START, B_CONTINUE, OTHER); Span[] expected = new Span[] {new Span(0, 2, B_TYPE)}; Span[] actual = codec.decode(encoded); Assert.assertArrayEquals(expected, actual); }
public Span[] decode(List<String> c) { int start = -1; int end = -1; List<Span> spans = new ArrayList<>(c.size()); for (int li = 0; li < c.size(); li++) { String chunkTag = c.get(li); if (chunkTag.endsWith(BioCodec.START)) { if (start != -1) { spans.add(new Span(start, end, extractNameType(c.get(li - 1)))); } start = li; end = li + 1; } else if (chunkTag.endsWith(BioCodec.CONTINUE)) { end = li + 1; } else if (chunkTag.endsWith(BioCodec.OTHER)) { if (start != -1) { spans.add(new Span(start, end, extractNameType(c.get(li - 1)))); start = -1; end = -1; } } } if (start != -1) { spans.add(new Span(start, end, extractNameType(c.get(c.size() - 1)))); } return spans.toArray(new Span[spans.size()]); }
BioCodec implements SequenceCodec<String> { public Span[] decode(List<String> c) { int start = -1; int end = -1; List<Span> spans = new ArrayList<>(c.size()); for (int li = 0; li < c.size(); li++) { String chunkTag = c.get(li); if (chunkTag.endsWith(BioCodec.START)) { if (start != -1) { spans.add(new Span(start, end, extractNameType(c.get(li - 1)))); } start = li; end = li + 1; } else if (chunkTag.endsWith(BioCodec.CONTINUE)) { end = li + 1; } else if (chunkTag.endsWith(BioCodec.OTHER)) { if (start != -1) { spans.add(new Span(start, end, extractNameType(c.get(li - 1)))); start = -1; end = -1; } } } if (start != -1) { spans.add(new Span(start, end, extractNameType(c.get(c.size() - 1)))); } return spans.toArray(new Span[spans.size()]); } }
BioCodec implements SequenceCodec<String> { public Span[] decode(List<String> c) { int start = -1; int end = -1; List<Span> spans = new ArrayList<>(c.size()); for (int li = 0; li < c.size(); li++) { String chunkTag = c.get(li); if (chunkTag.endsWith(BioCodec.START)) { if (start != -1) { spans.add(new Span(start, end, extractNameType(c.get(li - 1)))); } start = li; end = li + 1; } else if (chunkTag.endsWith(BioCodec.CONTINUE)) { end = li + 1; } else if (chunkTag.endsWith(BioCodec.OTHER)) { if (start != -1) { spans.add(new Span(start, end, extractNameType(c.get(li - 1)))); start = -1; end = -1; } } } if (start != -1) { spans.add(new Span(start, end, extractNameType(c.get(c.size() - 1)))); } return spans.toArray(new Span[spans.size()]); }  }
BioCodec implements SequenceCodec<String> { public Span[] decode(List<String> c) { int start = -1; int end = -1; List<Span> spans = new ArrayList<>(c.size()); for (int li = 0; li < c.size(); li++) { String chunkTag = c.get(li); if (chunkTag.endsWith(BioCodec.START)) { if (start != -1) { spans.add(new Span(start, end, extractNameType(c.get(li - 1)))); } start = li; end = li + 1; } else if (chunkTag.endsWith(BioCodec.CONTINUE)) { end = li + 1; } else if (chunkTag.endsWith(BioCodec.OTHER)) { if (start != -1) { spans.add(new Span(start, end, extractNameType(c.get(li - 1)))); start = -1; end = -1; } } } if (start != -1) { spans.add(new Span(start, end, extractNameType(c.get(c.size() - 1)))); } return spans.toArray(new Span[spans.size()]); }  Span[] decode(List<String> c); String[] encode(Span[] names, int length); NameFinderSequenceValidator createSequenceValidator(); @Override boolean areOutcomesCompatible(String[] outcomes); }
BioCodec implements SequenceCodec<String> { public Span[] decode(List<String> c) { int start = -1; int end = -1; List<Span> spans = new ArrayList<>(c.size()); for (int li = 0; li < c.size(); li++) { String chunkTag = c.get(li); if (chunkTag.endsWith(BioCodec.START)) { if (start != -1) { spans.add(new Span(start, end, extractNameType(c.get(li - 1)))); } start = li; end = li + 1; } else if (chunkTag.endsWith(BioCodec.CONTINUE)) { end = li + 1; } else if (chunkTag.endsWith(BioCodec.OTHER)) { if (start != -1) { spans.add(new Span(start, end, extractNameType(c.get(li - 1)))); start = -1; end = -1; } } } if (start != -1) { spans.add(new Span(start, end, extractNameType(c.get(c.size() - 1)))); } return spans.toArray(new Span[spans.size()]); }  Span[] decode(List<String> c); String[] encode(Span[] names, int length); NameFinderSequenceValidator createSequenceValidator(); @Override boolean areOutcomesCompatible(String[] outcomes); static final String START; static final String CONTINUE; static final String OTHER; }