Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -16,7 +16,7 @@ from talon.signature.constants import SIGNATURE_MAX_LINES
|
|||||||
|
|
||||||
rc = re.compile
|
rc = re.compile
|
||||||
|
|
||||||
RE_EMAIL = rc('@')
|
RE_EMAIL = rc('\S@\S')
|
||||||
RE_RELAX_PHONE = rc('(\(? ?[\d]{2,3} ?\)?.{,3}?){2,}')
|
RE_RELAX_PHONE = rc('(\(? ?[\d]{2,3} ?\)?.{,3}?){2,}')
|
||||||
RE_URL = rc(r'''https?://|www\.[\S]+\.[\S]''')
|
RE_URL = rc(r'''https?://|www\.[\S]+\.[\S]''')
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ def contains_sender_names(sender):
|
|||||||
names = names or sender
|
names = names or sender
|
||||||
if names != '':
|
if names != '':
|
||||||
return binary_regex_search(re.compile(names))
|
return binary_regex_search(re.compile(names))
|
||||||
return lambda s: False
|
return lambda s: 0
|
||||||
|
|
||||||
|
|
||||||
def extract_names(sender):
|
def extract_names(sender):
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ from talon.signature.learning import featurespace as fs
|
|||||||
|
|
||||||
|
|
||||||
def test_apply_features():
|
def test_apply_features():
|
||||||
s = '''John Doe
|
s = '''This is John Doe
|
||||||
|
|
||||||
|
Tuesday @3pm suits. I'll chat to you then.
|
||||||
|
|
||||||
VP Research and Development, Xxxx Xxxx Xxxxx
|
VP Research and Development, Xxxx Xxxx Xxxxx
|
||||||
|
|
||||||
@@ -19,11 +21,12 @@ john@example.com'''
|
|||||||
# note that we don't consider the first line because signatures don't
|
# note that we don't consider the first line because signatures don't
|
||||||
# usually take all the text, empty lines are not considered
|
# usually take all the text, empty lines are not considered
|
||||||
eq_(result, [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
|
eq_(result, [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
|
||||||
|
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
|
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
|
||||||
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]])
|
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]])
|
||||||
|
|
||||||
with patch.object(fs, 'SIGNATURE_MAX_LINES', 4):
|
with patch.object(fs, 'SIGNATURE_MAX_LINES', 5):
|
||||||
features = fs.features(sender)
|
features = fs.features(sender)
|
||||||
new_result = fs.apply_features(s, features)
|
new_result = fs.apply_features(s, features)
|
||||||
# result remains the same because we don't consider empty lines
|
# result remains the same because we don't consider empty lines
|
||||||
|
|||||||
Reference in New Issue
Block a user