vinhkhuc / JFastText

Java interface for fastText

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get nearest neighbours using the API?

gabrer opened this issue · comments

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".

Did you get any chance to implement this functionality ?

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.

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

commented

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

carschno#9

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