Loading allzweckmesser/import.py +2 −4 Original line number Diff line number Diff line Loading @@ -3,8 +3,7 @@ import argparse import sys import json from model import * def parse_args() -> argparse.Namespace: """Parse arguments from the commandline. Loading @@ -28,8 +27,7 @@ def json_from_file(filename:str)->list: return json.loads(json_file.read()) def build_verse_object(json_string:str): pass if __name__ == 'main': Loading allzweckmesser/model.py +36 −37 Original line number Diff line number Diff line Loading @@ -153,15 +153,15 @@ class Phenomenon: phenomenon = cls() if 'caused_by' in raw: cls.caused_by = raw['caused_by'] phenomenon.caused_by = raw['caused_by'] if 'overruled_by' in raw: cls.overruled_by = raw['overruled_by'] phenomenon.overruled_by = raw['overruled_by'] if 'chars' in raw: cls.chars = raw['chars'] phenomenon.chars = raw['chars'] if 'typus' in raw: cls.typus = raw['typus'] phenomenon.typus = raw['typus'] if 'omitted' in raw: cls.omitted = raw['omitted'] phenomenon.omitted = raw['omitted'] return phenomenon Loading @@ -172,13 +172,13 @@ class Phenomenon: if self.caused_by != None: features.update({'caused_by':self.caused_by}) if self.overruled_by != None: features.append({'overruled_by':self.overruled_by}) features.update({'overruled_by':self.overruled_by}) if self.chars != None: features.append({'chars':self.chars}) features.update({'chars':self.chars}) if self.typus != None: features.append({'typus':self.typus}) features.update({'typus':self.typus}) if self.omitted != None: features.append({'omitted':self.omitted}) features.update({'omitted':self.omitted}) return minimal(features) Loading Loading @@ -214,15 +214,15 @@ class MultisyllablePhenomenon(Phenomenon): phenomenon = cls(beginning, end) if 'caused_by' in raw: cls.caused_by = raw['caused_by'] phenomenon.caused_by = raw['caused_by'] if 'overruled_by' in raw: cls.overruled_by = raw['overruled_by'] phenomenon.overruled_by = raw['overruled_by'] if 'chars' in raw: cls.chars = raw['chars'] phenomenon.chars = raw['chars'] if 'typus' in raw: cls.typus = raw['typus'] phenomenon.typus = raw['typus'] if 'omitted' in raw: cls.omitted = raw['omitted'] phenomenon.omitted = raw['omitted'] return phenomenon Loading @@ -237,13 +237,13 @@ class MultisyllablePhenomenon(Phenomenon): if self.caused_by != None: features.update({'caused_by':self.caused_by}) if self.overruled_by != None: features.append({'overruled_by':self.overruled_by}) features.update({'overruled_by':self.overruled_by}) if self.chars != None: features.append({'chars':self.chars}) features.update({'chars':self.chars}) if self.typus != None: features.append({'typus':self.typus}) features.update({'typus':self.typus}) if self.omitted != None: features.append({'omitted':self.omitted}) features.update({'omitted':self.omitted}) return minimal(features) Loading Loading @@ -277,13 +277,14 @@ class Token: token = cls(text, span) if 'clitic' in raw: token.clitic = raw['clitic'] if 'syllables' in raw: token.syllables = list() for syllable in raw['syllables']: token.syllables.append(Syllable.from_json(syllable)) return token else: return token def to_dict(self): Loading @@ -292,7 +293,9 @@ class Token: features.update({'token':self.text}) features.update({'span':self.span}) features.update({'clitic':self.clitic}) features.update({'clitic':self.span}) if self.syllables: features.update({'syllables': [syllable.to_dict() for syllable in self.syllables]}) return minimal(features) Loading Loading @@ -360,13 +363,10 @@ class Reading: class Verse: def __init__(self, verse: str, author: str = None, work: str = None, place: str = None, readings: List[Reading] = list()): def __init__(self, verse: str, readings: List[Reading] = list(), source: dict = None): self.text = verse self.author = author self.work = work self.place = place self.source = source self.readings = readings @classmethod Loading @@ -381,10 +381,11 @@ class Verse: raw = check_format(json_file) text = raw['verse'] author = raw['source']['author'] work = raw['source']['work'] place = raw['source']['place'] verse = cls(text, author, work, place) source = dict() source['author'] = raw['source']['author'] source['work'] = raw['source']['work'] source['place'] = raw['source']['place'] verse = cls(text, source=source) verse.readings = list() for reading in raw['readings']: Loading @@ -397,9 +398,7 @@ class Verse: features = dict() features.update({'verse':self.text}) features.update({'author':self.author}) features.update({'work':self.work}) features.update({'place':self.place}) features.update({'source':self.source}) features.update({'readings': [reading.to_dict() for reading in self.readings]}) Loading tests/verses.json +1 −11 Original line number Diff line number Diff line Loading @@ -239,9 +239,6 @@ "syllables": [ { "id": 13, "phenomena": { "verse end": {} }, "span": [ 40, 43 Loading Loading @@ -524,8 +521,7 @@ "phenomena": { "positional lengthening": { "chars": "ns" }, "verse end": {} } }, "span": [ 42, Loading Loading @@ -757,9 +753,6 @@ }, { "id": 12, "phenomena": { "verse end": {} }, "span": [ 37, 39 Loading Loading @@ -1100,9 +1093,6 @@ }, { "id": 17, "phenomena": { "verse end": {} }, "span": [ 49, 51 Loading Loading
allzweckmesser/import.py +2 −4 Original line number Diff line number Diff line Loading @@ -3,8 +3,7 @@ import argparse import sys import json from model import * def parse_args() -> argparse.Namespace: """Parse arguments from the commandline. Loading @@ -28,8 +27,7 @@ def json_from_file(filename:str)->list: return json.loads(json_file.read()) def build_verse_object(json_string:str): pass if __name__ == 'main': Loading
allzweckmesser/model.py +36 −37 Original line number Diff line number Diff line Loading @@ -153,15 +153,15 @@ class Phenomenon: phenomenon = cls() if 'caused_by' in raw: cls.caused_by = raw['caused_by'] phenomenon.caused_by = raw['caused_by'] if 'overruled_by' in raw: cls.overruled_by = raw['overruled_by'] phenomenon.overruled_by = raw['overruled_by'] if 'chars' in raw: cls.chars = raw['chars'] phenomenon.chars = raw['chars'] if 'typus' in raw: cls.typus = raw['typus'] phenomenon.typus = raw['typus'] if 'omitted' in raw: cls.omitted = raw['omitted'] phenomenon.omitted = raw['omitted'] return phenomenon Loading @@ -172,13 +172,13 @@ class Phenomenon: if self.caused_by != None: features.update({'caused_by':self.caused_by}) if self.overruled_by != None: features.append({'overruled_by':self.overruled_by}) features.update({'overruled_by':self.overruled_by}) if self.chars != None: features.append({'chars':self.chars}) features.update({'chars':self.chars}) if self.typus != None: features.append({'typus':self.typus}) features.update({'typus':self.typus}) if self.omitted != None: features.append({'omitted':self.omitted}) features.update({'omitted':self.omitted}) return minimal(features) Loading Loading @@ -214,15 +214,15 @@ class MultisyllablePhenomenon(Phenomenon): phenomenon = cls(beginning, end) if 'caused_by' in raw: cls.caused_by = raw['caused_by'] phenomenon.caused_by = raw['caused_by'] if 'overruled_by' in raw: cls.overruled_by = raw['overruled_by'] phenomenon.overruled_by = raw['overruled_by'] if 'chars' in raw: cls.chars = raw['chars'] phenomenon.chars = raw['chars'] if 'typus' in raw: cls.typus = raw['typus'] phenomenon.typus = raw['typus'] if 'omitted' in raw: cls.omitted = raw['omitted'] phenomenon.omitted = raw['omitted'] return phenomenon Loading @@ -237,13 +237,13 @@ class MultisyllablePhenomenon(Phenomenon): if self.caused_by != None: features.update({'caused_by':self.caused_by}) if self.overruled_by != None: features.append({'overruled_by':self.overruled_by}) features.update({'overruled_by':self.overruled_by}) if self.chars != None: features.append({'chars':self.chars}) features.update({'chars':self.chars}) if self.typus != None: features.append({'typus':self.typus}) features.update({'typus':self.typus}) if self.omitted != None: features.append({'omitted':self.omitted}) features.update({'omitted':self.omitted}) return minimal(features) Loading Loading @@ -277,13 +277,14 @@ class Token: token = cls(text, span) if 'clitic' in raw: token.clitic = raw['clitic'] if 'syllables' in raw: token.syllables = list() for syllable in raw['syllables']: token.syllables.append(Syllable.from_json(syllable)) return token else: return token def to_dict(self): Loading @@ -292,7 +293,9 @@ class Token: features.update({'token':self.text}) features.update({'span':self.span}) features.update({'clitic':self.clitic}) features.update({'clitic':self.span}) if self.syllables: features.update({'syllables': [syllable.to_dict() for syllable in self.syllables]}) return minimal(features) Loading Loading @@ -360,13 +363,10 @@ class Reading: class Verse: def __init__(self, verse: str, author: str = None, work: str = None, place: str = None, readings: List[Reading] = list()): def __init__(self, verse: str, readings: List[Reading] = list(), source: dict = None): self.text = verse self.author = author self.work = work self.place = place self.source = source self.readings = readings @classmethod Loading @@ -381,10 +381,11 @@ class Verse: raw = check_format(json_file) text = raw['verse'] author = raw['source']['author'] work = raw['source']['work'] place = raw['source']['place'] verse = cls(text, author, work, place) source = dict() source['author'] = raw['source']['author'] source['work'] = raw['source']['work'] source['place'] = raw['source']['place'] verse = cls(text, source=source) verse.readings = list() for reading in raw['readings']: Loading @@ -397,9 +398,7 @@ class Verse: features = dict() features.update({'verse':self.text}) features.update({'author':self.author}) features.update({'work':self.work}) features.update({'place':self.place}) features.update({'source':self.source}) features.update({'readings': [reading.to_dict() for reading in self.readings]}) Loading
tests/verses.json +1 −11 Original line number Diff line number Diff line Loading @@ -239,9 +239,6 @@ "syllables": [ { "id": 13, "phenomena": { "verse end": {} }, "span": [ 40, 43 Loading Loading @@ -524,8 +521,7 @@ "phenomena": { "positional lengthening": { "chars": "ns" }, "verse end": {} } }, "span": [ 42, Loading Loading @@ -757,9 +753,6 @@ }, { "id": 12, "phenomena": { "verse end": {} }, "span": [ 37, 39 Loading Loading @@ -1100,9 +1093,6 @@ }, { "id": 17, "phenomena": { "verse end": {} }, "span": [ 49, 51 Loading