Skip to content

Commit

Permalink
Refactored Manfred-named class into Clauss-named class before publica…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
PonteIneptique committed Nov 2, 2017
1 parent 88addcb commit 0a2cac6
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 27 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)"))
```
Expand Down
2 changes: 1 addition & 1 deletion chetc/configs/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .manfred import Manfred
from .clauss import Clauss
2 changes: 1 addition & 1 deletion chetc/configs/base.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
32 changes: 16 additions & 16 deletions chetc/configs/manfred.py → chetc/configs/clauss.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,27 +25,27 @@ 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
('(\/\s*\])',
'/ [?]'),

# 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
Expand Down Expand Up @@ -102,23 +102,23 @@ 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 + "*)\]",
"<supplied reason=\"lost\"><expan><abbr>$1</abbr><ex>$2</ex><abbr>$3</abbr></expan></supplied>"),

##########################################
# Parentheses
##########################################

# 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 + "*)",
"<expan><abbr>$1</abbr><ex>$2</ex><abbr>$3</abbr></expan>"),

# 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 + "*)",
"<expan><abbr>$1</abbr><ex cert=\"low\">$2</ex><abbr>$3</abbr></expan>"),

# 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 + "*)",
"<expan><abbr>$1</abbr><abbr>$2</abbr></expan>"),

##########################################
Expand All @@ -140,15 +140,15 @@ def replacements(self):
'<gap reason="lost" extent="$1" unit="character" cert="low"/>'),

# When we supply an uncertain replacement
("\[(" + Manfred.word_matcher_regularization + "+)\?\]",
("\[(" + Clauss.word_matcher_regularization + "+)\?\]",
'<supplied reason="lost" cert="low">$1</supplied>'),
("\[(" + Manfred.word_matcher_regularization + "+)\(\?\)\]",
("\[(" + Clauss.word_matcher_regularization + "+)\(\?\)\]",
'<supplied reason="lost" cert="low">$1</supplied>'),
("(\w*)\[(" + Manfred.word_matcher_regularization + "+)\](\w*)\(\?\)",
("(\w*)\[(" + Clauss.word_matcher_regularization + "+)\](\w*)\(\?\)",
'$1<supplied reason="lost" cert="low">$2</supplied>$3'),

# When we supply a replacement
("\[("+Manfred.word_matcher_regularization+"+)\]",
("\[(" + Clauss.word_matcher_regularization + "+)\]",
'<supplied reason="lost">$1</supplied>'),

##########################################
Expand Down
4 changes: 2 additions & 2 deletions chetc/converter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .configs import Manfred
from .configs import Clauss
import re


Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/test_manfred_now.py → tests/test_Clauss_now.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 4 additions & 1 deletion tests/test_manfred_now.txt → tests/test_Clauss_now.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ C(aio) Iulio Caesare dict(atore) iter(um) / M(arco) Antonio mag(istro) eq(uitum)
<lb n="1"/><expan><abbr>C</abbr><ex>aio</ex></expan> Iulio Caesare <expan><abbr>dict</abbr><ex>atore</ex></expan> <expan><abbr>iter</abbr><ex>um</ex></expan> <lb n="2"/> <expan><abbr>M</abbr><ex>arco</ex></expan> Antonio <expan><abbr>mag</abbr><ex>istro</ex></expan> <expan><abbr>eq</abbr><ex>uitum</ex></expan> <lb n="3"/> <expan><abbr>mag</abbr><ex>istri</ex></expan> vici et compiti <lb n="4"/> <expan><abbr>M</abbr><ex>arcus</ex></expan> Blattius <expan><abbr>M</abbr><ex>arci</ex></expan> <expan><abbr>f</abbr><ex>ilius</ex></expan> <lb n="5"/> <expan><abbr>M</abbr><ex>arcus</ex></expan> Cerrinius <expan><abbr>M</abbr><ex>arci</ex></expan> <expan><abbr>f</abbr><ex>ilius</ex></expan> <lb n="6"/> <expan><abbr>M</abbr><ex>arcus</ex></expan> Sepullius <gap reason="lost" extent="3" unit="character"/> <lb n="7"/> <gap reason="lost" extent="6" unit="character"/> <lb n="8"/> <expan><abbr>Q</abbr><ex>uintus</ex></expan> Pra<gap reason="lost" extent="3" unit="character"/> <lb n="9"/> <expan><abbr>C</abbr><ex>aius</ex></expan> Corne<supplied reason="lost">lius</supplied> <gap reason="lost" extent="3" unit="character"/> <lb n="10"/> <gap reason="lost" extent="6" unit="character"/> <lb n="11"/> <expan><abbr>P</abbr><ex>ublius</ex></expan> Ro<supplied reason="lost">c</supplied>ius <gap reason="lost" extent="3" unit="character"/>s <lb n="12"/> Salvius <expan><abbr>E<gap reason="lost" extent="3" unit="character"/>ro</abbr></expan> <expan><abbr>M</abbr><ex>arci</ex></expan> <expan><abbr>s</abbr><ex>ervus</ex></expan> <lb n="13"/><gap extent="unknown" reason="lost" unit="line" /> <expan><abbr>C</abbr><ex>aio</ex></expan> Caes]are <expan><abbr>M</abbr><ex>arco</ex></expan> Lepido <expan><abbr>co</abbr><ex>n</ex><abbr>s</abbr></expan><expan><ex>ulibus</ex></expan> <lb n="14"/> <gap reason="lost" extent="3" unit="character"/> Blattius <expan><abbr>M</abbr><ex>arci</ex></expan> <expan><abbr>f</abbr><ex>ilius</ex></expan> <lb n="15"/> <expan><abbr>C</abbr><ex>aius</ex></expan> <supplied reason="lost" cert="low">H</supplied>ermatorius <expan><abbr>P</abbr><ex>ubli</ex></expan> <expan><abbr>f</abbr><ex>ilius</ex></expan> <lb n="16"/> <expan><abbr>M</abbr><ex>arcus</ex></expan> <gap reason="lost" extent="3" unit="character"/>ius <expan><abbr>M</abbr><ex>arci</ex></expan> <expan><abbr>f</abbr><ex cert="low">ilius</ex></expan> Plutus <lb n="17"/> <expan><abbr>M</abbr><ex>arcus</ex></expan> Stronnius <expan><abbr>M</abbr><ex>arci</ex></expan> <expan><abbr>l</abbr><ex>ibertus</ex></expan> Nic<gap reason="lost" extent="3" unit="character"/>o <lb n="18"/> <expan><abbr>M</abbr><ex>arcus</ex></expan> Oppius <expan><abbr>S</abbr><ex>exti</ex></expan> <expan><abbr>l</abbr><ex>ibertus</ex></expan> Aes<supplied reason="lost" cert="low">chines</supplied> <expan><abbr>C</abbr><ex>aius</ex></expan> Cepidius <expan><abbr>C</abbr><ex>ai</ex></expan> <supplied reason="lost"><expan><abbr>l</abbr><ex>ibertus</ex></expan></supplied> <gap reason="lost" extent="unknown" unit="character"/>
CIL 04, 00131
Sittium a[e]d(ilem) [o(ro) v(os)] f(aciatis)
<lb n="1"/>Sittium <expan><abbr>a<supplied reason="lost">e</supplied>d</abbr><ex>ilem</ex></expan> <supplied reason="lost"><expan><abbr>o</abbr><ex>ro</ex></expan></supplied> <supplied reason="lost"><expan><abbr>v</abbr><ex>os</ex></expan></supplied> <expan><abbr>f</abbr><ex>aciatis</ex></expan>
<lb n="1"/>Sittium <expan><abbr>a<supplied reason="lost">e</supplied>d</abbr><ex>ilem</ex></expan> <supplied reason="lost"><expan><abbr>o</abbr><ex>ro</ex></expan></supplied> <supplied reason="lost"><expan><abbr>v</abbr><ex>os</ex></expan></supplied> <expan><abbr>f</abbr><ex>aciatis</ex></expan>
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)]
<lb n="1"/><gap reason="lost" extent="3" unit="character"/> Aqutium <gap reason="lost" extent="3" unit="character"/> <lb n="2"/> <expan><abbr>d</abbr><ex>uum</ex><abbr>v</abbr></expan><expan><ex>irum</ex></expan> <expan><abbr>v</abbr><ex>irum</ex></expan> <supplied reason="lost"><expan><abbr>b</abbr><ex>onum</ex></expan></supplied>
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
File renamed without changes.

0 comments on commit 0a2cac6

Please sign in to comment.