# Path: talon/signature/learning/featurespace.py
# def features(sender=''):
# def apply_features(body, features):
# def build_pattern(body, features):


from ... import *
from talon.signature.learning import featurespace as fs
# -*- coding: utf-8 -*-

from __future__ import absolute_import



def test_apply_features():
    s = '''This is John Doe

Tuesday @3pm suits. I'll chat to you then.

VP Research and Development, Xxxx Xxxx Xxxxx

555-226-2345

john@example.com'''
    sender = 'John <john@example.com>'
    features = fs.features(sender)
    result = fs.apply_features(s, features)
    # note that we don't consider the first line because signatures don't
    # usually take all the text, empty lines are not considered
    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],
                 [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
                 [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]])


# Path: talon/signature/learning/featurespace.py
# def features(sender=''):
# def apply_features(body, features):
# def build_pattern(body, features):


# Path: tests/signature/learning/featurespace_test.py
from ... import *
from talon.signature.learning import featurespace as fs

# -*- coding: utf-8 -*-

from __future__ import absolute_import



def test_apply_features():
    s = '''This is John Doe

Tuesday @3pm suits. I'll chat to you then.

VP Research and Development, Xxxx Xxxx Xxxxx

555-226-2345

john@example.com'''
    sender = 'John <john@example.com>'
    features = fs.features(sender)
    result = fs.apply_features(s, features)
    # note that we don't consider the first line because signatures don't
    # usually take all the text, empty lines are not considered
    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],
                 [0, 0, 0, 0, 1, 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', 5):