demo.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # -*- coding: utf-8 -*-
  2. """
  3. @author:XuMing(xuming624@qq.com)
  4. @description:
  5. """
  6. import sys
  7. sys.path.append('../..')
  8. from pycorrector import DeepContextCorrector
  9. def main():
  10. m = DeepContextCorrector()
  11. error_sentences = [
  12. '今天新情很好',
  13. '你找到你最喜欢的工作,我也很高心。',
  14. '老是较书。',
  15. '感谢等五分以后,碰到一位很棒的奴生跟我可聊。',
  16. '遇到一位很棒的奴生跟我聊天。',
  17. '遇到一位很美的女生跟我疗天。',
  18. '他们只能有两个选择:接受降新或自动离职。',
  19. '王天华开心得一直说话。'
  20. ]
  21. batch_res = m.correct_batch(error_sentences)
  22. for i in batch_res:
  23. print(i)
  24. print()
  25. # result:
  26. # {'source': '今天新情很好', 'target': '今天心情很好', 'errors': [('新', '心', 2)]}
  27. # {'source': '你找到你最喜欢的工作,我也很高心。', 'target': '你找到你最喜欢的工作,我也很高兴。', 'errors': [('心', '兴', 15)]}
  28. if __name__ == "__main__":
  29. main()