adding all of botlist, initial add
[botlist.git] / openbotlist / src / org / spirit / business / EntityLinkManager.java
blobfeb1c74779651ea349ac92344194e48528963f84
1 /*
2 * EnityLinkManager.java
3 * Nov 16, 2007
4 */
5 package org.spirit.business;
7 import java.util.ArrayList;
8 import java.util.Calendar;
9 import java.util.Iterator;
10 import java.util.List;
11 import java.util.Set;
13 import org.spirit.bean.impl.BotListEntityLinks;
14 import org.spirit.dao.BotListEntityLinksDAO;
15 import org.spirit.util.BotListGenericUtils;
17 /**
18 * @author bbrown
20 public class EntityLinkManager {
22 /**
23 * Return all links found in the last 24 hours.
25 public static List readLinksForDay(final BotListEntityLinksDAO dao) {
26 // Return current time.
27 Calendar curCal = Calendar.getInstance();
28 curCal.add(Calendar.DATE, -2);
29 return dao.readListingUpToCurrentDate(curCal);
32 /**
33 * Map and Reduce all entity link keywords.
35 public static Set mapReduceLinkKeywords(final BotListEntityLinksDAO dao) {
36 List allterms = new ArrayList();
37 List list = readLinksForDay(dao);
38 for (Iterator it = list.iterator(); it.hasNext();) {
39 BotListEntityLinks link = (BotListEntityLinks) it.next();
40 final String keywords = link.getKeywords();
41 if (keywords != null) {
42 final String[] words = keywords.split(" ");
43 if (words != null) {
44 for (int i = 0; i < words.length; i++) {
45 // Also check for stop words
46 if ((BotListGenericUtils.STOP_WORDS_MAP.get(words[i]) == null)
47 && (words[i].length() > 1)) {
48 allterms.add(words[i]);
49 } // End of if - stop word check
51 } // End of if - words null
52 } // End of if
53 } // End of For
54 return BotListGenericUtils.mapReduce(allterms, 8);