AnnotatedText implements Serializable { @SuppressWarnings("unchecked") public ListAttribute<CategorizerResult> getTopicResults() { return (ListAttribute<CategorizerResult>) attributes.get(AttributeKey.TOPIC_RESULTS.key()); } 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 testTopicResults() { AnnotatedText.Builder builder = new AnnotatedText.Builder(); ListAttribute.Builder<CategorizerResult> listBuilder = new ListAttribute.Builder<>(CategorizerResult.class); listBuilder.add(new CategorizerResult.Builder("sports", 0.2) .confidence(0.2).build()); listBuilder.add(new CategorizerResult.Builder("basketball", 0.1) .confidence(0.1).build()); builder.topicResults(listBuilder.build()); AnnotatedText text = builder.build(); CategorizerResult r1 = text.getTopicResults().get(0); assertEquals("sports", r1.getLabel()); assertEquals(0.2, r1.getScore(), 0.000000001); assertEquals(0.2, r1.getConfidence(), 0.000000001); assertNull(r1.getExplanationSet()); assertNull(r1.getPerFeatureScores()); CategorizerResult r2 = text.getTopicResults().get(1); assertEquals("basketball", r2.getLabel()); assertEquals(0.1, r2.getScore(), 0.000000001); assertEquals(0.1, r2.getConfidence(), 0.000000001); assertNull(r2.getExplanationSet()); assertNull(r2.getPerFeatureScores()); }