JFastSpell is a Java wrapper of FastSpell, the most performant, publicly available language detection module by 07/23/2024.
I have no prior knowledge of Java. Please let me know if you have any issue.
- Bazel
- Gson
- JFastText
- HunSpell JNA (This might also work, but it hasn't been maintained for 7 years.)
-
Download
lid.176.bin
model from FastText and put it in thesrc/main/resources
folder of your project. -
Download the
fastspell_dictionaries
folder and put it in thesrc/main/resources
folder of your project. Make sure the folder name uses an underscore_
instead of-
. -
Make sure that the contents of
hunspellCodes.json
andsimilarLangs.json
in thesrc/main/resources
folder matches the contents of the.yaml
configurations here. -
Build the aforementioned dependencies and put the
.jar
files in thedependencies
folder at project root:
gson-2.11.0.jar
hunspell-2.2.0.jar
jfasttext-0.5-jar-with-dependencies.jar
- (optional) Modify your configurations in
src/main/resources/config.json
if necessary.
Make sure that you have successfully installed Bazel. Go to the project root directory. Build FastSpell:
bazel build //:FastSpell
Then test it with an arbitrary input sentence:
bazel-bin/FastSpell YOUR_SENTENCE_HERE
FastSpell fs = new FastSpell();
String lang = fs.getLang("Hello world!");
System.out.println(lang);