@@ -179,14 +179,24 @@ public Map<Integer, Double> getRankedTagList(int userID, int resID, List<Integer
179179
180180 public Map <Integer , Double > getCollectiveRankedTagList (List <Integer > testCats , double testTimestamp , int limit , boolean tagBLL , boolean topicBLL ) {
181181 Map <Integer , Double > collectiveTagMap = new LinkedHashMap <Integer , Double >();
182- for (int id = 0 ; id < this .reader .getUsers ().size (); id ++) {
183- Map <Integer , Double > tagMap = getRankedTagList (id , -1 , testCats , testTimestamp , limit , tagBLL , topicBLL , false );
184- for (Map .Entry <Integer , Double > entry : tagMap .entrySet ()) {
185- Double val = collectiveTagMap .get (entry .getKey ());
186- collectiveTagMap .put (entry .getKey (), val == null ? entry .getValue () : val .doubleValue () + entry .getValue ());
182+
183+ List <Bookmark > bookmarks = this .reader .getBookmarks ();
184+ List <Map <Integer , Integer >> resTopics = Utilities .getResTopics (bookmarks );
185+ for (Bookmark b : bookmarks ) {
186+ if (b .getResourceID () < resTopics .size ()) {
187+ double sim = Utilities .getCosineSimList (testCats , new ArrayList <Integer >(resTopics .get (b .getResourceID ()).keySet ()));
188+ Double ajhid = Math .pow (sim , 3 );
189+ if (ajhid .isNaN () || ajhid .isInfinite ()) {
190+ ajhid = 0.0 ;
191+ System .out .println ("Cos - NAN" );
192+ }
193+ for (int t : b .getTags ()) {
194+ Double tVal = collectiveTagMap .get (t );
195+ collectiveTagMap .put (t , tVal == null ? ajhid : tVal .doubleValue () + ajhid );
196+ }
187197 }
188198 }
189-
199+
190200 Map <Integer , Double > sortedResultMap = new TreeMap <Integer , Double >(new DoubleMapComparator (collectiveTagMap ));
191201 sortedResultMap .putAll (collectiveTagMap );
192202 Map <Integer , Double > returnMap = new LinkedHashMap <Integer , Double >();
0 commit comments