// Path: src/main/java/unsw/curation/api/domain/ExtractSynonym.java
// public class ExtractSynonym {
// 
// 	public ExtractSynonym(){}
// 	public ExtractSynonym(String word,String synset)
// 	{
// 		this.word=word;
// 		this.synset=synset;
// 	}
// 	private String word;
// 	
// 	private String synset;
// 
// 	public String getWord() {
// 		return word;
// 	}
// 
// 	public void setWord(String word) {
// 		this.word = word;
// 	}
// 
// 	public String getSynset() {
// 		return synset;
// 	}
// 
// 	public void setSynset(String synset) {
// 		this.synset = synset;
// 	}
// 	
// }
// 
// Path: src/main/java/unsw/curation/api/domain/abstraction/ISynonym.java
// public interface ISynonym {
// 
// 	List<String> ExtractSynonymWord(String word) throws URISyntaxException, IOException;
// 	List<String> ExtractHypernymWord(String word);
// }


import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import edu.mit.jwi.Dictionary;
import edu.mit.jwi.IDictionary;
import edu.mit.jwi.item.IIndexWord;
import edu.mit.jwi.item.ISynset;
import edu.mit.jwi.item.ISynsetID;
import edu.mit.jwi.item.IWord;
import edu.mit.jwi.item.IWordID;
import edu.mit.jwi.item.POS;
import edu.mit.jwi.item.Pointer;
import edu.mit.jwi.morph.WordnetStemmer;
import unsw.curation.api.domain.ExtractSynonym;
import unsw.curation.api.domain.abstraction.ISynonym;

	            dict.open();
	            WordnetStemmer stemmer=new WordnetStemmer(dict);
	            List<String> lstStem=stemmer.findStems(word, POS.NOUN);
	            for(int j=0;j<1000;j++)
	            {
	            IIndexWord idxWord = dict.getIndexWord(lstStem.get(0),POS.NOUN);
	            IWordID wordID = idxWord.getWordIDs().get (j) ;
	            IWord mywords = dict . getWord (wordID);
	            ISynset sen=mywords.getSynset();
	            List <ISynsetID> hypernyms = sen.getRelatedSynsets (Pointer.HYPERNYM);
	            List<IWord> words;
	            for(ISynsetID sid : hypernyms)
	            {
	                words = dict . getSynset (sid). getWords ();
	                for( Iterator <IWord > i = words . iterator (); i. hasNext () ;)
	                {
	                	
	                	lstHypernym.add((i. next (). getLemma ()));
	                //if(i. hasNext ())
	                 //  strHypernym+=",";
	                }
	            }
	            }
	         }
	       catch(Exception ex)
	       {
	       }
	        return lstHypernym;
	}
	

// Path: src/main/java/unsw/curation/api/domain/ExtractSynonym.java
// public class ExtractSynonym {
// 
// 	public ExtractSynonym(){}
// 	public ExtractSynonym(String word,String synset)
// 	{
// 		this.word=word;
// 		this.synset=synset;
// 	}
// 	private String word;
// 	
// 	private String synset;
// 
// 	public String getWord() {
// 		return word;
// 	}
// 
// 	public void setWord(String word) {
// 		this.word = word;
// 	}
// 
// 	public String getSynset() {
// 		return synset;
// 	}
// 
// 	public void setSynset(String synset) {
// 		this.synset = synset;
// 	}
// 	
// }
// 
// Path: src/main/java/unsw/curation/api/domain/abstraction/ISynonym.java
// public interface ISynonym {
// 
// 	List<String> ExtractSynonymWord(String word) throws URISyntaxException, IOException;
// 	List<String> ExtractHypernymWord(String word);
// }


// Path: src/main/java/unsw/curation/api/extractsynonym/WordNetFile.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import edu.mit.jwi.Dictionary;
import edu.mit.jwi.IDictionary;
import edu.mit.jwi.item.IIndexWord;
import edu.mit.jwi.item.ISynset;
import edu.mit.jwi.item.ISynsetID;
import edu.mit.jwi.item.IWord;
import edu.mit.jwi.item.IWordID;
import edu.mit.jwi.item.POS;
import edu.mit.jwi.item.Pointer;
import edu.mit.jwi.morph.WordnetStemmer;
import unsw.curation.api.domain.ExtractSynonym;
import unsw.curation.api.domain.abstraction.ISynonym;

	            dict.open();
	            WordnetStemmer stemmer=new WordnetStemmer(dict);
	            List<String> lstStem=stemmer.findStems(word, POS.NOUN);
	            for(int j=0;j<1000;j++)
	            {
	            IIndexWord idxWord = dict.getIndexWord(lstStem.get(0),POS.NOUN);
	            IWordID wordID = idxWord.getWordIDs().get (j) ;
	            IWord mywords = dict . getWord (wordID);
	            ISynset sen=mywords.getSynset();
	            List <ISynsetID> hypernyms = sen.getRelatedSynsets (Pointer.HYPERNYM);
	            List<IWord> words;
	            for(ISynsetID sid : hypernyms)
	            {
	                words = dict . getSynset (sid). getWords ();
	                for( Iterator <IWord > i = words . iterator (); i. hasNext () ;)
	                {
	                	
	                	lstHypernym.add((i. next (). getLemma ()));
	                //if(i. hasNext ())
	                 //  strHypernym+=",";
	                }
	            }
	            }
	         }
	       catch(Exception ex)
	       {
	       }
	        return lstHypernym;
	}
	

	public List<ExtractSynonym> ExtractSynonymFile(File filePath) throws MalformedURLException, IOException
