fastText4j icon indicating copy to clipboard operation
fastText4j copied to clipboard

nnSearch and analogies does not return the specified k

Open DavidGOrtega opened this issue 7 years ago • 1 comments

Loaded the model for english if I set k=5 return less

   private static FastText model;

    @BeforeClass
    public static void onlyOnce() throws Exception {
        String modelPath = "../cc.en.300.bin";
        model = FastText.loadFasttextBinModel(modelPath);
    }

    @Test
    public void nnSearch() {
        int topN = 5;
        List<FloatStringPair> predict = model.nearestNeighbor("king", topN);
        assertEquals(topN, predict.size());
    }

    @Test
    public void analogies() {
        int topN = 5;
        List<FloatStringPair> predict = model.analogies("berlin", "germany", "france", topN);
        assertEquals(topN, predict.size());
    }
java.lang.AssertionError: 
Expected :5
Actual   :3

java.lang.AssertionError: 
Expected :5
Actual   :4

DavidGOrtega avatar Aug 17 '19 10:08 DavidGOrtega

<dependency>
  <groupId>com.mayabot.mynlp</groupId>
  <artifactId>fastText4j</artifactId>
  <version>3.1.0</version>
</dependency>

jimichenx avatar Mar 06 '20 13:03 jimichenx