diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 111680f..9773ba4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,11 +3,6 @@ stages: - test - lint -build:python3.5: - image: python:3.5 - stage: build - script: python setup.py -q install - build:python3.6: image: python:3.6 stage: build @@ -18,11 +13,6 @@ build:python3.7: stage: build script: python setup.py -q install -test:python3.5: - image: python:3.5 - stage: test - script: pip install pytest pytest-cov && python -m pytest --cov=pyfn tests/ - test:python3.6: image: python:3.6 stage: test @@ -33,11 +23,6 @@ test:python3.7: stage: test script: pip install pytest pytest-cov && python -m pytest --cov=pyfn tests/ -lint:python3.5: - image: python:3.5 - stage: lint - script: pip install pylint && pylint pyfn - lint:python3.6: image: python:3.6 stage: lint @@ -48,17 +33,3 @@ lint:python3.7: stage: lint script: pip install pylint && pylint pyfn -docstyle:python3.5: - image: python:3.5 - stage: lint - script: pip install pydocstyle && pydocstyle pyfn - -docstyle:python3.6: - image: python:3.6 - stage: lint - script: pip install pydocstyle && pydocstyle pyfn - -docstyle:python3.7: - image: python:3.7 - stage: lint - script: pip install pydocstyle && pydocstyle pyfn diff --git a/README.md b/README.md index ccb75db..f82b79e 100644 --- a/README.md +++ b/README.md @@ -208,19 +208,19 @@ parser, please create an [issue](https://github.com/akb89/pyfn/issues) on Github To run the preprocessing and frame semantic parsing scripts, first download: - `data.7z` containing all the FrameNet splits for FN 1.5 and FN 1.7 ```shell -wget http://129.194.21.122/~kabbach/pyfn/data.7z +wget backup.3azouz.net/pyfn/data.7z ``` - `lib.7z` containing all the different external softwares (taggers, parsers, etc.) ```shell -wget http://129.194.21.122/~kabbach/pyfn/lib.7z +wget backup.3azouz.net/pyfn/lib.7z ``` - `resources.7z` containing all the required resources ```shell -wget http://129.194.21.122/~kabbach/pyfn/resources.7z +wget backup.3azouz.net/pyfn/resources.7z ``` - `scripts.7z` containing the set of bash scripts to call the different parsers and preprocessing toolkits ```shell -wget http://129.194.21.122/~kabbach/pyfn/scripts.7z +wget backup.3azouz.net/pyfn/scripts.7z ``` Extract the content of all the archives under a diff --git a/pyfn/marshalling/marshallers/semafor.py b/pyfn/marshalling/marshallers/semafor.py index 0777b88..661e9bd 100644 --- a/pyfn/marshalling/marshallers/semafor.py +++ b/pyfn/marshalling/marshallers/semafor.py @@ -32,10 +32,9 @@ def _get_token_num(index, text): if char.isspace(): prev_char_is_whitespace = True continue - else: - if prev_char_is_whitespace: - token_num += 1 - prev_char_is_whitespace = False + if prev_char_is_whitespace: + token_num += 1 + prev_char_is_whitespace = False if char_index == index: return token_num raise Exception('Could not determine token number for char index ' diff --git a/pyfn/marshalling/unmarshallers/bios.py b/pyfn/marshalling/unmarshallers/bios.py index 4f6582c..8796235 100644 --- a/pyfn/marshalling/unmarshallers/bios.py +++ b/pyfn/marshalling/unmarshallers/bios.py @@ -53,9 +53,8 @@ def _get_labelstore(lines, tokens, text, labelstore): label.end = marsh_utils.get_end_index( int(iline_split[0])-1, tokens, text) continue - else: - labelstore.labels.append(label) - return _get_labelstore(lines[lines.index(iline):], + labelstore.labels.append(label) + return _get_labelstore(lines[lines.index(iline):], tokens, text, labelstore) labelstore.labels.append(label) return labelstore diff --git a/pyfn/marshalling/unmarshallers/framenet.py b/pyfn/marshalling/unmarshallers/framenet.py index 3abf952..4f965a2 100644 --- a/pyfn/marshalling/unmarshallers/framenet.py +++ b/pyfn/marshalling/unmarshallers/framenet.py @@ -280,7 +280,7 @@ def _unmarshall_fulltext_xml(xml_file_path, fe_dict, flatten=False): const.FN_XML_NAMESPACE)) except XMLProcessingError as err: raise XMLProcessingError('Could not process XML file: {}. Cause: {}' - .format(xml_file_path, str(err))) + .format(xml_file_path, str(err))) from err sentence_tags = root.findall('fn:sentence', const.FN_XML_NAMESPACE) for sentence_tag in sentence_tags: annosets = extract_fn_annosets( @@ -385,7 +385,7 @@ def _get_fe_dict(frame_xml_filepaths): fe_dict[frame_element._id] = frame_element except XMLProcessingError as err: raise XMLProcessingError('Could not process XML file: {}. Cause: {}' - .format(frame_xml_filepath, str(err))) + .format(frame_xml_filepath, str(err)))from err return fe_dict @@ -506,5 +506,5 @@ def extract_relations(fr_relation_xml_filepath): fe_relations.append(fe_relation) except XMLProcessingError as err: raise XMLProcessingError('Could not process XML file: {}. Cause: {}' - .format(fr_relation_xml_filepath, str(err))) + .format(fr_relation_xml_filepath, str(err))) from err return frame_relations, fe_relations diff --git a/setup.py b/setup.py index fb01b18..820d7d7 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ author_email='akb@3azouz.net', long_description=long_description, long_description_content_type='text/markdown', - version='1.3.7', + version='1.3.11', url='https://gitlab.com/akb89/pyfn', download_url='https://pypi.org/project/pyfn/#files', license='MIT', @@ -48,7 +48,6 @@ 'License :: OSI Approved :: MIT License', 'Natural Language :: English', 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Topic :: Scientific/Engineering :: Artificial Intelligence', diff --git a/tests/test_utils_immutables.py b/tests/test_utils_immutables.py deleted file mode 100644 index 7a65e5c..0000000 --- a/tests/test_utils_immutables.py +++ /dev/null @@ -1,65 +0,0 @@ -"""Tests for utils.immutables.""" - -import pytest - -from pyfn.utils.immutables import FrozenDict -from pyfn.utils.immutables import ImmutableConfig - -from pyfn.exceptions.method import InvalidMethodError -from pyfn.exceptions.parameter import InvalidParameterError - - -def test_frozen_dict(): - """Test that assigning a value to a frozen dict raises an - InvalidMethodError.""" - mutable_dict = {'key': 'I can assign a value to a mutable dict'} - assert mutable_dict['key'] == 'I can assign a value to a mutable dict' - frozen_dict = FrozenDict(mutable_dict) - with pytest.raises(InvalidMethodError, message='Cannot assign value to a\ - FrozenDict'): - frozen_dict['key'] = 'Raise an error as a frozen dict is immutable' - - -def test_immutable_config_exception_string(): - """Test that passing a string to ImmutableConfig raises an - InvalidParameterError. - """ - dict_config = {'key': 'value'} - ImmutableConfig(dict_config) - string_config = 'key: value' - with pytest.raises(InvalidParameterError, message='ImmutableConfig requires\ - an instance of a dict as\ - input parameter'): - ImmutableConfig(string_config) - - -def test_immutable_config_exception_list(): - """Test that passing a list to ImmutableConfig raises an - InvalidParameterError. - """ - dict_config = {'key': 'value'} - ImmutableConfig(dict_config) - list_config = ['key', 'value'] - with pytest.raises(InvalidParameterError, message='ImmutableConfig requires\ - an instance of a dict as\ - input parameter'): - ImmutableConfig(list_config) - - -def test_immutable_config(): - """Test that ImmutableConfig returns a FrozenDict (of FrozenDict(s)).""" - mutable_config = {'key1': {'key2': {'key3': 'value1'}}, 'key4': 'value2'} - immutable_config = ImmutableConfig(mutable_config) - print(immutable_config) - assert _contains_only_frozen_dict(immutable_config) - - -def _contains_only_frozen_dict(input_dict): - if not isinstance(input_dict, FrozenDict): - return False - results = [] - for key in input_dict: - value = input_dict[key] - if isinstance(value, dict): - results.append(_contains_only_frozen_dict(value)) - return False if False in results else True