vinhkhuc / JFastText

Java interface for fastText
Other
228 stars 100 forks source link

How to get nearest neighbours using the API? #12

Open gabrer opened 7 years ago

gabrer commented 7 years ago

Hi!

I want to get the nearest neighbours inside my Java code using the JFastText API; however, I can not find which method I should use. In the original library the method is the "void FastText::nn(int32_t k)", but so far I've been able to call it only by JFastText "command".

suresh-soundararajan commented 6 years ago

Did you get any chance to implement this functionality ?

plxCrush commented 6 years ago

How can you use nn command for specific word? i'm trying something like:

`public void printSimilars(String x) {

    jft.runCmd(new String[] {
            String.format("echo %s |", x),
            "nn",
            MODEL_BIN,
    });

}`

to get 10 similar words for a given word in model. I get this error: "usage: fasttext The commands supported by fasttext are:

Thanks in advance.

aliakhtar commented 4 years ago

Bump - can this please be added? Shouldn't be too hard as most other functions are supported and this is a pretty important one

raman-r-4978 commented 4 years ago

Similar issue I have created in one of forked repo, hope it gives some idea.

https://github.com/carschno/JFastText/issues/9

If anyone interested, we can work on this to bring it as Java APIs.