Commits

Sara Magliacane committed 95e89db

trying to remove the duplication in the computation

  • Participants
  • Parent commits e4183e8

Comments (0)

Files changed (1)

File src/nl/vu/recoprov/experiments/Experiment3.java

 	private static String jsonfile = "pan.json";
 	
 	private static DependencyGraph baselineGraph = null;
-	private static DependencyGraph depGraph;
+	private static DependencyGraph depGraph = null;
 	private static ProvDMtranslator provtranslator = new  ProvDMtranslator();
 
 	
 		File logfile = new File("log" + System.currentTimeMillis() + ".txt");
 		FileWriter writer = new FileWriter(logfile);
 
+		
+		DependencyGraph depGraphLucene = createGraph();
+		depGraphLucene = new LuceneSimilaritySignal().computeSignal(depGraphLucene);
+		
+		DependencyGraph depGraphLuceneMore = createGraph();
+		depGraphLuceneMore = new LuceneMoreLikeThisSignal().computeSignal(depGraphLuceneMore);
+		
+		depGraph = provreader.generatePANDepGraph();
+		provtranslator.translate(depGraph, "graphCorpus.gv");
+		System.out.println("Done with reference graph");
+
+		// Compare with Transitive Closure
+//		DependencyGraph depGraphT = new TransitiveClosure()
+//				.aggregateSignals(depGraph);
+//		provtranslator.translate(depGraphT, "graphCorpus_Trans.gv");
+
+		
 		// useful for small experiments
 		double[] thresholds = { 0, 0.01, 0.05, 0.1, 0.2};
 
 		for (double threshold : thresholds) {
 
 			ConfigurationDefaults.LUCENE_THRESHOLD = threshold;
-
-			// use only Lucene
-			DependencyGraph depGraph1 = createGraph();
-			depGraph1 = new LuceneSimilaritySignal().computeSignal(depGraph1);
-			depGraph1 = new LuceneThresholdFilter().filterSignals(depGraph1);
+			DependencyGraph depGraphLuceneThreshold = depGraphLucene.copyGraph();
+			depGraphLuceneThreshold = new LuceneThresholdFilter().filterSignals(depGraphLuceneThreshold);
+			
+			
+			DependencyGraph depGraph1 = depGraphLuceneThreshold.copyGraph();
 			depGraph1 = new WeightedSumAggregator().aggregateSignals(depGraph1);
 			System.out.println("Done with baseline graph (Lucene)");
-
-			depGraph = provreader.generatePANDepGraph();
-			provtranslator.translate(depGraph, "graphCorpus.gv");
-			System.out.println("Done with reference graph");
-			// Compare with Transitive Closure
-//			DependencyGraph depGraphT = new TransitiveClosure()
-//					.aggregateSignals(depGraph);
-//			provtranslator.translate(depGraphT, "graphCorpus_Trans.gv");
-
 			writeResults(depGraph1, "Lucene", writer);
 
-			
-			
-			depGraph1 = createGraph();
-			depGraph1 = new LuceneMoreLikeThisSignal().computeSignal(depGraph1);
-			depGraph1 = new LuceneThresholdFilter().filterSignals(depGraph1);
-			depGraph1 = new WeightedSumAggregator().aggregateSignals(depGraph1);
-			System.out.println("Done with Lucene more like this");
-			writeResults(depGraph1, "LuceneMoreLikeThis", writer);
 
-			depGraph1 = createGraph();
-			depGraph1 = new LuceneSimilaritySignal().computeSignal(depGraph1);
-			depGraph1 = new LuceneThresholdFilter().filterSignals(depGraph1);
+			depGraph1 = depGraphLuceneThreshold.copyGraph();
 			depGraph1 = new TextContainmentFilter().filterSignals(depGraph1);
 			depGraph1 = new WeightedSumAggregator().aggregateSignals(depGraph1);
 			System.out.println("Done with Lucene + Filter");
 			writeResults(depGraph1, "LuceneFilter", writer);
-			
-			
-			depGraph1 = createGraph();
-			depGraph1 = new LuceneSimilaritySignal().computeSignal(depGraph1);
-			depGraph1 = new LuceneThresholdFilter().filterSignals(depGraph1);
+
+			depGraph1 = depGraphLuceneThreshold.copyGraph();
 			depGraph1 = new PlagiarismCorpusSpecificFilter().filterSignals(depGraph1);
 			depGraph1 = new WeightedSumAggregator().aggregateSignals(depGraph1);
 			System.out.println("Done with Lucene + Domain Specific Filter");
 			writeResults(depGraph1, "LucenePANFilter", writer);
 			
-			depGraph1 = createGraph();
-			depGraph1 = new LuceneSimilaritySignal().computeSignal(depGraph1);
-			depGraph1 = new LuceneThresholdFilter().filterSignals(depGraph1);
+			depGraph1 = depGraphLuceneThreshold.copyGraph();
 			depGraph1 = new TextContainmentFilter().filterSignals(depGraph1);
 			depGraph1 = new PlagiarismCorpusSpecificFilter().filterSignals(depGraph1);
 			depGraph1 = new WeightedSumAggregator().aggregateSignals(depGraph1);
 			writeResults(depGraph1, "LucenePAN2Filters", writer);
 			
 			
-			depGraph1 = createGraph();
-			depGraph1 = new LuceneMoreLikeThisSignal().computeSignal(depGraph1);
+			depGraphLuceneThreshold = depGraphLuceneMore.copyGraph();
+			depGraph1 = new LuceneThresholdFilter().filterSignals(depGraph1);
+			depGraph1 = new WeightedSumAggregator().aggregateSignals(depGraph1);
+			System.out.println("Done with Lucene more like this");
+			writeResults(depGraph1, "LuceneMoreLikeThis", writer);
+
+			
+			depGraph1 = depGraphLuceneMore.copyGraph();
 			depGraph1 = new LuceneThresholdFilter().filterSignals(depGraph1);
 			depGraph1 = new TextContainmentFilter().filterSignals(depGraph1);
 			depGraph1 = new PlagiarismCorpusSpecificFilter().filterSignals(depGraph1);
 //			System.out.println("Done with compression distance + Lucene + Filter");
 //			writeResults(depGraph1, "CompressionLuceneFilter", writer);
 
-
+			writer.flush();
 		}
-		writer.flush();
+
 		writer.close();
 
 	}