1
1
/* Licensed under MIT 2021-2024. */
2
2
package edu .kit .kastel .mcse .ardoco .core .api .stage .textextraction ;
3
3
4
- import java .util .Optional ;
5
-
6
4
import org .eclipse .collections .api .factory .Lists ;
7
- import org .eclipse .collections .api .factory .SortedSets ;
8
5
import org .eclipse .collections .api .list .ImmutableList ;
9
6
import org .eclipse .collections .api .list .MutableList ;
10
7
import org .eclipse .collections .api .map .sorted .ImmutableSortedMap ;
15
12
import edu .kit .kastel .mcse .ardoco .core .api .text .Phrase ;
16
13
import edu .kit .kastel .mcse .ardoco .core .api .text .Word ;
17
14
import edu .kit .kastel .mcse .ardoco .core .common .tuple .Pair ;
18
- import edu .kit .kastel .mcse .ardoco .core .common .util .AbbreviationDisambiguationHelper ;
19
15
import edu .kit .kastel .mcse .ardoco .core .configuration .IConfigurable ;
20
16
import edu .kit .kastel .mcse .ardoco .core .data .Confidence ;
21
17
import edu .kit .kastel .mcse .ardoco .core .data .PipelineStepData ;
@@ -42,7 +38,7 @@ public interface TextState extends IConfigurable, PipelineStepData {
42
38
* @param probability probability to be a name mapping
43
39
*/
44
40
default NounMapping addNounMapping (Word word , MappingKind kind , Claimant claimant , double probability ) {
45
- return getTextStateStrategy ().addOrExtendNounMapping (word , kind , claimant , probability , Lists .immutable .with (word .getText ()));
41
+ return this . getTextStateStrategy ().addOrExtendNounMapping (word , kind , claimant , probability , Lists .immutable .with (word .getText ()));
46
42
}
47
43
48
44
/**
@@ -56,7 +52,7 @@ default NounMapping addNounMapping(Word word, MappingKind kind, Claimant claiman
56
52
* @param surfaceForms list of the appearances of the mapping
57
53
*/
58
54
default NounMapping addNounMapping (Word word , MappingKind kind , Claimant claimant , double probability , ImmutableList <String > surfaceForms ) {
59
- return getTextStateStrategy ().addOrExtendNounMapping (word , kind , claimant , probability , surfaceForms );
55
+ return this . getTextStateStrategy ().addOrExtendNounMapping (word , kind , claimant , probability , surfaceForms );
60
56
}
61
57
62
58
/**
@@ -74,7 +70,7 @@ default NounMapping addNounMapping(Word word, MappingKind kind, Claimant claiman
74
70
*/
75
71
default NounMapping addNounMapping (ImmutableSortedSet <Word > words , MappingKind kind , Claimant claimant , double probability ,
76
72
ImmutableList <Word > referenceWords , ImmutableList <String > surfaceForms , String reference ) {
77
- return getTextStateStrategy ().addNounMapping (words , kind , claimant , probability , referenceWords , surfaceForms , reference );
73
+ return this . getTextStateStrategy ().addNounMapping (words , kind , claimant , probability , referenceWords , surfaceForms , reference );
78
74
}
79
75
80
76
/**
@@ -90,7 +86,7 @@ default NounMapping addNounMapping(ImmutableSortedSet<Word> words, MappingKind k
90
86
*/
91
87
default NounMapping addNounMapping (ImmutableSortedSet <Word > words , ImmutableSortedMap <MappingKind , Confidence > distribution ,
92
88
ImmutableList <Word > referenceWords , ImmutableList <String > surfaceForms , String reference ) {
93
- return getTextStateStrategy ().addNounMapping (words , distribution , referenceWords , surfaceForms , reference );
89
+ return this . getTextStateStrategy ().addNounMapping (words , distribution , referenceWords , surfaceForms , reference );
94
90
}
95
91
96
92
/**
@@ -137,7 +133,7 @@ default NounMapping addNounMapping(ImmutableSortedSet<Word> words, ImmutableSort
137
133
* @param phrase the phrase
138
134
*/
139
135
default ImmutableList <PhraseMapping > getPhraseMappings (Phrase phrase ) {
140
- return Lists .immutable .fromStream (getPhraseMappings ().stream ().filter (pm -> pm .getPhrases ().contains (phrase )));
136
+ return Lists .immutable .fromStream (this . getPhraseMappings ().stream ().filter (pm -> pm .getPhrases ().contains (phrase )));
141
137
}
142
138
143
139
ImmutableList <NounMapping > getNounMappingsOfKind (MappingKind mappingKind );
@@ -166,78 +162,4 @@ void mergePhraseMappingsAndNounMappings(PhraseMapping phraseMapping, PhraseMappi
166
162
boolean isWordContainedByMappingKind (Word word , MappingKind kind );
167
163
168
164
ImmutableList <NounMapping > getNounMappingsWithSimilarReference (String reference );
169
-
170
- /**
171
- * Adds a {@link WordAbbreviation} for the abbreviation with the specified word meaning to the state using the state's {@link TextStateStrategy}.
172
- *
173
- * @param abbreviation the abbreviation
174
- * @param word the meaning
175
- * @return the resulting word abbreviation in the state
176
- */
177
- default WordAbbreviation addWordAbbreviation (String abbreviation , Word word ) {
178
- logger .debug ("Added word abbreviation for {} with meaning {}" , abbreviation , word .getText ());
179
- var wordAbbreviation = getTextStateStrategy ().addOrExtendWordAbbreviation (abbreviation , word );
180
- AbbreviationDisambiguationHelper .addTransient (wordAbbreviation );
181
- return wordAbbreviation ;
182
- }
183
-
184
- /**
185
- * Adds a {@link PhraseAbbreviation} for the abbreviation with the specified phrase meaning to the state using the state's {@link TextStateStrategy}.
186
- *
187
- * @param abbreviation the abbrevation
188
- * @param phrase the meaning
189
- * @return the resulting phrase abbreviation in the state
190
- */
191
- default PhraseAbbreviation addPhraseAbbreviation (String abbreviation , Phrase phrase ) {
192
- logger .debug ("Added phrase abbreviation for {} with meaning {}" , abbreviation , phrase .getText ());
193
- var phraseAbbreviation = getTextStateStrategy ().addOrExtendPhraseAbbreviation (abbreviation , phrase );
194
- AbbreviationDisambiguationHelper .addTransient (phraseAbbreviation );
195
- return phraseAbbreviation ;
196
- }
197
-
198
- /**
199
- * {@return all word abbreviations from the state}
200
- */
201
- ImmutableSortedSet <WordAbbreviation > getWordAbbreviations ();
202
-
203
- /**
204
- * {@return all word abbreviations from the state that have the specified meaning}
205
- *
206
- * @param word the meaning to search for
207
- */
208
- default ImmutableSortedSet <WordAbbreviation > getWordAbbreviations (Word word ) {
209
- return SortedSets .immutable .ofAll (getWordAbbreviations ().stream ().filter (w -> w .getWords ().contains (word )).toList ());
210
- }
211
-
212
- /**
213
- * {@return the optional word abbreviation from the state that has the specified abbreviation}
214
- *
215
- * @param abbreviation the abbreviation
216
- */
217
- default Optional <WordAbbreviation > getWordAbbreviation (String abbreviation ) {
218
- return getWordAbbreviations ().stream ().filter (w -> w .getAbbreviation ().equals (abbreviation )).findFirst ();
219
- }
220
-
221
- /**
222
- * {@return all phrase abbreviations from the state}
223
- */
224
- ImmutableSortedSet <PhraseAbbreviation > getPhraseAbbreviations ();
225
-
226
- /**
227
- * {@return all phrase abbreviations from the state that have the specified meaning}
228
- *
229
- * @param phrase the meaning to search for
230
- */
231
- default ImmutableSortedSet <PhraseAbbreviation > getPhraseAbbreviations (Phrase phrase ) {
232
- return SortedSets .immutable .ofAll (getPhraseAbbreviations ().stream ().filter (p -> p .getPhrases ().contains (phrase )).toList ());
233
- }
234
-
235
- /**
236
- * {@return the optional phrase abbreviation from the state that has the specified abbreviation}
237
- *
238
- * @param abbreviation the abbreviation
239
- */
240
- default Optional <PhraseAbbreviation > getPhraseAbbreviation (String abbreviation ) {
241
- return getPhraseAbbreviations ().stream ().filter (p -> p .getAbbreviation ().equals (abbreviation )).findFirst ();
242
- }
243
165
}
0 commit comments