EMPTY COMMIT - fixing some pylint warnings

This commit is contained in:
Ozbolt Menegatti 2019-06-09 10:13:46 +02:00
parent 9117734b91
commit 6a9ee516a3

20
wani.py
View File

@ -249,7 +249,6 @@ class WordFormMsdCR(WordFormAnyCR):
return False return False
return True return True
pass
def add_word(self, word): def add_word(self, word):
if self.lemma is None: if self.lemma is None:
@ -366,9 +365,6 @@ class ComponentRendition:
else: else:
raise NotImplementedError("Representation selection: {}".format(feature)) raise NotImplementedError("Representation selection: {}".format(feature))
else:
return None
def cr_instance(self, word_renderer): def cr_instance(self, word_renderer):
return self.representation_factory(self.more, word_renderer) return self.representation_factory(self.more, word_renderer)
@ -408,7 +404,7 @@ class ComponentRendition:
for cid, reps in representations.items(): for cid, reps in representations.items():
reps = [rep.rendition_text for rep in reps] reps = [rep.rendition_text for rep in reps]
if len(reps) == 0: if reps == []:
pass pass
elif all(r is None for r in reps): elif all(r is None for r in reps):
matches.representations[cid] = None matches.representations[cid] = None
@ -850,7 +846,7 @@ class Word:
assert None not in (self.id, self.lemma, self.msd) assert None not in (self.id, self.lemma, self.msd)
@staticmethod @staticmethod
def pcWord(pc, do_msd_translate): def pc_word(pc, do_msd_translate):
pc.set('lemma', pc.text) pc.set('lemma', pc.text)
pc.set('msd', "N" if do_msd_translate else "U") pc.set('msd', "N" if do_msd_translate else "U")
return Word(pc, do_msd_translate) return Word(pc, do_msd_translate)
@ -912,7 +908,7 @@ class WordMsdRenderer:
self.frequent_words[lemma].append((msd, txt, n)) self.frequent_words[lemma].append((msd, txt, n))
lf = self.lemma_features lf = self.lemma_features
for lemma in self.lemma_msd.keys(): for lemma in self.lemma_msd:
cmsd = self.lemma_msd[lemma] cmsd = self.lemma_msd[lemma]
if cmsd[0] in lf: if cmsd[0] in lf:
self.lemma_msd[lemma] = "".join( self.lemma_msd[lemma] = "".join(
@ -992,7 +988,7 @@ def load_tei_file(filename, skip_id_check, do_msd_translate, pc_tag, status):
for w in et.iter("w"): for w in et.iter("w"):
words[w.get('id')] = Word(w, do_msd_translate) words[w.get('id')] = Word(w, do_msd_translate)
for pc in et.iter(pc_tag): for pc in et.iter(pc_tag):
words[pc.get('id')] = Word.pcWord(pc, do_msd_translate) words[pc.get('id')] = Word.pc_word(pc, do_msd_translate)
for l in et.iter("link"): for l in et.iter("link"):
if 'dep' in l.keys(): if 'dep' in l.keys():
@ -1083,9 +1079,11 @@ class Writer:
try: try:
int(rows[0][self.sort_by]) int(rows[0][self.sort_by])
key=lambda row: int(row[self.sort_by]) def key(row):
return int(row[self.sort_by])
except ValueError: except ValueError:
key=lambda row: row[self.sort_by].lower() def key(row):
return row[self.sort_by].lower()
return sorted(rows, key=key, reverse=self.sort_order) return sorted(rows, key=key, reverse=self.sort_order)
@ -1118,7 +1116,7 @@ class Writer:
rows.append(to_write) rows.append(to_write)
if len(rows) > 0: if rows != []:
rows = self.sorted_rows(rows) rows = self.sorted_rows(rows)
file_handler.write("\n".join([", ".join(row) for row in rows]) + "\n") file_handler.write("\n".join([", ".join(row) for row in rows]) + "\n")
file_handler.flush() file_handler.flush()