import java.net.MalformedURLException;
import java.net.URL;
import java.time.Instant;
+import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
}
entities = new ArrayList<>();
- if (desc != null && lang.equals("en"))
+ if (lang.equals("en"))
try {
NER.classify(title, entities, config);
- NER.classify(desc, entities, config);
+ if (desc != null)
+ NER.classify(desc, entities, config);
} catch (ClassCastException | ClassNotFoundException | IOException e1) {
LOG.log(Level.SEVERE, "Cannot classify " + feedTitle, e1);
}
final String FUNCTION_NAME = "getEntities";
EntityStat s;
List<EntityStat> stats;
+ Instant minInstant;
LOG.entering(CLASS_NAME, FUNCTION_NAME, cat);
articles = getArticles(cat, null);
+ minInstant = Instant.now().minus(15, ChronoUnit.DAYS);
+
entities = new HashMap<>();
- for (Article a: articles)
- if (a.getEntities() != null) {
+ for (Article a: articles)
+ if (a.getPublicationDate().isAfter(minInstant) && a.getEntities() != null)
for (String e: a.getEntities()) {
s = entities.get(e);
if (s == null) {
}
s.increment();
}
- }
-
+
stats = new ArrayList<>(entities.values());
stats.sort(new Comparator<EntityStat>() {