Download Jar. Uses 81K of libraries. Click here for Pure Java version (5921L/42K).
1 | !7 |
2 | |
3 | lib 1400180 // github.com/optimaize/language-detector |
4 | lib 1400181 // jsonic |
5 | lib 1011966 // slf4j-api-1.7.25.jar |
6 | lib 1400182 // guava |
7 | |
8 | import com.optimaize.langdetect.*; |
9 | import com.optimaize.langdetect.i18n.*; |
10 | import com.optimaize.langdetect.ngram.*; |
11 | import com.optimaize.langdetect.profiles.*; |
12 | import com.optimaize.langdetect.text.*; |
13 | |
14 | p-exp { |
15 | new LanguageProfileReader profileReader; |
16 | //L<LanguageProfile> languageProfiles = profileReader.readAllBuiltIn(); |
17 | L<LanguageProfile> languageProfiles = ll(profileReader.readBuiltIn(LdLocale.fromString("de")), profileReader.readBuiltIn(LdLocale.fromString("en"))); |
18 | |
19 | LanguageDetector languageDetector = LanguageDetectorBuilder.create(NgramExtractors.standard()) |
20 | .withProfiles(languageProfiles) |
21 | .build(); |
22 | |
23 | // create a text object factory |
24 | TextObjectFactory textObjectFactory = CommonTextObjectFactories.forDetectingOnLargeText(); |
25 | |
26 | // query |
27 | for (S text : ll("hello world", "hallo welt")) { |
28 | //TextObject textObject = textObjectFactory.forText(text); |
29 | //LdLocale lang = languageDetector.detect(textObject).orElse(null); |
30 | L<DetectedLanguage> languages = languageDetector.getProbabilities(text); |
31 | print(text + " => " + languages); |
32 | } |
33 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1021122 |
Snippet name: | Test Language Detector [OK] |
Eternal ID of this version: | #1021122/9 |
Text MD5: | 4a76bc18dfbcae47825c34d01a3553b1 |
Transpilation MD5: | 473e2c9b6593d2a0a016756c177b7b7a |
Author: | stefan |
Category: | javax / nlp |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-01-23 18:48:14 |
Source code size: | 1244 bytes / 33 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 408 / 901 |
Version history: | 8 change(s) |
Referenced in: | [show references] |