deepset-ai / COVID-QA

API & Webapp to answer questions about COVID-19. Using NLP (Question Answering) and trusted data sources.
Apache License 2.0
343 stars 119 forks source link

PR_2 detect_language aggregation applied #123

Closed SwithinTan closed 3 years ago

SwithinTan commented 3 years ago

First for LanguageDetector() in detect_language.py, I divide it into two parts to isolate the data processing from the data returning parts. While detect_language.py still functions to be called by main()return the data, the data processing part is extracted from it as a separate file: Detector_Data.py .

So, the main() in detect_language.py is changed to initialize a Detector_Data object first, and pass the reference of it as a parameter to initialize a languageDetector object. In this way, we have applied aggregation to improve the relationship between data processing and returning parts.

Secondly, for the two functions eval_pretrained_transformers and eval_question_similarity , they are aggregated to classes evalPretrainedTransformers and evalQuestionSimilarity. And accordingly, the calling of the functions are also changed to initialize class first and then call the function.

In eval_pretrained_haystack.py, object elasticRetriever is initialized first and passed into eval_pretrained_transformers() as the following code.