@@ -31,16 +31,16 @@ License, or (at your option) any later version.
3131
3232public class TagRecommenderEvalEngine implements EngineInterface {
3333
34- private EngineInterface lmEngine ;
34+ // private EngineInterface lmEngine;
3535 private EngineInterface bllEngine ;
36- // private EngineInterface threelEngine;
36+ private EngineInterface threelEngine ;
3737 //private Random random;
3838 private BufferedWriter bw ;
3939
4040 public TagRecommenderEvalEngine () {
41- this .lmEngine = null ;
41+ // this.lmEngine = null;
4242 this .bllEngine = null ;
43- // this.threelEngine = null;
43+ this .threelEngine = null ;
4444 //this.random = new Random();
4545 this .bw = null ;
4646
@@ -54,29 +54,39 @@ public TagRecommenderEvalEngine() {
5454
5555 @ Override
5656 public void loadFile (String filename ) throws Exception {
57- this .lmEngine = null ;
57+ // this.lmEngine = null;
5858 this .bllEngine = null ;
59- // this.threelEngine = null;
59+ this .threelEngine = null ;
6060
61+ /* old
6162 BookmarkReader reader = new BookmarkReader(0, false);
6263 reader.readFile(filename);
63- // if (reader.getCategories().size() > 0) {
64- // this.threelEngine = new ThreeLayersEngine();
65- // this.threelEngine.loadFile(filename);
66- // }
64+ if (reader.getCategories().size() > 0) {
65+ this.threelEngine = new ThreeLayersEngine();
66+ this.threelEngine.loadFile(filename);
67+ }
6768 if (reader.hasTimestamp()) {
6869 this.bllEngine = new BaseLevelLearningEngine();
6970 this.bllEngine.loadFile(filename);
7071 }
7172 this.lmEngine = new LanguageModelEngine();
7273 this.lmEngine.loadFile(filename);
74+ */
75+ //if (filename.contains("group1") || filename.contains("group3")) {
76+ this .threelEngine = new ThreeLayersCollectiveEngine ();
77+ this .threelEngine .loadFile (filename );
78+ //} else {
79+ this .bllEngine = new BaseLevelLearningCollectiveEngine ();
80+ this .bllEngine .loadFile (filename );
81+ //}
7382 }
7483
7584 @ Override
7685 public synchronized Map <String , Double > getEntitiesWithLikelihood (String user , String resource , List <String > topics , Integer count , Boolean filterOwnEntities , Algorithm algorithm , EntityType type ) {
7786 Map <String , Double > returnMap = null ;
7887 String algorithmString = null ;
7988
89+ /* old
8090 if (this.bllEngine != null) {
8191 if (algorithm == null || algorithm == Algorithm.BLLacMPr) {
8292 algorithmString = "BLLacMPr";
@@ -88,13 +98,31 @@ public synchronized Map<String, Double> getEntitiesWithLikelihood(String user, S
8898 if (algorithmString != null) {
8999 returnMap = this.bllEngine.getEntitiesWithLikelihood(user, resource, topics, count, filterOwnEntities, algorithm, type);
90100 }
91- }
92-
101+ }
93102 if (algorithmString == null) {
94103 algorithmString = "MPur";
95104 returnMap = this.lmEngine.getEntitiesWithLikelihood(user, resource, topics, count, filterOwnEntities, algorithm, type);
96105 }
97-
106+ */
107+ if (algorithm == null || algorithm == Algorithm .THREELcoll || algorithm == Algorithm .THREEL ) {
108+ if (this .threelEngine != null ) {
109+ returnMap = this .threelEngine .getEntitiesWithLikelihood (user , resource , topics , count , filterOwnEntities , algorithm , type );
110+ if (algorithm == Algorithm .THREEL ) {
111+ algorithmString = "3L" ;
112+ } else {
113+ algorithmString = "3Lcoll" ;
114+ }
115+ }
116+ } else {
117+ if (this .bllEngine != null ) {
118+ returnMap = this .bllEngine .getEntitiesWithLikelihood (user , resource , topics , count , filterOwnEntities , algorithm , type );
119+ if (algorithm == Algorithm .BLL ) {
120+ algorithmString = "BLL" ;
121+ } else {
122+ algorithmString = "BLLcoll" ;
123+ }
124+ }
125+ }
98126 if (this .bw != null ) {
99127 try {
100128 this .bw .write (user + "|" + resource + "|" + topics + "|" + count + "|" + filterOwnEntities + "|" + System .currentTimeMillis () + "|" + algorithmString + "|" + returnMap .keySet () + "\n " );
@@ -105,4 +133,8 @@ public synchronized Map<String, Double> getEntitiesWithLikelihood(String user, S
105133 }
106134 return returnMap ;
107135 }
136+
137+ public static boolean getRandomBoolean () {
138+ return Math .random () < 0.5 ;
139+ }
108140}
0 commit comments