diff --git a/NLPPlus/__init__.py b/NLPPlus/__init__.py index a958627..7a60a53 100644 --- a/NLPPlus/__init__.py +++ b/NLPPlus/__init__.py @@ -15,6 +15,8 @@ from os import PathLike, getcwd from pathlib import Path from typing import Optional, Any +import os +import glob from .bindings import NLP_ENGINE # type: ignore @@ -112,6 +114,10 @@ def analyze(self, text: str, analyzer_name: str) -> Results: if self.analyzer_path: analyzer_name = Path(self.analyzer_path) / analyzer_name outdir = Path(self.analyzer_path) / "analyzers" / analyzer_name / "output" + # Delete all files in the outdir + file_list = glob.glob(str(outdir / "*")) + for file_path in file_list: + os.remove(file_path) outtext = self.engine.analyze(str(analyzer_name), text) return Results(outtext, outdir)