@@ -60,69 +60,9 @@ public class ThsEntryEntity extends UserFriendlyEntity implements Recursable {
6060 @ Field (type = FieldType .Search_As_You_Type , name = "hash" )
6161 private String SUID ;
6262
63- @ Field (type = FieldType .Object )
64- private Translations translations ;
65-
6663 @ Field (type = FieldType .Object )
6764 private ObjectPath [] paths ;
6865
69- /**
70- * Returns translations of a thesaurus entry's label. If no explicit translations exist, this method
71- * attempts to extract translations from the <code>synonym_group</code> field of the passport.
72- */
73- public Translations getTranslations () {
74- if (this .translations != null ) {
75- return this .translations ;
76- } else {
77- return this .extractTranslationsFromPassport ();
78- }
79- }
80-
81- /**
82- * Convert multilingual synonyms extracted from passport to {@link Translations} object.
83- *
84- * @return {@link Translations} instance or <code>null</code> if no synonyms are in passport
85- */
86- private Translations extractTranslationsFromPassport () {
87- Translations res = null ;
88- if (this .getPassport () != null ) {
89- List <Passport > nodes = this .getPassport ().extractProperty (
90- SYNONYMS_PASSPORT_PATH
91- );
92- Map <String , List <String >> synonyms = new HashMap <>();
93- nodes .stream ().filter (
94- n -> n .containsKey (SYNONYM_LANG_PATH ) && n .containsKey (SYNONYM_VALUE_PATH )
95- ).forEach (
96- n -> {
97- List <String > translations = n .extractProperty (SYNONYM_VALUE_PATH ).stream ().map (
98- leafNode -> leafNode .getLeafNodeValue ()
99- ).collect (
100- Collectors .toList ()
101- );
102- n .extractProperty (SYNONYM_LANG_PATH ).forEach (
103- langValueNode -> {
104- String lang = langValueNode .getLeafNodeValue ();
105- if (synonyms .containsKey (lang )) {
106- synonyms .get (lang ).addAll (translations );
107- } else {
108- synonyms .put (lang , new ArrayList <String >(translations ));
109- }
110- }
111- );
112- }
113- );
114- try {
115- res = objectMapper .readValue (
116- objectMapper .writeValueAsString (synonyms ),
117- Translations .class
118- );
119- } catch (Exception e ) {
120- log .error ("something went wrong during synonum extraction" , e );
121- }
122- }
123- return res ;
124- }
125-
12666 /**
12767 * Returns the timespan represented by a thesaurus entry in the form of a list
12868 * of size 2 containing first and last year.
0 commit comments