optimaize / language-detector

Language Detection Library for Java
Apache License 2.0
567 stars 165 forks source link

How to set short-text profile from Java code #95

Open sagarpatel07 opened 6 years ago

sagarpatel07 commented 6 years ago

Hello,

I am very happy to used this API, but someone can please let me know how i can used API with short-text profile. Thanks in Advanced.

Thanks, Sagar

james-s-w-clark commented 4 years ago

@sagarpatel07 I think my snippet in issue 63 (slightly rewritten here) does what you want:

        int shortTextLimit = 100; // 50 by default. Strings shorter than this use the short-text language detection algorithm

        List<LanguageProfile> languageProfiles = new LanguageProfileReader().readAllBuiltIn();
        LanguageDetector detector = LanguageDetectorBuilder.create(NgramExtractors.standard())
                .withProfiles(languageProfiles)
                .shortTextAlgorithm(shortTextLimit)
                .build();

Does that help you?