omrih1010 / language-detection

Automatically exported from code.google.com/p/language-detection
0 stars 0 forks source link

Duplicate the same Language Profile #19

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What is the expected output? What do you see instead?
Expected output is the name of the detected language but I am getting 
com.cybozu.labs.langdetect.LangDetectException: duplicate the same language 
profile

What version of the product are you using? On what operating system?
The latest one on ubuntu

Original issue reported on code.google.com by mail2gau...@gmail.com on 6 Jun 2011 at 8:19

GoogleCodeExporter commented 8 years ago
As the message mentioned, the same profile was loaded doubly.
Did it call DetectorFactory.loadProfile() twice?

Original comment by nakatani.shuyo on 7 Jun 2011 at 6:38

GoogleCodeExporter commented 8 years ago
Hello,

I have the same problem when i call the detectLanguage function more than one 
time
public static String getTextLang(String text) throws LangDetectException{           
             DetectorFactory.loadProfile(LANGUAGEPROFILE);
             Detector detector = DetectorFactory.create();
                     detector.append(text);

                      return detector.detect();
                }

any solution?

Original comment by Mustafa....@googlemail.com on 28 Sep 2011 at 8:19

GoogleCodeExporter commented 8 years ago
I had same issue n following code worked for me.
       DetectorFactory.loadProfile("your/path/to/profiles");
       Detector detector = DetectorFactory.create();
       detector.append("قال الرئيس اليمني علي عبد الله صالح إنه سيتنحى بعد ");
       System.out.println("lang is "+detector.detect());
       detector = DetectorFactory.create();
       detector.append("hallo world");
       System.out.println("lang is "+detector.detect());
output will be like
ar
en

Make sure 2 things 
1) profiles are loaded once 
2) u recreate detector = DetectorFactory.create(); for each language detection 
otherwise it will return language of 1st creaded detector.

Original comment by ali.shan...@gmail.com on 18 Nov 2011 at 4:00

GoogleCodeExporter commented 8 years ago
Sorry, I missed This comment.
You can detect multiplely as Comment 3. Very Thanks!

Original comment by nakatani.shuyo on 22 Nov 2011 at 5:28