omrih1010 / language-detection

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

Singleton implementation of DetectorFactory prohibits Detectors using different profiles #35

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
First of all: thank you for making this software publicly available! I really 
appreciate it ;)

Now that you provide two different types of language profiles (based on 
wikipedia and twitter, respectively), I'd like to be able to keep two language 
detectors alive simultaneously. One relying on the twitter profiles for 
classifying short texts, and one relying on the wikipedia profiles for 
classifying long ones (this is somewhat related to issue 25). However, the 
current implementation of the DetectorFactory does not allow me to set up more 
than one type of Detector.

I'd like to be able to do something similar to the following (where 
detectorShort and detectorLong would use language profiles for (approximately) 
the same languages, originating from different sources):

// set-up two different detectors
DetectorFactory.loadProfiles(LanguageProfile.SHORT_TEXTS, 
"/path/to/shorttextprofiles");
DetectorFactory.loadProfiles(LanguageProfile.LONG_TEXTS, 
"/path/to/longtextprofiles");

...

// get the detector for handling short texts
Detector detectorShort = DetectorFactory.create(LanguageProfile.SHORT_TEXTS);

// get the detector for handling longer texts
Detector detectorLong = DetectorFactory.create(LanguageProfile.LONG_TEXTS);

...

Is this behaviour something you would consider in a future release?

Kind regards

Original issue reported on code.google.com by fredrik....@gmail.com on 15 Mar 2012 at 6:44

GoogleCodeExporter commented 8 years ago
DetectorFactory.loadProfiles() should return an instance instead of putting 
everything into static variables.

Original comment by t.br...@talkwalker.com on 19 Mar 2012 at 11:45