BratAnnotationContainer { static Object[] parseRoleIndex(String str) { Matcher m = digitsPattern.matcher(str); if (m.find()) { String roleName = str.substring(0, m.start()); String indexStr = m.group(); Integer index = Integer.valueOf(indexStr); return new Object[]{roleName, index}; } else { return null; } } BratAnnotationContainer(BratTypesConfiguration typesCfg); @SuppressWarnings("unchecked") Collection<A> getAnnotations(T type); Collection<BratEntity> getEntities(BratEntityType type); Collection<BratRelation> getRelations(BratRelationType type); Collection<BratEvent> getEvents(BratEventType type); BratAnnotation<?> getAnnotation(String id); BratAnnotation<?> getAnnotation(String id, boolean mustExist); Collection<BratNoteAnnotation> getNotes(BratAnnotation<?> targetAnno); B register(B anno); void writeTo(Writer writer); void readFrom(Reader srcReader); static final String ENTITY_ID_PREFIX; static final String RELATION_ID_PREFIX; static final String EVENT_ID_PREFIX; static final String NOTE_ID_PREFIX; static final String ATTRIBUTE_ID_PREFIX; static final String NORMALIZATION_ID_PREFIX; static final String EQUIV_RELATION_PREFIX; }
@Test public void testIndexedRoleParsing() { assertArrayEquals(null, BratAnnotationContainer.parseRoleIndex("someRole")); assertArrayEquals(new Object[]{"someRole", 2}, BratAnnotationContainer.parseRoleIndex("someRole2")); assertArrayEquals(new Object[]{"someRole", 30}, BratAnnotationContainer.parseRoleIndex("someRole030")); }