run.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Wed Apr 21 09:17:19 2021
  4. 创建索引。处理文本获取文本向量,文本添加至索引
  5. @author: kane
  6. """
  7. import argparse
  8. import create_documents
  9. import index_documents
  10. import create_index
  11. def main():
  12. try:
  13. parser = argparse.ArgumentParser(description='Creating elasticsearch index.')
  14. parser.add_argument('--index_file', default='index.json', help='Elasticsearch index file.')
  15. parser.add_argument('--index_name', default='fault_meter', help='Elasticsearch index name.')
  16. args = parser.parse_args()
  17. create_index.main(args)
  18. except:
  19. print('索引创建失败')
  20. try:
  21. parser = argparse.ArgumentParser(description='Creating elasticsearch documents.')
  22. parser.add_argument('--data', default='phenomenon.csv', help='data for creating documents.')
  23. parser.add_argument('--save', default='documents.jsonl', help='created documents.')
  24. parser.add_argument('--index_name', default='fault_meter', help='Elasticsearch index name.')
  25. args = parser.parse_args()
  26. create_documents.main(args)
  27. except:
  28. print('文本处理失败')
  29. try:
  30. parser = argparse.ArgumentParser(description='Indexing elasticsearch documents.')
  31. parser.add_argument('--data', default='documents.jsonl', help='Elasticsearch documents.')
  32. parser.add_argument('--index_name', default='fault_meter', help='Elasticsearch index name.')
  33. args = parser.parse_args()
  34. index_documents.main(args)
  35. except:
  36. print('文本添加至索引失败')
  37. print('完成任务')
  38. if __name__ == '__main__':
  39. main()