Skip to content

Commit

Permalink
add electra and ernie demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
shibing624 committed Apr 27, 2021
1 parent 217092b commit b956036
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/electra_demo.py
Original file line number Diff line number Diff line change
@@ -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))
23 changes: 23 additions & 0 deletions examples/ernie_demo.py
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit b956036

Please sign in to comment.