Package com.cybozu.labs.langdetect

Examples of com.cybozu.labs.langdetect.Detector


    public boolean hasTranslatedProperty(GraphPropertyWorkData data, String translatedTextPropertyKey) {
        return data.getElement().getProperty(translatedTextPropertyKey, data.getProperty().getName()) != null;
    }

    private String detectLanguage(String text) throws LangDetectException, IOException {
        Detector detector = DetectorFactory.create();
        detector.append(text);
        String lang = detector.detect();
        if (lang.length() == 0) {
            return null;
        }
        return lang;
    }
View Full Code Here


    try {
      if (!isLoadLanguageProfile) {
        DetectorFactory.loadProfile("language_detect");
        isLoadLanguageProfile = true;
      }
      Detector detector = DetectorFactory.create();
      detector.append(title);
      lang = detector.detect();
    } catch (LangDetectException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    int type = 1;
View Full Code Here

    try {
      if (!isLoadLanguageProfile) {
        DetectorFactory.loadProfile("language_detect");
        isLoadLanguageProfile = true;
      }
      Detector detector = DetectorFactory.create();
      detector.append(title);
      lang = detector.detect();
    } catch (LangDetectException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    int type = 1;
View Full Code Here

    try {
      if (!isLoadLanguageProfile) {
        DetectorFactory.loadProfile("language_detect");
        isLoadLanguageProfile = true;
      }
      Detector detector = DetectorFactory.create();
      detector.append(title);
      lang = detector.detect();
    } catch (LangDetectException e) {
      e.printStackTrace();
    }
    int type = 1;
    if (lang.equalsIgnoreCase("en")) {
View Full Code Here

    try {
      if (!isLoadLanguageProfile) {
        DetectorFactory.loadProfile("language_detect");
        isLoadLanguageProfile = true;
      }
      Detector detector = DetectorFactory.create();
      detector.append(title);
      lang = detector.detect();
    } catch (LangDetectException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    int type = 1;
View Full Code Here

    try {
      if (!isLoadLanguageProfile) {
        DetectorFactory.loadProfile("language_detect");
        isLoadLanguageProfile = true;
      }
      Detector detector = DetectorFactory.create();
      detector.append(title);
      lang = detector.detect();
    } catch (LangDetectException e) {
      e.printStackTrace();
    }
    int type = 1;
    if (lang.equalsIgnoreCase("en")) {
View Full Code Here

     */
    public String detect(ServiceContext srvContext, String input) throws Exception {
        if(!LanguageDetector.languageLevelSupported) {
            throw new Exception(LanguageDetector.upgradeMessage);
        }
        Detector detector = DetectorFactory.create();
        detector.append(input);
        String detectedLanguage = detector.detect()
        // this is to deal with zh-cn and zh-tw in languageprofiles. All other files have a 639-1 2-char filename.
        if(detectedLanguage.length() > 2) {
            detectedLanguage = detectedLanguage.substring(0, 2);
        }
        String iso639_2 = srvContext.getBean(IsoLanguagesMapper.class).iso639_1_to_iso639_2(detectedLanguage);
View Full Code Here

    try {
      if (!isLoadLanguageProfile) {
        DetectorFactory.loadProfile("language_detect");
        isLoadLanguageProfile = true;
      }
      Detector detector = DetectorFactory.create();
      detector.append(title);
      lang = detector.detect();
    } catch (LangDetectException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    int type = 1;
View Full Code Here

        DetectorFactory.loadProfile(profileDirectory);
    }
   
    // isLanguage("The quick brown fox.", "en")
    public boolean isLanguage(String text, String langAbbr) {
        Detector detector;
        boolean isLang = false;
        try {
            detector = DetectorFactory.create();
            detector.append(text);
            isLang = detector.detect().startsWith(langAbbr);
        } catch (LangDetectException e) {
            //System.out.println("Could not detect language on: " + text);
        }
       
       
View Full Code Here

        }
        return profiles;
    }
   
    public String getLanguage(String text) throws LangDetectException {
        Detector detector = DetectorFactory.create();
        detector.append(text);
        return detector.detect();
    }
View Full Code Here

TOP

Related Classes of com.cybozu.labs.langdetect.Detector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.