@@ -79,7 +79,7 @@ public BLLCalculator(BookmarkReader reader, int trainSize, double dVal, int beta
7979 this .userDenoms = new ArrayList <Double >();
8080 this .userTimestamps = new ArrayList <Long >();
8181 //if (this.userBased) {
82- this .userMaps = getArtifactMaps (reader , this .trainList , testList , false , this .userTimestamps , this .userDenoms , this .dVal , true , lambda );
82+ this .userMaps = getArtifactMaps (reader , this .trainList , testList , false , this .userTimestamps , this .userDenoms , this .dVal , true , lambda , true );
8383 this .userCounts = Utilities .getRelativeTagMaps (this .trainList , false );
8484 this .resCounts = Utilities .getRelativeTagMaps (this .trainList , true );
8585 if (cType != CalculationType .NONE ) {
@@ -89,7 +89,7 @@ public BLLCalculator(BookmarkReader reader, int trainSize, double dVal, int beta
8989 this .resDenoms = new ArrayList <Double >();
9090 this .resTimestamps = new ArrayList <Long >();
9191 //if (this.resBased) {
92- this .resMaps = getArtifactMaps (reader , this .trainList , testList , true , this .resTimestamps , this .resDenoms , this .dVal , true , null );
92+ this .resMaps = getArtifactMaps (reader , this .trainList , testList , true , this .resTimestamps , this .resDenoms , this .dVal , true , null , true );
9393 //}
9494 }
9595
@@ -226,7 +226,7 @@ public Map<Integer, Double> getRankedTagList(int userID, int resID, boolean sort
226226
227227 // Basis activations values for each user
228228 public static List <Map <Integer , Double >> getArtifactMaps (BookmarkReader reader , List <Bookmark > userLines , List <Bookmark > testLines , boolean resource ,
229- List <Long > timestampList , List <Double > denomList , double dVal , boolean normalize , Double lambda ) {
229+ List <Long > timestampList , List <Double > denomList , double dVal , boolean normalize , Double lambda , boolean calcOnTags ) {
230230
231231 List <Map <Integer , Double >> maps = new ArrayList <Map <Integer , Double >>();
232232 for (Bookmark data : userLines ) {
@@ -247,14 +247,14 @@ public static List<Map<Integer, Double>> getArtifactMaps(BookmarkReader reader,
247247 }
248248 timestampList .add (baselineTimestamp );
249249 if (baselineTimestamp != -1 ) {
250- maps .add (addActValue (data , new LinkedHashMap <Integer , Double >(), baselineTimestamp , resource , dVal , lambda ));
250+ maps .add (addActValue (data , new LinkedHashMap <Integer , Double >(), baselineTimestamp , resource , dVal , lambda , calcOnTags ));
251251 } else {
252252 maps .add (null );
253253 }
254254 } else {
255255 baselineTimestamp = timestampList .get (refID );
256256 if (baselineTimestamp != -1 ) {
257- addActValue (data , maps .get (refID ), baselineTimestamp , resource , dVal , lambda );
257+ addActValue (data , maps .get (refID ), baselineTimestamp , resource , dVal , lambda , calcOnTags );
258258 }
259259 }
260260 }
@@ -288,7 +288,7 @@ public static List<Map<Integer, Double>> getArtifactMaps(BookmarkReader reader,
288288 public static Map <Integer , Double > getSortedArtifactMapForUser (int userID , BookmarkReader reader , List <Bookmark > userLines , List <Bookmark > testLines , boolean resource ,
289289 List <Long > timestampList , List <Double > denomList , double dVal , boolean normalize ) {
290290
291- List <Map <Integer , Double >> artifactMaps = getArtifactMaps (reader , userLines , testLines , resource , timestampList , denomList , dVal , normalize , null );
291+ List <Map <Integer , Double >> artifactMaps = getArtifactMaps (reader , userLines , testLines , resource , timestampList , denomList , dVal , normalize , null , true );
292292 if (artifactMaps != null && userID < artifactMaps .size ()) {
293293 Map <Integer , Double > sortedResultMap = new TreeMap <Integer , Double >(new DoubleMapComparator (artifactMaps .get (userID )));
294294 sortedResultMap .putAll (artifactMaps .get (userID ));
@@ -301,7 +301,7 @@ public static Map<Integer, Double> getCollectiveArtifactMap(BookmarkReader reade
301301 List <Long > timestampList , List <Double > denomList , double dVal , boolean normalize ) {
302302
303303 Map <Integer , Double > collectiveArtifactMap = new LinkedHashMap <Integer , Double >();
304- List <Map <Integer , Double >> artifactMaps = getArtifactMaps (reader , userLines , testLines , resource , timestampList , denomList , dVal , normalize , null );
304+ List <Map <Integer , Double >> artifactMaps = getArtifactMaps (reader , userLines , testLines , resource , timestampList , denomList , dVal , normalize , null , true );
305305 for (Map <Integer , Double > map : artifactMaps ) {
306306 for (Map .Entry <Integer , Double > entry : map .entrySet ()) {
307307 Double val = collectiveArtifactMap .get (entry .getKey ());
@@ -314,7 +314,8 @@ public static Map<Integer, Double> getCollectiveArtifactMap(BookmarkReader reade
314314 return sortedResultMap ;
315315 }
316316
317- private static Map <Integer , Double > addActValue (Bookmark data , Map <Integer , Double > actValues , long baselineTimestamp , boolean resource , double dVal , Double lambda ) {
317+ private static Map <Integer , Double > addActValue (Bookmark data , Map <Integer , Double > actValues , long baselineTimestamp ,
318+ boolean resource , double dVal , Double lambda , boolean calcOnTags ) {
318319 if (!data .getTimestamp ().isEmpty ()) {
319320 Double newAct = 0.0 ;
320321 if (resource ) {
@@ -331,7 +332,8 @@ private static Map<Integer, Double> addActValue(Bookmark data, Map<Integer, Doub
331332 }
332333 //}
333334 }
334- for (Integer value : data .getTags ()) {
335+ List <Integer > entities = calcOnTags ? data .getTags () : data .getCategories ();
336+ for (Integer value : entities ) {
335337 Double oldAct = actValues .get (value );
336338 if (!newAct .isInfinite () && !newAct .isNaN ()) {
337339 actValues .put (value , (oldAct != null ? oldAct + newAct : newAct ));
0 commit comments