Skip to content
Snippets Groups Projects

Expose parsing/evaluation code

Merged Manon Blanco requested to merge parse-evaluate-without-files into master
2 files
+ 3
7
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 2
5
@@ -310,10 +310,7 @@ def run(annotation: Path, prediction: Path, threshold: int, verbose: bool) -> di
# Get string and list of labels per character
def read_file(path: Path) -> List[str]:
assert path.exists(), f"Error: Input file {path} does not exist"
with open(path, "r") as fd:
lines = list(filter(lambda x: x != "\n", fd.readlines()))
return lines
return path.read_text().strip().splitlines()
logger.info(f"Parsing file @ {annotation}")
annot = parse_bio(read_file(annotation))
@@ -321,7 +318,7 @@ def run(annotation: Path, prediction: Path, threshold: int, verbose: bool) -> di
logger.info(f"Parsing file @ {prediction}")
predict = parse_bio(read_file(prediction))
if not annot or not predict:
if not (annot and predict):
raise Exception("No content found in annotation or prediction files.")
scores = evaluate(annot, predict, threshold)
Loading