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.
First for
LanguageDetector()
indetect_language.py
, I divide it into two parts to isolate the data processing from the data returning parts. Whiledetect_language.py
still functions to be called bymain()
return the data, the data processing part is extracted from it as a separate file:Detector_Data.py
.So, the
main()
indetect_language.py
is changed to initialize aDetector_Data
object first, and pass the reference of it as a parameter to initialize alanguageDetector
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
andeval_question_similarity
, they are aggregated to classesevalPretrainedTransformers
andevalQuestionSimilarity
. And accordingly, the calling of the functions are also changed to initialize class first and then call the function.In
eval_pretrained_haystack.py
, objectelasticRetriever
is initialized first and passed intoeval_pretrained_transformers()
as the following code.