Skip to content

Commit

Permalink
testing with words
Browse files Browse the repository at this point in the history
  • Loading branch information
nikit-srivastava committed Oct 10, 2018
1 parent e64feea commit e823fa9
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ public class NrmlzdThetaMdlPrfmncTester {
PropertyConfigurator.configure(Cfg.LOG_FILE);
}
public static Logger LOG = LogManager.getLogger(NrmlzdThetaMdlPrfmncTester.class);

public static final float[][] TEST_CENTROIDS = { TestConst.CENT1, TestConst.CENT2, TestConst.CENT3, TestConst.CENT4,
TestConst.CENT5, TestConst.CENT6, TestConst.CENT7, TestConst.CENT8, TestConst.CENT9, TestConst.CENT10,
TestConst.CENT11, TestConst.CENT12, TestConst.CENT13, TestConst.CENT14, TestConst.CENT15, TestConst.CENT16,
TestConst.CENT17, TestConst.CENT18, TestConst.CENT19, TestConst.CENT20 };
public static final String[] TEST_WORDS = { "cat", "dog", "airplane", "road", "kennedy", "rome", "human", "disney",
"machine", "intelligence", "palaeontology", "surgeon", "amazon", "jesus", "gold", "atlantis", "ronaldo",
"pele", "scissors", "lizard" };
/*
* @Test public void testNbmTime() { long startTime, diff; long totTime = 0;
* LOG.info("Starting InMemory Theta Model test!"); Word2VecModel nbm =
Expand Down Expand Up @@ -56,10 +62,8 @@ public void testNbmTime() throws IOException {
long totTime = 0;
LOG.info("Starting InMemory Theta Model test!");
Word2VecModel nbm = Word2VecFactory.getNormalBinModel();
float[][] centroids = { TestConst.CENT1, TestConst.CENT2, TestConst.CENT3, TestConst.CENT4, TestConst.CENT5,
TestConst.CENT6, TestConst.CENT7, TestConst.CENT8, TestConst.CENT9, TestConst.CENT10, TestConst.CENT11,
TestConst.CENT12, TestConst.CENT13, TestConst.CENT14, TestConst.CENT15, TestConst.CENT16,
TestConst.CENT17, TestConst.CENT18, TestConst.CENT19, TestConst.CENT20 };
// float[][] centroids = TEST_CENTROIDS;
float[][] centroids = fetchWordsVec(TEST_WORDS, nbm);
LOG.info("Starting BruteForce-Model Test");
List<String> correctWords = NrmlzdMdlPrfmncTester.getCorrectWords(centroids, nbm);
LOG.info("Correct Words are :" + correctWords);
Expand All @@ -77,10 +81,19 @@ public void testNbmTime() throws IOException {
totTime += diff;
LOG.info("Query time recorded for Centroid " + (i + 1) + " is " + diff + " milliseconds.");
}
LOG.info("Average query time for W2VNrmlMemModelBinSrch is : " + (totTime / centroids.length) + " milliseconds");
LOG.info(
"Average query time for W2VNrmlMemModelBinSrch is : " + (totTime / centroids.length) + " milliseconds");
LOG.info("Predicted Words are :" + lrModelWords);
float percVal = NrmlzdMdlPrfmncTester.calcPercScore(correctWords, lrModelWords);
LOG.info("Score for Test is : " + percVal + "%");
lrModelWords.clear();
}

private static float[][] fetchWordsVec(String[] words, Word2VecModel nbm) {
float[][] resVec = new float[words.length][300];
for (int i = 0; i < words.length; i++) {
resVec[i] = nbm.word2vec.get(words[i]);
}
return resVec;
}
}

0 comments on commit e823fa9

Please sign in to comment.