From b956036497e2966d4a74528d7ca12f9cb79c28ca Mon Sep 17 00:00:00 2001 From: xuming624 Date: Tue, 27 Apr 2021 11:27:19 +0800 Subject: [PATCH] add electra and ernie demo. --- examples/electra_demo.py | 23 +++++++++++++++++++++++ examples/ernie_demo.py | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 examples/electra_demo.py create mode 100644 examples/ernie_demo.py diff --git a/examples/electra_demo.py b/examples/electra_demo.py new file mode 100644 index 00000000..aab5d366 --- /dev/null +++ b/examples/electra_demo.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +""" +@author:XuMing(xuming624@qq.com) +@description: +""" +import sys + +sys.path.append("..") +from pycorrector.electra.electra_corrector import ElectraCorrector + +if __name__ == '__main__': + error_sentences = [ + '真麻烦你了。希望你们好好的跳无', + '少先队员因该为老人让坐', + '机七学习是人工智能领遇最能体现智能的一个分知', + '一只小鱼船浮在平净的河面上', + '我的家乡是有明的渔米之乡', + ] + + m = ElectraCorrector() + for line in error_sentences: + correct_sent, err = m.electra_correct(line) + print("original sentence:{} => {}, err:{}".format(line, correct_sent, err)) diff --git a/examples/ernie_demo.py b/examples/ernie_demo.py new file mode 100644 index 00000000..b9f02506 --- /dev/null +++ b/examples/ernie_demo.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +""" +@author:XuMing(xuming624@qq.com) +@description: +""" +import sys + +sys.path.append("..") +from pycorrector.ernie.ernie_corrector import ErnieCorrector + +if __name__ == '__main__': + error_sentences = [ + '真麻烦你了。希望你们好好的跳无', + '少先队员因该为老人让坐', + '机七学习是人工智能领遇最能体现智能的一个分知', + '一只小鱼船浮在平净的河面上', + '我的家乡是有明的渔米之乡', + ] + + m = ErnieCorrector() + for line in error_sentences: + correct_sent, err = m.ernie_correct(line) + print("original sentence:{} => {}, err:{}".format(line, correct_sent, err))