@GET @Path("/getWordCloud/json/{fields}/{sources}/{keyword}") @Produces(MediaType.APPLICATION_JSON) public String getWordCloud( @PathParam("keyword") String keyword, @PathParam("fields") String fields, @PathParam("sources") String sources) { SolrDBManager db = new SolrDBManager(); JSONArray tfjson = null; ArrayList<String> searchField = formSearchField(fields); ArrayList<String> S = new ArrayList<String>(); if (sources.contains("video")) S.add("Video"); if (sources.contains("news")) S.add("NewsArticle"); try { int maxNumOfWordsToDisplay = Integer.parseInt(db.conf.getProperty("visualization_MaxWordCloudSize")); int maxNumOfEvents = Integer.parseInt(db.conf.getProperty("visualization_MaxDocForClouds")); StoryDistribution distr = db.getDistribution(keyword, S, searchField, maxNumOfEvents); tfjson = distr.getTermFrequencies(maxNumOfWordsToDisplay); System.out.println("Finish generating wordcloud"); } catch (Exception e) { e.printStackTrace(); } finally { } return tfjson.toString(); }
@GET @Path("/getNews/json/{fields}/{sources}/{keyword}") @Produces(MediaType.APPLICATION_JSON) public List<Event> getNews( @PathParam("keyword") String keyword, @PathParam("fields") String fields, @PathParam("sources") String sources) { SolrDBManager db = new SolrDBManager(); List<Event> events = new ArrayList<Event>(); ArrayList<String> searchField = formSearchField(fields); // search field // Debug ArrayList<String> S = new ArrayList<String>(); if (sources.contains("video")) S.add("Video"); if (sources.contains("news")) S.add("NewsArticle"); try { int maxNumOfEventsToDisplay = Integer.parseInt(db.conf.getProperty("visualization_MaxTimelineSize")); events = db.searchByKeyword(keyword, S, searchField, maxNumOfEventsToDisplay); } catch (Exception e) { e.printStackTrace(); } return events; }