AnnotatedText implements Serializable { @SuppressWarnings("unchecked") @Deprecated public ListAttribute<ResolvedEntity> getResolvedEntities() { if (!compatResolvedEntitiesProcessed) { compatResolvedEntitiesProcessed = true; ListAttribute.Builder<ResolvedEntity> reListBuilder = new ListAttribute.Builder<>(ResolvedEntity.class); ListAttribute<Entity> entities = getEntities(); if (entities == null) { return null; } if (entities.getExtendedProperties() != null) { for (Map.Entry<String, Object> me : entities.getExtendedProperties().entrySet()) { String key = me.getKey(); if (!key.startsWith("mention.")) { reListBuilder.extendedProperty(key, me.getValue()); } } } for (Entity entity : entities) { if (entity.getHeadMentionIndex() == null) { continue; } int headStart = 0; int headEnd = 0; if (entity.getHeadMentionIndex() != null) { Mention head = entity.getMentions().get(entity.getHeadMentionIndex()); headStart = head.getStartOffset(); headEnd = head.getEndOffset(); } ResolvedEntity.Builder reBuilder = new ResolvedEntity.Builder(headStart, headEnd, entity.getEntityId()); if (entity.getConfidence() != null) { reBuilder.confidence(entity.getConfidence()); } if (entity.getSentiment() != null && !entity.getSentiment().isEmpty()) { reBuilder.sentiment(entity.getSentiment().get(0)); } if (entity.getExtendedProperties() != null) { for (Map.Entry<String, Object> me : entity.getExtendedProperties().entrySet()) { if (me.getKey().equals("oldCoreferenceChainId")) { reBuilder.coreferenceChainId((Integer)me.getValue()); } else { reBuilder.extendedProperty(me.getKey(), me.getValue()); } } } reListBuilder.add(reBuilder.build()); } compatResolvedEntities = reListBuilder.build(); if (compatResolvedEntities.size() == 0) { compatResolvedEntities = null; } } return compatResolvedEntities; } AnnotatedText(CharSequence data,
                  Map<String, BaseAttribute> attributes,
                  Map<String, List<String>> documentMetadata,
                  /*
                   * This version is only here as a workaround for https://github.com/FasterXML/jackson-databind/issues/1118
                   * It would be better if it was only mentioned in the mixins. No data arrives here, it just
                   * allows the mixin to be matched with the existence of a version item in the json.
                   */
                  String version); CharSequence getData(); Map<String, List<String>> getDocumentMetadata(); Map<String, BaseAttribute> getAttributes(); @SuppressWarnings("unchecked") ListAttribute<Token> getTokens(); @SuppressWarnings("unchecked") ListAttribute<TranslatedTokens> getTranslatedTokens(); @SuppressWarnings("unchecked") ListAttribute<TranslatedData> getTranslatedData(); @SuppressWarnings("unchecked") ListAttribute<LanguageDetection> getLanguageDetectionRegions(); LanguageDetection getWholeTextLanguageDetection(); @SuppressWarnings("unchecked") @Deprecated ListAttribute<EntityMention> getEntityMentions(); @SuppressWarnings("unchecked") ListAttribute<Entity> getEntities(); @SuppressWarnings("unchecked") MapAttribute<LanguageCode, ListAttribute<SimilarTerm>> getSimilarTerms(); @SuppressWarnings("unchecked") ListAttribute<SimilarTerm> getSimilarTerms(LanguageCode languageCode); @SuppressWarnings("unchecked") ListAttribute<RelationshipMention> getRelationshipMentions(); @SuppressWarnings("unchecked") @Deprecated ListAttribute<ResolvedEntity> getResolvedEntities(); @SuppressWarnings("unchecked") ListAttribute<ScriptRegion> getScriptRegions(); @SuppressWarnings("unchecked") ListAttribute<Sentence> getSentences(); @SuppressWarnings("unchecked") ListAttribute<LayoutRegion> getLayoutRegions(); @SuppressWarnings("unchecked") ListAttribute<BaseNounPhrase> getBaseNounPhrases(); @SuppressWarnings("unchecked") ListAttribute<CategorizerResult> getCategorizerResults(); @SuppressWarnings("unchecked") ListAttribute<CategorizerResult> getSentimentResults(); @SuppressWarnings("unchecked") ListAttribute<Dependency> getDependencies(); @SuppressWarnings("unchecked") ListAttribute<CategorizerResult> getTopicResults(); Embeddings getEmbeddings(); @SuppressWarnings("unchecked") ListAttribute<Concept> getConcepts(); @SuppressWarnings("unchecked") ListAttribute<Keyphrase> getKeyphrases(); TransliterationResults getTransliteration(); @Override String toString();  }
@Test public void testResolvedEntities() { String rawText = "from Boston and Chicago"; AnnotatedText.Builder builder = new AnnotatedText.Builder().data(rawText); ListAttribute.Builder<ResolvedEntity> reListBuilder = new ListAttribute.Builder<>(ResolvedEntity.class); ResolvedEntity.Builder re1Builder = new ResolvedEntity.Builder(5, 11, "Q100"); re1Builder.coreferenceChainId(0); reListBuilder.add(re1Builder.build()); ResolvedEntity.Builder re2Builder = new ResolvedEntity.Builder(16, 23, "Q1297"); re2Builder.coreferenceChainId(1); reListBuilder.add(re2Builder.build()); builder.resolvedEntities(reListBuilder.build()); ListAttribute.Builder<EntityMention> mentionList = new ListAttribute.Builder<>(EntityMention.class); EntityMention.Builder emBuilder = new EntityMention.Builder(5, 11, "LOCATION"); emBuilder.coreferenceChainId(0); mentionList.add(emBuilder.build()); emBuilder = new EntityMention.Builder(16, 23, "LOCATION"); emBuilder.coreferenceChainId(1); mentionList.add(emBuilder.build()); builder.entityMentions(mentionList.build()); AnnotatedText text = builder.build(); ResolvedEntity resolvedEntity; assertEquals(2, text.getResolvedEntities().size()); resolvedEntity = text.getResolvedEntities().get(0); assertEquals(5, resolvedEntity.getStartOffset()); assertEquals(11, resolvedEntity.getEndOffset()); resolvedEntity = text.getResolvedEntities().get(1); assertEquals(16, resolvedEntity.getStartOffset()); assertEquals(23, resolvedEntity.getEndOffset()); }