@Test final void resolveTypeOverlappingHappyDrawPerson() throws MappingNotExistsException, TypeNotExistsException { final TypeOverlappingConfig config = new TypeOverlappingConfig(); config.setTo("CoNLL"); config.setPriority(Arrays.asList("ann1", "ann3")); final List<Entity> entities = new ArrayList<>(); final Entity entity = Entity.builder().type("PERfromCoNLL--ann1||dbo_PlacefromDBpedia--ann3").build(); entities.add(entity); final Document document = Document.builder().entities(entities).build(); final TypeOverlapResolutionRepository voting = new MajorityVotingTypeOverlapResolution(); voting.resolveTypeOverlapping(config, document.getEntities()); Assertions.assertEquals("PER", document.getEntities().get(0).getType(), "Must be equals"); }
@Override public final void resolveTypeOverlapping(final TypeOverlappingConfig config, final List<Entity> entities) throws MappingNotExistsException, TypeNotExistsException { for (final Entity entity : entities) { StringBuilder newType = new StringBuilder(); for (final String singleType : entity.getType().split("\\|\\|")) { final String[] splittedType = singleType.split("from"); if (newType.toString().isEmpty()) { newType = new StringBuilder(this.resolveTypeMapping(splittedType[1].split("--")[0], config.getTo(), splittedType[0])); } else { newType.append("||"); newType.append(this.resolveTypeMapping(splittedType[1].split("--")[0], config.getTo(), splittedType[0])); } newType.append("--"); newType.append(config.getPriority().indexOf(splittedType[1].split("--")[1])); } entity.setType(newType.toString()); } this.majorityVote(entities); }
MajorityVotingTypeOverlapResolution implements TypeOverlapResolutionRepository { @Override public final void resolveTypeOverlapping(final TypeOverlappingConfig config, final List<Entity> entities) throws MappingNotExistsException, TypeNotExistsException { for (final Entity entity : entities) { StringBuilder newType = new StringBuilder(); for (final String singleType : entity.getType().split("\\|\\|")) { final String[] splittedType = singleType.split("from"); if (newType.toString().isEmpty()) { newType = new StringBuilder(this.resolveTypeMapping(splittedType[1].split("--")[0], config.getTo(), splittedType[0])); } else { newType.append("||"); newType.append(this.resolveTypeMapping(splittedType[1].split("--")[0], config.getTo(), splittedType[0])); } newType.append("--"); newType.append(config.getPriority().indexOf(splittedType[1].split("--")[1])); } entity.setType(newType.toString()); } this.majorityVote(entities); } }
MajorityVotingTypeOverlapResolution implements TypeOverlapResolutionRepository { @Override public final void resolveTypeOverlapping(final TypeOverlappingConfig config, final List<Entity> entities) throws MappingNotExistsException, TypeNotExistsException { for (final Entity entity : entities) { StringBuilder newType = new StringBuilder(); for (final String singleType : entity.getType().split("\\|\\|")) { final String[] splittedType = singleType.split("from"); if (newType.toString().isEmpty()) { newType = new StringBuilder(this.resolveTypeMapping(splittedType[1].split("--")[0], config.getTo(), splittedType[0])); } else { newType.append("||"); newType.append(this.resolveTypeMapping(splittedType[1].split("--")[0], config.getTo(), splittedType[0])); } newType.append("--"); newType.append(config.getPriority().indexOf(splittedType[1].split("--")[1])); } entity.setType(newType.toString()); } this.majorityVote(entities); } MajorityVotingTypeOverlapResolution(); }
MajorityVotingTypeOverlapResolution implements TypeOverlapResolutionRepository { @Override public final void resolveTypeOverlapping(final TypeOverlappingConfig config, final List<Entity> entities) throws MappingNotExistsException, TypeNotExistsException { for (final Entity entity : entities) { StringBuilder newType = new StringBuilder(); for (final String singleType : entity.getType().split("\\|\\|")) { final String[] splittedType = singleType.split("from"); if (newType.toString().isEmpty()) { newType = new StringBuilder(this.resolveTypeMapping(splittedType[1].split("--")[0], config.getTo(), splittedType[0])); } else { newType.append("||"); newType.append(this.resolveTypeMapping(splittedType[1].split("--")[0], config.getTo(), splittedType[0])); } newType.append("--"); newType.append(config.getPriority().indexOf(splittedType[1].split("--")[1])); } entity.setType(newType.toString()); } this.majorityVote(entities); } MajorityVotingTypeOverlapResolution(); @Override final void resolveTypeOverlapping(final TypeOverlappingConfig config, final List<Entity> entities); }
MajorityVotingTypeOverlapResolution implements TypeOverlapResolutionRepository { @Override public final void resolveTypeOverlapping(final TypeOverlappingConfig config, final List<Entity> entities) throws MappingNotExistsException, TypeNotExistsException { for (final Entity entity : entities) { StringBuilder newType = new StringBuilder(); for (final String singleType : entity.getType().split("\\|\\|")) { final String[] splittedType = singleType.split("from"); if (newType.toString().isEmpty()) { newType = new StringBuilder(this.resolveTypeMapping(splittedType[1].split("--")[0], config.getTo(), splittedType[0])); } else { newType.append("||"); newType.append(this.resolveTypeMapping(splittedType[1].split("--")[0], config.getTo(), splittedType[0])); } newType.append("--"); newType.append(config.getPriority().indexOf(splittedType[1].split("--")[1])); } entity.setType(newType.toString()); } this.majorityVote(entities); } MajorityVotingTypeOverlapResolution(); @Override final void resolveTypeOverlapping(final TypeOverlappingConfig config, final List<Entity> entities);  }