From 0a2cac642aceeef2b7357e74ca8903fedfcbd93f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Cl=C3=A9rice?= Date: Thu, 2 Nov 2017 16:10:00 +0100 Subject: [PATCH] Refactored Manfred-named class into Clauss-named class before publication --- README.md | 4 +-- chetc/configs/__init__.py | 2 +- chetc/configs/base.py | 2 +- chetc/configs/{manfred.py => clauss.py} | 32 +++++++++---------- chetc/converter.py | 4 +-- ...test_manfred_now.py => test_Clauss_now.py} | 6 ++-- ...st_manfred_now.txt => test_Clauss_now.txt} | 5 ++- ...anfred_wordid.py => test_Clauss_wordid.py} | 2 +- ...fred_wordid.txt => test_Clauss_wordid.txt} | 0 9 files changed, 30 insertions(+), 27 deletions(-) rename chetc/configs/{manfred.py => clauss.py} (78%) rename tests/{test_manfred_now.py => test_Clauss_now.py} (80%) rename tests/{test_manfred_now.txt => test_Clauss_now.txt} (88%) rename tests/{test_manfred_wordid.py => test_Clauss_wordid.py} (94%) rename tests/{test_manfred_wordid.txt => test_Clauss_wordid.txt} (100%) diff --git a/README.md b/README.md index 42b5212..4944b0e 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,10 @@ To use ETC.py, you need to create a converter instance and configure it with a C ```python from chetc import Converter -from chetc.configs import Manfred +from chetc.configs import Clauss # We initialize a converter and disable the word tagging and numbering -converter = Converter(replacement_model=Manfred(word_numbering=False)) +converter = Converter(replacement_model=Clauss(word_numbering=False)) # We run a single transformation and print it print(converter.convert("Sittium a[e]d(ilem) [o(ro) v(os)] f(aciatis)")) ``` diff --git a/chetc/configs/__init__.py b/chetc/configs/__init__.py index 0354d83..79f3b59 100644 --- a/chetc/configs/__init__.py +++ b/chetc/configs/__init__.py @@ -1 +1 @@ -from .manfred import Manfred +from .clauss import Clauss diff --git a/chetc/configs/base.py b/chetc/configs/base.py index a349f86..0fd0d4c 100644 --- a/chetc/configs/base.py +++ b/chetc/configs/base.py @@ -1,5 +1,5 @@ class ConverterReplacementModel: - """ Conversion class for the Manfred database + """ Conversion class for the Clauss database :param word_numbering: Includes a word number every time a new word is found :type word_numbering: bool diff --git a/chetc/configs/manfred.py b/chetc/configs/clauss.py similarity index 78% rename from chetc/configs/manfred.py rename to chetc/configs/clauss.py index 03e49b1..e752f47 100644 --- a/chetc/configs/manfred.py +++ b/chetc/configs/clauss.py @@ -2,8 +2,8 @@ from .base import ConverterReplacementModel -class Manfred(ConverterReplacementModel): - """ Conversion class for the Manfred database +class Clauss(ConverterReplacementModel): + """ Conversion class for the Clauss database :param word_numbering: Includes a word number every time a new word is found :type word_numbering: bool @@ -25,9 +25,9 @@ def replacements(self): ("(\[\s*\/)", "[?] /"), # When a line ends with a provided character and an unknown loss - ("(\[("+Manfred.word_matcher_regularization+"*)\s*\/)", + ("(\[(" + Clauss.word_matcher_regularization + "*)\s*\/)", "[$1] [?] /"), - ("\[("+Manfred.word_matcher_regularization+"+)\s*$", + ("\[(" + Clauss.word_matcher_regularization + "+)\s*$", "[$1] [?]"), # When a line starts with an unknown content @@ -35,17 +35,17 @@ def replacements(self): '/ [?]'), # When a line starts with a provided character and an unknown content - ('(\/\s*('+Manfred.word_matcher_regularization+'*)\])', + ('(\/\s*(' + Clauss.word_matcher_regularization + '*)\])', '/ [?] [$1]'), - ('^(\s*('+Manfred.word_matcher_regularization+'*)\])', + ('^(\s*(' + Clauss.word_matcher_regularization + '*)\])', '[?] [$1]'), # When two words are spanning inside the same provided lacuna : [abc(ade!) abc(e)x(z!)] - ('\[('+Manfred.word_matcher_regularization+'+) ('+Manfred.word_matcher_regularization+'+)\]', + ('\[(' + Clauss.word_matcher_regularization + '+) (' + Clauss.word_matcher_regularization + '+)\]', '[$1] [$2]'), # When three words are spanning inside the same provided lacuna : [abc(ade!) abc(e)x(z!) abc(e)x(z!)] - ('\[('+Manfred.word_matcher_regularization+'+) ('+Manfred.word_matcher_regularization+'+) ('+Manfred.word_matcher_regularization+'+)\]', + ('\[(' + Clauss.word_matcher_regularization + '+) (' + Clauss.word_matcher_regularization + '+) (' + Clauss.word_matcher_regularization + '+)\]', '[$1] [$2] [$3]'), # Replace angular bracket by curved bracked @@ -102,7 +102,7 @@ def replacements(self): ########################################## # Abbreviation inside Parentheses, even with supplied inside - ("\[("+Manfred.word_matcher_plus_square_brkcts+"*)\((\w+)\)("+Manfred.word_matcher_plus_square_brkcts+"*)\]", + ("\[(" + Clauss.word_matcher_plus_square_brkcts + "*)\((\w+)\)(" + Clauss.word_matcher_plus_square_brkcts + "*)\]", "$1$2$3"), ########################################## @@ -110,15 +110,15 @@ def replacements(self): ########################################## # Parentheses, even with supplied inside - ("("+Manfred.word_matcher_plus_square_brkcts+"*)\((\w+)\)("+Manfred.word_matcher_plus_square_brkcts+"*)", + ("(" + Clauss.word_matcher_plus_square_brkcts + "*)\((\w+)\)(" + Clauss.word_matcher_plus_square_brkcts + "*)", "$1$2$3"), # Parentheses with uncertain - ("("+Manfred.word_matcher_plus_square_brkcts+"*)\((\w+)(?:(?:\?)|(?:\(\?\)))\)("+Manfred.word_matcher_plus_square_brkcts+"*)", + ("(" + Clauss.word_matcher_plus_square_brkcts + "*)\((\w+)(?:(?:\?)|(?:\(\?\)))\)(" + Clauss.word_matcher_plus_square_brkcts + "*)", "$1$2$3"), # Parentheses with unextented parentheses - ("("+Manfred.word_matcher_plus_square_brkcts+"*)\(\)("+Manfred.word_matcher_plus_square_brkcts+"*)", + ("(" + Clauss.word_matcher_plus_square_brkcts + "*)\(\)(" + Clauss.word_matcher_plus_square_brkcts + "*)", "$1$2"), ########################################## @@ -140,15 +140,15 @@ def replacements(self): ''), # When we supply an uncertain replacement - ("\[(" + Manfred.word_matcher_regularization + "+)\?\]", + ("\[(" + Clauss.word_matcher_regularization + "+)\?\]", '$1'), - ("\[(" + Manfred.word_matcher_regularization + "+)\(\?\)\]", + ("\[(" + Clauss.word_matcher_regularization + "+)\(\?\)\]", '$1'), - ("(\w*)\[(" + Manfred.word_matcher_regularization + "+)\](\w*)\(\?\)", + ("(\w*)\[(" + Clauss.word_matcher_regularization + "+)\](\w*)\(\?\)", '$1$2$3'), # When we supply a replacement - ("\[("+Manfred.word_matcher_regularization+"+)\]", + ("\[(" + Clauss.word_matcher_regularization + "+)\]", '$1'), ########################################## diff --git a/chetc/converter.py b/chetc/converter.py index 00dc318..bc12cf7 100644 --- a/chetc/converter.py +++ b/chetc/converter.py @@ -1,4 +1,4 @@ -from .configs import Manfred +from .configs import Clauss import re @@ -22,7 +22,7 @@ class Converter(object): def __init__(self, replacement_model=None): if replacement_model is None: - self.__replacement_model__ = Manfred() + self.__replacement_model__ = Clauss() else: self.__replacement_model__ = replacement_model self.lineNum = 0 diff --git a/tests/test_manfred_now.py b/tests/test_Clauss_now.py similarity index 80% rename from tests/test_manfred_now.py rename to tests/test_Clauss_now.py index ae05f75..64d514a 100644 --- a/tests/test_manfred_now.py +++ b/tests/test_Clauss_now.py @@ -1,15 +1,15 @@ from chetc import Converter from unittest import TestCase import os -from chetc.configs import Manfred +from chetc.configs import Clauss class TestClauss(TestCase): def setUp(self): - with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_manfred_now.txt")) as f: + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_Clauss_now.txt")) as f: lines = [x for x in f.readlines()] self.tests_strings = zip(*[lines[i::3] for i in range(3)]) - self.converter = Converter(replacement_model=Manfred(word_numbering=False)) + self.converter = Converter(replacement_model=Clauss(word_numbering=False)) self.debug = False self.maxDiff = 50000 diff --git a/tests/test_manfred_now.txt b/tests/test_Clauss_now.txt similarity index 88% rename from tests/test_manfred_now.txt rename to tests/test_Clauss_now.txt index 5069010..d6b4b33 100644 --- a/tests/test_manfred_now.txt +++ b/tests/test_Clauss_now.txt @@ -3,4 +3,7 @@ C(aio) Iulio Caesare dict(atore) iter(um) / M(arco) Antonio mag(istro) eq(uitum) Caio Iulio Caesare dictatore iterum Marco Antonio magistro equitum magistri vici et compiti Marcus Blattius Marci filius Marcus Cerrinius Marci filius Marcus Sepullius Quintus Pra Caius Cornelius Publius Rocius s Salvius Ero Marci servus Caio Caes]are Marco Lepido consulibus Blattius Marci filius Caius Hermatorius Publi filius Marcus ius Marci filius Plutus Marcus Stronnius Marci libertus Nico Marcus Oppius Sexti libertus Aeschines Caius Cepidius Cai libertus CIL 04, 00131 Sittium a[e]d(ilem) [o(ro) v(os)] f(aciatis) -Sittium aedilem oro vos faciatis \ No newline at end of file +Sittium aedilem oro vos faciatis +http://db.edcs.eu/epigr/edcs_id.php?s_sprache=en&p_edcs_id=EDCS-25800673 +[3] Aqutium [3] / d(uum)v(irum) v(irum) [b(onum)] + Aqutium duumvirum virum bonum \ No newline at end of file diff --git a/tests/test_manfred_wordid.py b/tests/test_Clauss_wordid.py similarity index 94% rename from tests/test_manfred_wordid.py rename to tests/test_Clauss_wordid.py index 81becdc..6349076 100644 --- a/tests/test_manfred_wordid.py +++ b/tests/test_Clauss_wordid.py @@ -5,7 +5,7 @@ class TestClauss(TestCase): def setUp(self): - with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_manfred_wordid.txt")) as f: + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_Clauss_wordid.txt")) as f: lines = [x for x in f.readlines()] self.tests_strings = zip(*[lines[i::3] for i in range(3)]) self.converter = Converter() diff --git a/tests/test_manfred_wordid.txt b/tests/test_Clauss_wordid.txt similarity index 100% rename from tests/test_manfred_wordid.txt rename to tests/test_Clauss_wordid.txt