ftyers / commonvoice-utils

Linguistic processing for Common Voice
GNU Affero General Public License v3.0
51 stars 14 forks source link

Feature Request: Please add "hasValidator" etc #37

Closed HarikalarKutusu closed 1 year ago

HarikalarKutusu commented 1 year ago

Currently commonvoice-utils returns a list of paths if you want to check if e.g. segmentation is supported by a language, thus you need to scan the list to get a result. Like:

import cvutils as cvu

cv: cvu.CV = cvu.CV()

lc = 'tr'
supported: bool = False

validator: cvu.Validator = cvu.Validator(lc)
tokeniser: cvu.Tokeniser = cvu.Tokeniser(lc)

for val in cv.validators():
    if lc == os.path.split(os.path.split(val)[0])[1]:
        supported = True

It would be very helpful to have utility functions like cvu.hasValidator(lc) or cvu.hasTokenizer(lc) which does the same out of the box.

ftyers commented 1 year ago

Hmm... at the moment it works like this:

import cvutils as cvu

cv: cvu.CV = cvu.CV()

print('tr' in cv.validators())
print('nhi' in cv.validators())
$ python3 /tmp/test.py
True
False

But we could definitely implement some utility functions too, they should probably go in __init__.py.

HarikalarKutusu commented 1 year ago

Hmm... at the moment it works like this:

Oh, of course :) Thanks...

ftyers commented 1 year ago

Can we close this?

HarikalarKutusu commented 1 year ago

Sure, thanks for the tip...