daltonfury42 / truecase

A python true casing utility that restores case information for texts
Apache License 2.0
87 stars 16 forks source link

Lazy load the TrueCaser() in __init__.py for faster import (-1s) #4

Closed louismartin closed 4 years ago

louismartin commented 4 years ago

Not instanciating the TrueCaser() in init.py at import decreases the import time of the library from 2s to 1s on my setup (the remaining second coming mostly from importing NLTK).

Now the TrueCaser is instanciated lazily at the first call to get_true_case. I checked that the get_true_case method still works correctly after the change.