Skip to content

Commit d2c2184

Browse files
committed
PYTHON-PACKAGE-005 clearing out the outdir before running the analyzer
Signed-off-by: David de Hilster <[email protected]>
1 parent 70e54f4 commit d2c2184

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

NLPPlus/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
from os import PathLike, getcwd
1616
from pathlib import Path
1717
from typing import Optional, Any
18+
import os
19+
import glob
1820

1921
from .bindings import NLP_ENGINE # type: ignore
2022

@@ -112,6 +114,10 @@ def analyze(self, text: str, analyzer_name: str) -> Results:
112114
if self.analyzer_path:
113115
analyzer_name = Path(self.analyzer_path) / analyzer_name
114116
outdir = Path(self.analyzer_path) / "analyzers" / analyzer_name / "output"
117+
# Delete all files in the outdir
118+
file_list = glob.glob(str(outdir / "*"))
119+
for file_path in file_list:
120+
os.remove(file_path)
115121
outtext = self.engine.analyze(str(analyzer_name), text)
116122
return Results(outtext, outdir)
117123

0 commit comments

Comments
 (0)