@@ -98,31 +98,27 @@ public Map<String, List<String>> extractEntities(String text, String entityTypes
98
98
}
99
99
100
100
CoreDocument document = annotateDocument (text );
101
- try {
102
- List <CoreEntityMention > mentions = document .entityMentions ();
103
- if (document .entityMentions () == null ) {
104
- mentions = new ArrayList <CoreEntityMention >();
105
- }
106
101
107
- for (CoreEntityMention entityMention : mentions ) {
108
- String eType = entityMention .entityType ();
109
- if (extractLocations && locationNerTagList .contains (eType )) {
110
- List <String > locs = output .get ("location" );
111
- locs .add (entityMention .text ());
112
- output .put ("location" , locs );
113
- continue ;
114
- }
115
- if (nerTagList .contains (eType )) {
116
- List <String > e = output .get (eType .toLowerCase ());
117
- e .add (entityMention .text ());
118
- output .put (eType .toLowerCase (), e );
119
- }
120
- }
102
+ List <CoreEntityMention > mentions = document .entityMentions ();
103
+ if (document .entityMentions () == null ) {
104
+ mentions = new ArrayList <CoreEntityMention >();
105
+ }
121
106
122
- return output ;
123
- } catch (Exception e ) {
124
- System .out .println ("Exception while finding mentions: " + e );
107
+ for (CoreEntityMention entityMention : mentions ) {
108
+ String eType = entityMention .entityType ();
109
+ if (extractLocations && locationNerTagList .contains (eType )) {
110
+ List <String > locs = output .get ("location" );
111
+ locs .add (entityMention .text ());
112
+ output .put ("location" , locs );
113
+ continue ;
114
+ }
115
+ if (nerTagList .contains (eType )) {
116
+ List <String > e = output .get (eType .toLowerCase ());
117
+ e .add (entityMention .text ());
118
+ output .put (eType .toLowerCase (), e );
119
+ }
125
120
}
121
+
126
122
return output ;
127
123
}
128
124
0 commit comments