private static final String CLASS_NAME = ArticleProvider.class.getName();
private static final Logger LOG = Logger.getLogger(CLASS_NAME);
private final Map<Category, List<Article>> articlesByCategory = new HashMap<>();
- private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(2);
+ private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors());
private final Config config;
public ArticleProvider(Config config) {
private static Article toArticle(String link, SyndEntry entry, SyndFeed feed, String lang) {
String desc, title, thumbnail, feedTitle, str;
Date date;
- String[] entities;
+ List<String> entities;
feedTitle = feed.getTitle();
if (feedTitle != null) {
LOG.severe("The article " + feedTitle + " - " + title + " does not have a date");
- entities = null;
+ entities = new ArrayList<>();
if (desc != null && lang.equals("en"))
try {
- entities = NER.classify(desc);
+ NER.classify(title, entities);
+ NER.classify(desc, entities);
} catch (ClassCastException | ClassNotFoundException | IOException e1) {
LOG.log(Level.SEVERE, "Cannot classify " + feedTitle, e1);
}
- return new Article(link, title, desc, thumbnail, date, feedTitle, entities);
+ return new Article(link, title, desc, thumbnail, date, feedTitle, entities.toArray(new String[0]));
}
private void addArticles(Category cat, SyndFeed feed) {
entities = new HashMap<>();
for (Article a: articles)
- if (a.getEntities() != null)
+ if (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>() {