package week5;

import java.util.BitSet;

import week3.BooleanModel;
import week3.Document;

/**
 * Implements the Boolean Model using the vector space model
 * @author harryscells
 *
 */
public class VectorSpaceModel extends BooleanModel{

	VectorSpaceModel() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	public void addDocument(Document document) {
		documentmap.put(documentmap.size(), document);
	}
	
	public void addTerm(String term) {
		index.put(term, new BitSet());
	}
	
	public float calculateCosineSimilarity(Document d, Query q) {
		return 0;
	}
	
	public float calculateIDF(Term t) {
		return 0;
	}

}

@@ -33,16 +33,42 @@
 .BitSet;
+%0Aimport java.util.HashMap;
 %0A%0Aimport
@@ -260,16 +260,86 @@
 Model%7B%0A%0A
+%09private HashMap%3CTerm, BitSet%3E index = new HashMap%3CTerm, BitSet%3E();%0A%09%0A
 %09VectorS
@@ -515,42 +515,253 @@
 %0A%09%0A%09
-public void addTerm(String term) %7B
+/**%0A%09 * Adds a term with it's frequency to the index%0A%09 * @param term %09%09The actual term string%0A%09 * @param frequency%09The total frequency in all documents%0A%09 */%0A%09public void addTerm(String term, int frequency) %7B%0A%09%09Term t = new Term(term, frequency);
 %0A%09%09i
@@ -770,19 +770,16 @@
 ex.put(t
-erm
 , new Bi
@@ -792,37 +792,38 @@
 );%0A%09%7D%0A%09%0A%09public 
-float
+double
  calculateCosine
@@ -885,13 +885,14 @@
 lic 
-float
+double
  cal
@@ -925,12 +925,202 @@
 rn 0;%0A%09%7D
+%0A%09%0A%09public double precalculateTFIDF(double tf, double df, int num_docs) %7B%0A%09%09return ((Math.log(tf) + 1) * Math.log(index.size()/num_docs)) / Math.sqrt(1/* lol what actually goes here? */);%0A%09%7D
 %0A%0A%7D%0A

make a start on some of the calculations