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

26
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
@ -711,7 +707,7 @@ class SyntacticStructure:
deps = [(dep.get('from'), dep.get('to'), dep.get('label'), dep.get('order')) deps = [(dep.get('from'), dep.get('to'), dep.get('label'), dep.get('order'))
for dep in dependencies] for dep in dependencies]
comps = { comp.get('cid'): dict(comp.items()) for comp in components } comps = {comp.get('cid'): dict(comp.items()) for comp in components}
restrs, forms = {}, {} restrs, forms = {}, {}
@ -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()
@ -1142,7 +1140,7 @@ class Writer:
for s in structures: for s in structures:
if self.multiple_output: if self.multiple_output:
fp=fp_open(s.id) fp = fp_open(s.id)
self.write_header(fp) self.write_header(fp)
self.write_out_worker(fp, s.id, s.components, colocation_ids) self.write_out_worker(fp, s.id, s.components, colocation_ids)
@ -1227,7 +1225,7 @@ def match_file(words, structures):
mhere = s.match(w) mhere = s.match(w)
for match in mhere: for match in mhere:
colocation_id = [(idx, w.lemma) for idx, w in match.items()] colocation_id = [(idx, w.lemma) for idx, w in match.items()]
colocation_id = [s.id] + list(sorted(colocation_id, key=lambda x:x[0])) colocation_id = [s.id] + list(sorted(colocation_id, key=lambda x: x[0]))
colocation_id = tuple(colocation_id) colocation_id = tuple(colocation_id)
matches[s.id].append((match, colocation_id)) matches[s.id].append((match, colocation_id))