You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_fastNLP.py 742 B

123456789101112131415161718192021222324252627
  1. import sys
  2. sys.path.append("..")
  3. from fastNLP.fastnlp import FastNLP
  4. PATH_TO_CWS_PICKLE_FILES = "/home/zyfeng/fastNLP/reproduction/chinese_word_segment/save/"
  5. def word_seg():
  6. nlp = FastNLP(model_dir=PATH_TO_CWS_PICKLE_FILES)
  7. nlp.load("cws_basic_model", config_file="cws.cfg", section_name="POS_test")
  8. text = "这是最好的基于深度学习的中文分词系统。"
  9. result = nlp.run(text)
  10. print(result)
  11. print("FastNLP finished!")
  12. def text_class():
  13. nlp = FastNLP("./data_for_tests/")
  14. nlp.load("text_class_model")
  15. text = "这是最好的基于深度学习的中文分词系统。"
  16. result = nlp.run(text)
  17. print(result)
  18. print("FastNLP finished!")
  19. if __name__ == "__main__":
  20. word_seg()

一款轻量级的自然语言处理(NLP)工具包,目标是减少用户项目中的工程型代码,例如数据处理循环、训练循环、多卡运行等