@@ -98,31 +98,27 @@ public Map<String, List<String>> extractEntities(String text, String entityTypes
9898 }
9999
100100 CoreDocument document = annotateDocument (text );
101- try {
102- List <CoreEntityMention > mentions = document .entityMentions ();
103- if (document .entityMentions () == null ) {
104- mentions = new ArrayList <CoreEntityMention >();
105- }
106101
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+ }
121106
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+ }
125120 }
121+
126122 return output ;
127123 }
128124
0 commit comments