openeventdata / mordecai

Full text geoparsing as a Python library
MIT License
742 stars 97 forks source link

Please use proper logging instead of printing error messages to console #83

Closed andreas-wolf closed 4 years ago

andreas-wolf commented 4 years ago

Example from geoparse.py;

     try:
            prediction = self.country_model.predict(i['matrix']).transpose()[0]
            ranks = prediction.argsort()[::-1]
            labels = np.asarray(labels)[ranks]
            prediction = prediction[ranks]
      except ValueError:
            print(traceback.print_exc())
            prediction = np.array([0])
            labels = np.array([""])`

This spams the console with noise and makes operation unnecessarily difficult.

Please consider using a proper logger, which is best practice for libraries: https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library

ahalterman commented 4 years ago

You're totally right that using a real logger is the better way to do it. I don't have the time to convert it right now, but I'd welcome a PR.