[text] Adding utils.py for is_numeric/is_numeric_strict

This commit is contained in:
Al
2016-07-24 03:37:11 -04:00
parent a620cae6e0
commit 7b3f4e9175

View File

@@ -0,0 +1,12 @@
from geodata.text.tokenize import tokenize
from geodata.text.token_types import token_types
def is_numeric(s):
tokens = tokenize(s)
return sum((1 for t, c in tokens if c in token_types.NUMERIC_TOKEN_TYPES)) == len(tokens)
def is_numeric_strict(s):
tokens = tokenize(s)
return sum((1 for t, c in tokens if c == token_types.NUMERIC)) == len(tokens)