@Test public void testDecodeTripletFirst() { List<String> encoded = Arrays.asList(A_START, A_CONTINUE, A_LAST, OTHER); Span[] expected = new Span[] {new Span(0, 3, A_TYPE)}; Span[] actual = codec.decode(encoded); Assert.assertArrayEquals(expected, actual); }
@Override 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(BilouCodec.START)) { start = li; end = li + 1; } else if (chunkTag.endsWith(BilouCodec.CONTINUE)) { end = li + 1; } else if (chunkTag.endsWith(LAST)) { if (start != -1) { spans.add(new Span(start, end + 1, BioCodec.extractNameType(c.get(li - 1)))); start = -1; end = -1; } } else if (chunkTag.endsWith(UNIT)) { spans.add(new Span(li, li + 1, BioCodec.extractNameType(c.get(li)))); } } return spans.toArray(new Span[spans.size()]); }
BilouCodec implements SequenceCodec<String> { @Override 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(BilouCodec.START)) { start = li; end = li + 1; } else if (chunkTag.endsWith(BilouCodec.CONTINUE)) { end = li + 1; } else if (chunkTag.endsWith(LAST)) { if (start != -1) { spans.add(new Span(start, end + 1, BioCodec.extractNameType(c.get(li - 1)))); start = -1; end = -1; } } else if (chunkTag.endsWith(UNIT)) { spans.add(new Span(li, li + 1, BioCodec.extractNameType(c.get(li)))); } } return spans.toArray(new Span[spans.size()]); } }
BilouCodec implements SequenceCodec<String> { @Override 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(BilouCodec.START)) { start = li; end = li + 1; } else if (chunkTag.endsWith(BilouCodec.CONTINUE)) { end = li + 1; } else if (chunkTag.endsWith(LAST)) { if (start != -1) { spans.add(new Span(start, end + 1, BioCodec.extractNameType(c.get(li - 1)))); start = -1; end = -1; } } else if (chunkTag.endsWith(UNIT)) { spans.add(new Span(li, li + 1, BioCodec.extractNameType(c.get(li)))); } } return spans.toArray(new Span[spans.size()]); }  }
BilouCodec implements SequenceCodec<String> { @Override 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(BilouCodec.START)) { start = li; end = li + 1; } else if (chunkTag.endsWith(BilouCodec.CONTINUE)) { end = li + 1; } else if (chunkTag.endsWith(LAST)) { if (start != -1) { spans.add(new Span(start, end + 1, BioCodec.extractNameType(c.get(li - 1)))); start = -1; end = -1; } } else if (chunkTag.endsWith(UNIT)) { spans.add(new Span(li, li + 1, BioCodec.extractNameType(c.get(li)))); } } return spans.toArray(new Span[spans.size()]); }  @Override Span[] decode(List<String> c); @Override String[] encode(Span[] names, int length); @Override SequenceValidator<String> createSequenceValidator(); @Override boolean areOutcomesCompatible(String[] outcomes); }
BilouCodec implements SequenceCodec<String> { @Override 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(BilouCodec.START)) { start = li; end = li + 1; } else if (chunkTag.endsWith(BilouCodec.CONTINUE)) { end = li + 1; } else if (chunkTag.endsWith(LAST)) { if (start != -1) { spans.add(new Span(start, end + 1, BioCodec.extractNameType(c.get(li - 1)))); start = -1; end = -1; } } else if (chunkTag.endsWith(UNIT)) { spans.add(new Span(li, li + 1, BioCodec.extractNameType(c.get(li)))); } } return spans.toArray(new Span[spans.size()]); }  @Override Span[] decode(List<String> c); @Override String[] encode(Span[] names, int length); @Override SequenceValidator<String> createSequenceValidator(); @Override boolean areOutcomesCompatible(String[] outcomes); static final String START; static final String CONTINUE; static final String LAST; static final String UNIT; static final String OTHER; }