From 765b897bf652c5ac4e9c32986844ec2c90a68654 Mon Sep 17 00:00:00 2001 From: aitordiaz Date: Mon, 13 Sep 2021 14:34:45 +0200 Subject: [PATCH] Fix output --- CHANGELOG.rst | 7 ++++- setup.cfg | 2 +- setup.py | 2 +- src/rantanplan/__init__.py | 2 +- src/rantanplan/core.py | 6 ++-- tests/fixtures/haiku.json | 18 +++++++++-- tests/fixtures/scansion_sonnet.json | 6 +++- tests/fixtures/sonnet.json | 48 ++++++++++++++++++++++++----- 8 files changed, 73 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index aa92a45..46ed198 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,7 +3,12 @@ Changelog ========= -0.7.0 (2021-01-28) +0.7.1 (2021-09-13) +------------------ + +* Fix output. + +0.7.0 (2021-09-13) ------------------ * Added option to generate a new output format, compliant with POSTDATA ontology. diff --git a/setup.cfg b/setup.cfg index e955e96..5e5a876 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.7.0 +current_version = 0.7.1 commit = True tag = True diff --git a/setup.py b/setup.py index c311ca7..626c36d 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ def read(*names, **kwargs): setup( name='rantanplan', - version='0.7.0', + version='0.7.1', license='Apache Software License 2.0', description='Scansion tool for Spanish texts', long_description='%s\n%s' % ( diff --git a/src/rantanplan/__init__.py b/src/rantanplan/__init__.py index 0af2655..96ccb21 100644 --- a/src/rantanplan/__init__.py +++ b/src/rantanplan/__init__.py @@ -1,2 +1,2 @@ -__version__ = '0.7.0' +__version__ = '0.7.1' from .core import get_scansion # noqa diff --git a/src/rantanplan/core.py b/src/rantanplan/core.py index 1e19f53..120fae9 100644 --- a/src/rantanplan/core.py +++ b/src/rantanplan/core.py @@ -843,7 +843,8 @@ def _get_scansion(text, rhyme_analysis=False, rhythm_format="pattern", break if not pos_output: remove_pos_from_output(lines) - scansion = remove_exact_length_matches(lines) + # scansion = remove_exact_length_matches(lines) + scansion = lines if alternative_output\ and split_stanzas_on is not None\ and rhyme_analysis\ @@ -1018,6 +1019,7 @@ def transform_scansion(scansion, text): new_line = copy.deepcopy(scheme["stanzaList"][0]["lineList"][0]) tokens, _, rhythm, structure, rhyme, ending, ending_stress, \ rhyme_type, rhyme_relaxation = [v for v in line.values()] + print(rhythm) phonological_list = [] for pg in line["phonological_groups"]: phonological_dict = copy.deepcopy( @@ -1087,7 +1089,7 @@ def transform_scansion(scansion, text): "ending": ending, "rhymeGrapheme": ending, "typeOfRhymeMatching": rhyme_type, - "endingStressedVowel": ending[ending_stress], + "endingStressedVowel": ending[ending_stress] if ending else None, }) new_line.update({ "relativeLineNumber": line_idx + 1, diff --git a/tests/fixtures/haiku.json b/tests/fixtures/haiku.json index 805849d..7d5854c 100644 --- a/tests/fixtures/haiku.json +++ b/tests/fixtures/haiku.json @@ -73,7 +73,11 @@ "rhythm": { "stress": "+--+-", "type": "pattern", - "length": 5 + "length": 5, + "length_range": { + "min_length": 5, + "max_length": 5 + } }, "structure": "haiku", "rhyme": "a", @@ -167,7 +171,11 @@ "rhythm": { "stress": "---+-+-", "type": "pattern", - "length": 7 + "length": 7, + "length_range": { + "min_length": 7, + "max_length": 7 + } }, "structure": "haiku", "rhyme": "a", @@ -248,7 +256,11 @@ "rhythm": { "stress": "-+-+-", "type": "pattern", - "length": 5 + "length": 5, + "length_range": { + "min_length": 5, + "max_length": 5 + } }, "structure": "haiku", "rhyme": "-", diff --git a/tests/fixtures/scansion_sonnet.json b/tests/fixtures/scansion_sonnet.json index db380c0..aa04a83 100644 --- a/tests/fixtures/scansion_sonnet.json +++ b/tests/fixtures/scansion_sonnet.json @@ -672,7 +672,11 @@ "rhythm": { "stress": "---+-+-", "type": "pattern", - "length": 7 + "length": 7, + "length_range": { + "min_length": 7, + "max_length": 7 + } }, "structure": "unknown", "rhyme": "-", diff --git a/tests/fixtures/sonnet.json b/tests/fixtures/sonnet.json index 57e78e1..8681ed6 100644 --- a/tests/fixtures/sonnet.json +++ b/tests/fixtures/sonnet.json @@ -134,7 +134,11 @@ "rhythm": { "stress": "-+-+-+---+-", "type": "pattern", - "length": 11 + "length": 11, + "length_range": { + "min_length": 11, + "max_length": 11 + } }, "structure": "sonnet", "rhyme": "a", @@ -287,7 +291,11 @@ "rhythm": { "stress": "-+---+-+-+-", "type": "pattern", - "length": 11 + "length": 11, + "length_range": { + "min_length": 11, + "max_length": 11 + } }, "structure": "sonnet", "rhyme": "b", @@ -626,7 +634,11 @@ "rhythm": { "stress": "-+-+-+---+-", "type": "pattern", - "length": 11 + "length": 11, + "length_range": { + "min_length": 11, + "max_length": 11 + } }, "structure": "sonnet", "rhyme": "a", @@ -786,7 +798,11 @@ "rhythm": { "stress": "+--+-+---+-", "type": "pattern", - "length": 11 + "length": 11, + "length_range": { + "min_length": 11, + "max_length": 11 + } }, "structure": "sonnet", "rhyme": "a", @@ -928,7 +944,11 @@ "rhythm": { "stress": "+--+---+-+-", "type": "pattern", - "length": 11 + "length": 11, + "length_range": { + "min_length": 11, + "max_length": 11 + } }, "structure": "sonnet", "rhyme": "b", @@ -1257,7 +1277,11 @@ "rhythm": { "stress": "---+-++--+-", "type": "pattern", - "length": 11 + "length": 11, + "length_range": { + "min_length": 11, + "max_length": 11 + } }, "structure": "sonnet", "rhyme": "a", @@ -1409,7 +1433,11 @@ "rhythm": { "stress": "-+-+-++--+-", "type": "pattern", - "length": 11 + "length": 11, + "length_range": { + "min_length": 11, + "max_length": 11 + } }, "structure": "sonnet", "rhyme": "c", @@ -2060,7 +2088,11 @@ "rhythm": { "stress": "--+--+---+-", "type": "pattern", - "length": 11 + "length": 11, + "length_range": { + "min_length": 11, + "max_length": 11 + } }, "structure": "sonnet", "rhyme": "c",