lexnlp.tests package

Submodules

lexnlp.tests.dictionary_comparer module

class lexnlp.tests.dictionary_comparer.DictionaryComparer(check_order: bool = True, allow_extra_key: bool = False, number_precision_percent: float = 0.001)

Bases: object

check_dicts_equal(expected: dict, actual: dict) → List[str]
compare_list_of_dicts(expected: List[dict], actual: List[dict]) → List[str]

lexnlp.tests.lexnlp_tests module

lexnlp.tests.typed_annotations_tests module

class lexnlp.tests.typed_annotations_tests.ParsingError(**kwargs)

Bases: object

class lexnlp.tests.typed_annotations_tests.TypedAnnotationsTester(**kwargs)

Bases: object

check_case_annotations(ants: List[lexnlp.extract.common.annotations.text_annotation.TextAnnotation], case: lexnlp.tests.typed_annotations_tests.TypedAntTestCase, case_index: int)
process_cases() → Tuple[int, int]
process_file()
process_one_check(ant: lexnlp.extract.common.annotations.text_annotation.TextAnnotation, check: lexnlp.tests.typed_annotations_tests.TypedFieldCheck, case_index: int, check_index: int) → None
read_cases()
Sample file contains:

1.11.SCADA System means a supervisory control and data acquisition system such as the S/3 Software or Licensee’s OASyS(R) product. ——– total=1 0)locale=”en” 0)trademark=”OASyS (R)”

test_and_raise_errors(parsing_method: Callable, file_name: str, entity_type: Type)
test_parser(parsing_method: Callable, file_name: str, entity_type: Type)
class lexnlp.tests.typed_annotations_tests.TypedAntTestCase

Bases: object

is_completed
class lexnlp.tests.typed_annotations_tests.TypedFieldCheck(index: int = 0, path: List[str] = None, value: str = '', comparison: str = '=', check_all: bool = False)

Bases: object

Class is used to check one annotation’s attribute against provided value E.g., “0)date.month<6” means:

  • check first annotation within the sample
  • check that annotation’s month value strictly less than 6
or “..)coords.1>0” means:
  • check that coords[1] > 0 for all (..) annotations in this sample
compare_values(val: Any) → Tuple[bool, bool]
comparison_name = {'!=': 'not equal to', '<': 'less than', '<=': 'less or equal to', '=': 'equal to', '>': 'greater than', '>=': 'greater or equal to'}
comparison_string
date_formats = ['%Y.%m.%d', '%Y-%m-%d']
datetime_formats = ['%Y.%m.%d %H:%M:%S', '%Y-%m-%d %H:%M:%S', '%Y.%m.%d %H:%M', '%Y-%m-%d %H:%M']
get_ant_field_value(ant: lexnlp.extract.common.annotations.text_annotation.TextAnnotation) → Any
static parse(line: str)
parse_date(val_type: Type) → datetime.date
path_string
reg_compare_split = regex.Regex('!=|<=|>=|=|<|>', flags=regex.V0)

lexnlp.tests.upload_benchmarks module

lexnlp.tests.utility_for_testing module

lexnlp.tests.utility_for_testing.annotate_text(text: str, annotations: List[lexnlp.extract.common.annotations.text_annotation.TextAnnotation]) → str
Parameters:
  • text – source text
  • annotations – text annotations
Returns:

html, where annotations are replaced by HREFs + annotations’ list in the end of the document

lexnlp.tests.utility_for_testing.load_resource_document(doc_path: str, encoding: str = 'ascii') → str

load file as string from test_data folder

lexnlp.tests.utility_for_testing.save_test_document(doc_path: str, text: str, encoding: str = 'utf-8') → None

saves text as a file in test_data folder

lexnlp.tests.values_comparer module

lexnlp.tests.values_comparer.values_look_equal(a, b) → bool

Module contents