AnnotatedText implements Serializable { @SuppressWarnings("unchecked") public ListAttribute<TranslatedData> getTranslatedData() { return (ListAttribute<TranslatedData>) attributes.get(AttributeKey.TRANSLATED_DATA.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 testTranslatedData() { String rawText = "One. Two."; String germanText = "Ein. Zwei."; String spanishText = "Uno. Dos."; AnnotatedText.Builder builder = new AnnotatedText.Builder().data(rawText); ListAttribute.Builder<TranslatedData> translatedDataBuilder = new ListAttribute.Builder<>(TranslatedData.class); TextDomain domain = new TextDomain(ISO15924.Latn, LanguageCode.GERMAN, TransliterationScheme.NATIVE); TranslatedData.Builder tdBuilder = new TranslatedData.Builder(domain, germanText); translatedDataBuilder.add(tdBuilder.build()); domain = new TextDomain(ISO15924.Latn, LanguageCode.SPANISH, TransliterationScheme.NATIVE); tdBuilder = new TranslatedData.Builder(domain, spanishText); translatedDataBuilder.add(tdBuilder.build()); builder.translatedData(translatedDataBuilder.build()); AnnotatedText text = builder.build(); ListAttribute<TranslatedData> dataTranslations = text.getTranslatedData(); TranslatedData data = dataTranslations.get(0); TextDomain dataDomain = data.getDomain(); ISO15924 script = dataDomain.getScript(); LanguageCode language = dataDomain.getLanguage(); TransliterationScheme scheme = dataDomain.getTransliterationScheme(); String translation = data.getTranslation(); assertEquals(script, ISO15924.Latn); assertEquals(language, LanguageCode.GERMAN); assertEquals(scheme, TransliterationScheme.NATIVE); assertEquals(translation, germanText); data = dataTranslations.get(1); dataDomain = data.getDomain(); script = dataDomain.getScript(); language = dataDomain.getLanguage(); scheme = dataDomain.getTransliterationScheme(); translation = data.getTranslation(); assertEquals(script, ISO15924.Latn); assertEquals(language, LanguageCode.SPANISH); assertEquals(scheme, TransliterationScheme.NATIVE); assertEquals(translation, spanishText); }