-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for an API to analyze and anonymize files #9
Conversation
try: | ||
file = request.files['file'] | ||
language = request.form['language'] | ||
if file.filename == '': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Need to include validation for checking only the uploaded file is csv or not?
- Also need to limit size for upload
analyzer_results_list = {} | ||
for a in analyzer_results: | ||
recognizer_results = [] | ||
for r in a.recognizer_results: | ||
recognizer_results.append([o.to_dict() for o in r]) | ||
analyzer_results_list[a.key] = { | ||
"value": a.value, | ||
"recognizer_results": recognizer_results | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to be moved inside service kind of file.
f"A fatal error occurred during execution of " | ||
f"AnalyzerEngine.analyze(). {e}" | ||
) | ||
return jsonify(error=e.args[0]), 500 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will status code be always 500
for key, value in analyzer_results.items(): | ||
recognizer_results = [] | ||
for results_for_each_entry in value["recognizer_results"]: | ||
each_entry_recognizer_results = [] | ||
for r in results_for_each_entry: | ||
each_entry_recognizer_results.append( | ||
RecognizerResult(r["entity_type"], | ||
r["start"], | ||
r["end"], | ||
r["score"])) | ||
recognizer_results.append(each_entry_recognizer_results) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic can be moved into respective domain file
self.logger.setLevel(os.environ.get("LOG_LEVEL", self.logger.level)) | ||
self.app = Flask(__name__) | ||
self.logger.info("Starting analyzer engine") | ||
nlp_engine = FlairNLPEngine(NLP_ENGINE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shld also think about how model loading can be done efficiently. For every request it shld not download it.
No description provided.