public HashMap> createFeatureMatrix(int vocabSize,int embeddingDimension) throws NullPointerException /* *Weight vector for each of the word is initialized here. */ { HashMap> featureMatrix = new HashMap>(); for(int i =0 ; i< vocabSize; i++){ featureMatrix.put(i,wordFeauture(embeddingDimension)); } return featureMatrix; }//end of createFeatureMatrix private ArrayList wordFeauture(int a) { Double ranVal; Random rand = new Random(); ArrayList arrList = new ArrayList(); for(int i =0 ; i< a; i++){ ranVal = rand.nextGaussian(); arrList.add(ranVal); } return arrList; } private ArrayList getContextFeatureVector(ArrayList Ngram,HashMap FrequentWordIndex, HashMap > wordFeatureMatrix) throws NullPointerException /*INPUT :Ngram, Vocabulary Index *RETURNS:Feature Vector of context of given N-gram. */ { int contextSize = Ngram.size()-1; System.out.println("getContextFeatureVector: Context Size:"+ contextSize); System.out.println(Ngram); ArrayList contextFeature = new ArrayList(); contextFeature =wordFeatureMatrix.get(FrequentWordIndex.get(Ngram.get(0).toLowerCase())); System.out.println(Ngram.get(0)); //System.out.println(contextFeature); for(int i =1 ; i < contextSize; i++){ //ArrayList arrList = new ArrayList(); System.out.println(Ngram.get(i)); //arrList = wordFeatureMatrix.get(FrequentWordIndex.get(Ngram.get(i).toLowerCase())); System.out.println(wordFeatureMatrix.get(FrequentWordIndex.get(Ngram.get(i).toLowerCase())).size()); //System.out.println("getContextFeatureVector:feature vector:"+arrList); //System.out.println("getContextFeatureVector:feature vector size:"+arrList.size()); //contextFeature.addAll(wordFeatureMatrix.get(FrequentWordIndex.get(Ngram.get(i).toLowerCase()))); //System.out.println("getContextFeatureVector:context vector size:"+contextFeature.size()); } //System.out.println(contextFeature); System.out.println("Size of context Feature"+contextFeature.size()); return contextFeature; }