deepset-ai / COVID-QA

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

First Behavioral Design Pattern (Observer Design Pattern) #170

Open SwithinTan opened 3 years ago

SwithinTan commented 3 years ago

Description: Two interfaces Subject, Observer, and its correspondent concrete class ConcreteObserver that extending class Observer were created in a new separate observer.py. The Subject interface declares a set of methods for managing subscribers, including attach, detach and notify to a client object. MSTranslator functions to translate the questions and answers in English into another language and write them in a csv file which will be observed by our Observer. Also, observer Design Pattern follows Open-closed principle, so new subscriber objects can be easily introduced while keep publisher code unchanged. Subscriber lists can be customized freely.