2 * EnityLinkManager.java
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
;
13 import org
.spirit
.bean
.impl
.BotListEntityLinks
;
14 import org
.spirit
.dao
.BotListEntityLinksDAO
;
15 import org
.spirit
.util
.BotListGenericUtils
;
20 public class EntityLinkManager
{
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
);
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(" ");
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
54 return BotListGenericUtils
.mapReduce(allterms
, 8);