// Path: src/edu/antonym/prototype/Thesaurus.java
// public interface Thesaurus {
// 	public interface Entry {
// 		public int word1();
// 		public int word2();
// 		public boolean isAntonym();
// 	}
// 	public Vocabulary getVocab();
// 	
// 	//Returns the words included in the Thesaurus
// 	public int numEntries();
// 	public int numSynonyms();
// 	public int numAntonyms();
// 	public Entry getEntry(int entryn);
// 	
// 	public int lookupEntry(int word1, int word2, boolean isAnt);
// 
// 	
// 	public boolean isAntonym(int word1, int word2);
// 	public boolean isSynonym(int word1, int word2);
// }
// 
// Path: src/edu/antonym/prototype/Thesaurus.java
// public interface Entry {
// 	public int word1();
// 	public int word2();
// 	public boolean isAntonym();
// }
// 
// Path: src/edu/antonym/prototype/VectorEmbedding.java
// public interface VectorEmbedding extends WordMetric {
// 
// 	int getDimension();
// 	public double[] getVectorRep(int word);
// 	public int findClosestWord(double[] vector);
// 	Vocabulary getVocab();
// }
// 
// Path: src/edu/antonym/prototype/Vocabulary.java
// public interface Vocabulary {
// 	public int size();
// 	public int OOVindex();
// 	public String lookupIndex(int index);
// 	public int lookupWord(String word);
// 	public int getVocabSize();
// }


import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import edu.antonym.prototype.Thesaurus;
import edu.antonym.prototype.Thesaurus.Entry;
import edu.antonym.prototype.VectorEmbedding;
import edu.antonym.prototype.Vocabulary;
package edu.antonym;



public class Util {
	static void saveVectors(VectorEmbedding embed, Vocabulary vocab, File out) throws FileNotFoundException {
		int dim=embed.getDimension();
		
		PrintStream ps=new PrintStream(out);
		ps.println(dim);
		for(int i=0; i<vocab.size(); i++) {
			double[] vect=embed.getVectorRep(i);
			for(int j=0; j<dim; j++) {
				ps.print(vect[j]);
				ps.print(' ');
			}
			ps.println();
		}
		ps.close();
	}
	
	public static double cosineSimilarity(double[] vector1, double[] vector2) {
		double dotProduct = 0.0;
		double v1 = 0.0;
		double v2 = 0.0;
		double cosineSimilarity = 0.0;

        for (int i = 0; i < vector1.length; i++) //vector1 and vector2 must be of same length
        {
            dotProduct += vector1[i] * vector2[i];  
            v1 += Math.pow(vector1[i], 2);  
            v2 += Math.pow(vector2[i], 2); 
        }

// Path: src/edu/antonym/prototype/Thesaurus.java
// public interface Thesaurus {
// 	public interface Entry {
// 		public int word1();
// 		public int word2();
// 		public boolean isAntonym();
// 	}
// 	public Vocabulary getVocab();
// 	
// 	//Returns the words included in the Thesaurus
// 	public int numEntries();
// 	public int numSynonyms();
// 	public int numAntonyms();
// 	public Entry getEntry(int entryn);
// 	
// 	public int lookupEntry(int word1, int word2, boolean isAnt);
// 
// 	
// 	public boolean isAntonym(int word1, int word2);
// 	public boolean isSynonym(int word1, int word2);
// }
// 
// Path: src/edu/antonym/prototype/Thesaurus.java
// public interface Entry {
// 	public int word1();
// 	public int word2();
// 	public boolean isAntonym();
// }
// 
// Path: src/edu/antonym/prototype/VectorEmbedding.java
// public interface VectorEmbedding extends WordMetric {
// 
// 	int getDimension();
// 	public double[] getVectorRep(int word);
// 	public int findClosestWord(double[] vector);
// 	Vocabulary getVocab();
// }
// 
// Path: src/edu/antonym/prototype/Vocabulary.java
// public interface Vocabulary {
// 	public int size();
// 	public int OOVindex();
// 	public String lookupIndex(int index);
// 	public int lookupWord(String word);
// 	public int getVocabSize();
// }


// Path: src/edu/antonym/Util.java
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import edu.antonym.prototype.Thesaurus;
import edu.antonym.prototype.Thesaurus.Entry;
import edu.antonym.prototype.VectorEmbedding;
import edu.antonym.prototype.Vocabulary;

package edu.antonym;



public class Util {
	static void saveVectors(VectorEmbedding embed, Vocabulary vocab, File out) throws FileNotFoundException {
		int dim=embed.getDimension();
		
		PrintStream ps=new PrintStream(out);
		ps.println(dim);
		for(int i=0; i<vocab.size(); i++) {
			double[] vect=embed.getVectorRep(i);
			for(int j=0; j<dim; j++) {
				ps.print(vect[j]);
				ps.print(' ');
			}
			ps.println();
		}
		ps.close();
	}
	
	public static double cosineSimilarity(double[] vector1, double[] vector2) {
		double dotProduct = 0.0;
		double v1 = 0.0;
		double v2 = 0.0;
		double cosineSimilarity = 0.0;

        for (int i = 0; i < vector1.length; i++) //vector1 and vector2 must be of same length
        {
            dotProduct += vector1[i] * vector2[i];  
            v1 += Math.pow(vector1[i], 2);  
            v2 += Math.pow(vector2[i], 2); 
        }

        v1 = Math.sqrt(v1);	