public HashMap<Text, Double> calculateCosineSimilarity(ArrayList<Text> textCollection, String Query){
		CosineSimilarity cosim = new CosineSimilarity();
		Text QueryText = new Text(Query);
		ArrayList<String> QueryTokens = tokenize(QueryText);


		HashMap<String, Double> TfIdfQuery = new HashMap<String, Double>();
		Map<String, Integer> TermFrequency = new HashMap<String, Integer>();

		String[] StopWords = DEFAULT_STOPWORDS.split(" ");
		ArrayList<String> stopArrayList = new ArrayList<String>(Arrays.asList(StopWords));


		for(String word: QueryTokens){

			if(!stopArrayList.contains(word)){

				if(!TermFrequency.containsKey(word)){


					TermFrequency.put(word, 0);
				}
				TermFrequency.put(word, TermFrequency.get(word)+1);

			}
		}

		Set<Entry<String, Integer>> set = TermFrequency.entrySet(); 
		Map<String, Double> map2 = new HashMap<String, Double>();
		for (Map.Entry<String, Integer> me : set) { 

			double value = me.getValue();
			double antallOrd = QueryTokens.size();
			double snitt = value/antallOrd;

			map2.put(me.getKey(),snitt);
		}
		for(String s: map2.keySet()){
			double termFr = map2.get(s);
			double idf =0;
			try {
				idf = 0 + InvertedDocumentFrequency.get(s);			

			} catch (NullPointerException e) {
				idf=0;
			}
			double tfIdf = termFr * idf;
			TfIdfQuery.put(s, (tfIdf));

		}

		HashMap<Text, Double> map = new HashMap<Text, Double>();
		for(Text t : textCollection){
			HashMap<String, Double> h1 = (HashMap<String, Double>) t.getTfIdf();
			map.put(t, cosim.calculateCosineSimilarity(h1,TfIdfQuery));
		}


		HashMap<Text, Double> map1 = (HashMap<Text, Double>) Sorter.sortMapByValuesDescending(map);
		QueryText.setTfIdf(TfIdfQuery);
		return map1;
	}