Skip to content

Commit

Permalink
FormFieldClassifier.form_classes and FormFieldClassifier.field_classes
Browse files Browse the repository at this point in the history
  • Loading branch information
kmike committed Feb 9, 2016
1 parent 5b5086c commit e5a7b09
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions formasaurus/classifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ def _cached_model_path(cls):
path = "formasaurus-%s.joblib" % dependencies_string()
return at_root(path)

@property
def form_classes(self):
""" Possible form classes """
return self.form_classifier.classes

@property
def field_classes(self):
""" Possible field classes """
return self._field_model.classes_


class FormClassifier(object):
"""
Expand Down
6 changes: 6 additions & 0 deletions tests/test_classifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ def test_extract_forms_no_fields_direct(tree):
assert forms[0][1] == 'login'


def test_classes():
ex = classifiers.get_instance()
assert 'registration' in ex.form_classes
assert 'password' in ex.field_classes


@pytest.mark.parametrize(['fields'], [[True], [False]])
def test_extract_forms_proba(tree, fields):
forms = formasaurus.extract_forms(tree, proba=True, threshold=0, fields=fields)
Expand Down

0 comments on commit e5a7b09

Please sign in to comment.