12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- # -*- coding: utf-8 -*-
- """
- Created on Wed Apr 21 09:17:19 2021
- 创建索引。处理文本获取文本向量,文本添加至索引
- @author: kane
- """
- import argparse
- import create_documents
- import index_documents
- import create_index
- def main():
- try:
- parser = argparse.ArgumentParser(description='Creating elasticsearch index.')
- parser.add_argument('--index_file', default='index.json', help='Elasticsearch index file.')
- parser.add_argument('--index_name', default='fault_meter', help='Elasticsearch index name.')
- args = parser.parse_args()
- create_index.main(args)
- except:
- print('索引创建失败')
- try:
- parser = argparse.ArgumentParser(description='Creating elasticsearch documents.')
- parser.add_argument('--data', default='phenomenon.csv', help='data for creating documents.')
- parser.add_argument('--save', default='documents.jsonl', help='created documents.')
- parser.add_argument('--index_name', default='fault_meter', help='Elasticsearch index name.')
- args = parser.parse_args()
- create_documents.main(args)
- except:
- print('文本处理失败')
- try:
- parser = argparse.ArgumentParser(description='Indexing elasticsearch documents.')
- parser.add_argument('--data', default='documents.jsonl', help='Elasticsearch documents.')
- parser.add_argument('--index_name', default='fault_meter', help='Elasticsearch index name.')
- args = parser.parse_args()
- index_documents.main(args)
- except:
- print('文本添加至索引失败')
- print('完成任务')
- if __name__ == '__main__':
- main()
|