Make sure like_email returns bool

This commit is contained in:
ines 2017-05-09 11:37:29 +02:00
parent ea60932e1b
commit a0b00624bb

View File

@ -69,6 +69,10 @@ def is_right_punct(text):
return text in right_punct return text in right_punct
def like_email(text):
return bool(_like_email(text))
def like_url(text): def like_url(text):
# We're looking for things that function in text like URLs. So, valid URL # We're looking for things that function in text like URLs. So, valid URL
# or not, anything they say http:// is going to be good. # or not, anything they say http:// is going to be good.
@ -131,9 +135,9 @@ LEX_ATTRS = {
attrs.IS_SPACE: lambda string: string.isspace(), attrs.IS_SPACE: lambda string: string.isspace(),
attrs.IS_TITLE: lambda string: string.istitle(), attrs.IS_TITLE: lambda string: string.istitle(),
attrs.IS_UPPER: lambda string: string.isupper(), attrs.IS_UPPER: lambda string: string.isupper(),
attrs.LIKE_EMAIL: lambda string: _like_email(string),
attrs.IS_STOP: lambda string: False, attrs.IS_STOP: lambda string: False,
attrs.IS_OOV: lambda string: True, attrs.IS_OOV: lambda string: True,
attrs.LIKE_EMAIL: like_email,
attrs.LIKE_NUM: like_num, attrs.LIKE_NUM: like_num,
attrs.IS_PUNCT: is_punct, attrs.IS_PUNCT: is_punct,
attrs.IS_ASCII: is_ascii, attrs.IS_ASCII: is_ascii,