Mimino666 / langdetect

Port of Google's language-detection library to Python.
Other
1.71k stars 196 forks source link

LangDetectException - 'Need to load profiles.' #65

Open edsvisinditus opened 4 years ago

edsvisinditus commented 4 years ago

Hi,

I sometimes get a LangDetectException which tells me: 'Need to load profiles.'

Is there a way to check if all languages have been loaded before calling the detect method?

Thank you in advance.

jinalpanchall commented 3 years ago

I ma having the same issue. Let me know how you resolve it

CodeMazeSolver commented 1 year ago

Hi there, seems to be an issue still. I'm also running into the same problem. Is there already a solution to check if the profiles have been loaded before calling the detect method?

Bild_2022-12-15_092316571

Guust-Franssens commented 1 year ago

same issue, any updates?

mherkhachatryan commented 10 months ago

Same issue here, any update?

dongZheX commented 9 months ago

For me, this issue may be caused by the use of a multi-process program. If "detect" function is executed in multiple threads before _factory is properly initialized, it will cause _factory to not be properly initialized.

The solution is to execute a detect operation during the formal multi-threaded request.

Alternatively, add a thread lock in init_factory to ensure that only one thread is executing init_factory.

anjifenjou commented 9 months ago

@dongZheX can you show a code snippet of your proposed solution please?

dongZheX commented 9 months ago

"If you are experiencing initialization failure due to multiprocessing, the simplest solution is to run langtect.detect(xxx) once before running the multiprocessing program."

---- Replied Message ---- | From | Ahmed @.> | | Date | 12/07/2023 18:12 | | To | Mimino666/langdetect @.> | | Cc | dongZheX @.>, Mention @.> | | Subject | Re: [Mimino666/langdetect] LangDetectException - 'Need to load profiles.' (#65) |

@dongZheX can you show a code snippet of your proposed solution please?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

anjifenjou commented 9 months ago

My solution was to move to lingua-py which is most faster, more accurate on some languages (cf #51 #109 #9) and offer built-in parallel alternatives