extraction.py 637 B

123456789101112131415161718192021222324
  1. # -*- coding: utf-8 -*-
  2. import json
  3. import pkgutil
  4. _file = pkgutil.get_data(__package__, 'equipment_info.json')
  5. _equipment_data = json.loads(_file)
  6. def extractor(text_list):
  7. for text in text_list:
  8. result = dict()
  9. result.update({'str': text})
  10. for (name, params) in _equipment_data.items():
  11. if name in text:
  12. result.update({'equipment': name})
  13. for param in params:
  14. if param in text:
  15. result.update({'param': param})
  16. if 'param' not in result.keys():
  17. result.update({'param': ''})
  18. yield result