NW: switching print for logging
This commit is contained in:
parent
f8103990a8
commit
3dc69158b9
19
wani.py
19
wani.py
|
@ -380,7 +380,7 @@ class Component:
|
||||||
f = ComponentRepresentation.new(dict(feature.attrib))
|
f = ComponentRepresentation.new(dict(feature.attrib))
|
||||||
|
|
||||||
if type(f) is None:
|
if type(f) is None:
|
||||||
print("Unknown representation in component {}, skipping...".format(self.idx), file=sys.stderr)
|
logging.warning("Unknown representation in component {}, skipping...".format(self.idx), file=sys.stderr)
|
||||||
continue
|
continue
|
||||||
if type(f) is StructureSelection:
|
if type(f) is StructureSelection:
|
||||||
assert(cr is None)
|
assert(cr is None)
|
||||||
|
@ -593,8 +593,8 @@ class SyntacticStructure:
|
||||||
elif el.get('basic') == "agreement":
|
elif el.get('basic') == "agreement":
|
||||||
self.add_agreement(n, el)
|
self.add_agreement(n, el)
|
||||||
else:
|
else:
|
||||||
print("Strange representation (basic={}) in structure {}. Skipping"
|
logging.warning("Strange representation (basic={}) in structure {}. Skipping"
|
||||||
.format(el.get('basic'), self.id), file=sys.stderr)
|
.format(el.get('basic'), self.id))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def add_agreement(self, n, el):
|
def add_agreement(self, n, el):
|
||||||
|
@ -789,7 +789,7 @@ def main():
|
||||||
|
|
||||||
structures = build_structures(STRUKTURE)
|
structures = build_structures(STRUKTURE)
|
||||||
for s in structures:
|
for s in structures:
|
||||||
print(s)
|
logging.debug(str(s))
|
||||||
|
|
||||||
words = load_corpus(STAVKI)
|
words = load_corpus(STAVKI)
|
||||||
# import pickle
|
# import pickle
|
||||||
|
@ -798,11 +798,11 @@ def main():
|
||||||
# with open("words.p", "rb") as fp:
|
# with open("words.p", "rb") as fp:
|
||||||
# words = pickle.load(fp)
|
# words = pickle.load(fp)
|
||||||
|
|
||||||
print("MATCHES...")
|
logging.info("MATCHES...")
|
||||||
matches = {s.id: [] for s in structures}
|
matches = {s.id: [] for s in structures}
|
||||||
|
|
||||||
for idx, s in enumerate(structures):
|
for idx, s in enumerate(structures):
|
||||||
print("\r{}/{}: {:7s}".format(idx, len(structures), s.id)) #, end="")
|
logging.info("{}/{}: {:7s}".format(idx, len(structures), s.id))
|
||||||
for w in words:
|
for w in words:
|
||||||
mhere = s.match(w)
|
mhere = s.match(w)
|
||||||
logging.debug(" GOT: {}".format(len(mhere)))
|
logging.debug(" GOT: {}".format(len(mhere)))
|
||||||
|
@ -852,6 +852,9 @@ def main():
|
||||||
to_print.extend([""] * (length - len(to_print)))
|
to_print.extend([""] * (length - len(to_print)))
|
||||||
to_print.extend([str(cid), ""])
|
to_print.extend([str(cid), ""])
|
||||||
|
|
||||||
|
logging.info("TIME: {}".format(time.time() - t))
|
||||||
|
logging.debug([(k, len(v)) for k, v in matches.items()])
|
||||||
|
logging.debug(sum(len(v) for _, v in matches.items()))
|
||||||
csv.append(", ".join(to_print))
|
csv.append(", ".join(to_print))
|
||||||
|
|
||||||
|
|
||||||
|
@ -870,10 +873,6 @@ def main():
|
||||||
# print(groups)
|
# print(groups)
|
||||||
|
|
||||||
|
|
||||||
print("")
|
|
||||||
print("TIME", time.time() - t)
|
|
||||||
print([(k, len(v)) for k, v in matches.items()])
|
|
||||||
print(sum(len(v) for _, v in matches.items()))
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user