JFastText icon indicating copy to clipboard operation
JFastText copied to clipboard

How to get nearest neighbours using the API?

Open gabrer opened this issue 7 years ago • 4 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".

gabrer avatar Jun 22 '17 17:06 gabrer

Did you get any chance to implement this functionality ?

suresh-soundararajan avatar Jan 12 '18 11:01 suresh-soundararajan

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.

plxCrush avatar May 27 '18 19:05 plxCrush

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

aliakhtar avatar Feb 16 '20 10:02 aliakhtar

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.

raman-r-4978 avatar Jul 29 '20 04:07 raman-r-4978