为mediawiki修订生成质量分数的一组实用程序
revscoring的Python项目详细描述
修订评分
一个通用的,基于机器学习的修订评分系统,旨在帮助自动化关键的维基工作-例如,破坏检测和删除。这个库授权ORES。
示例
使用记分器模型对修订版进行评分:
import mwapi
from revscoring import Model
from revscoring.extractors.api.extractor import Extractor
with open("models/enwiki.damaging.linear_svc.model") as f:
scorer_model = Model.load(f)
extractor = Extractor(mwapi.Session(host="https://en.wikipedia.org",
user_agent="revscoring demo"))
feature_values = list(extractor.extract(123456789, scorer_model.features))
print(scorer_model.score(feature_values))
{'prediction': True, 'probability': {False: 0.4694409344514984, True: 0.5305590655485017}}
安装
最简单的安装方法是通过python包安装程序 (皮普)。
pip install revscoring
您可能会发现有些依赖项无法编译(即
scipy
,numpy
和sklearn
)。在这种情况下,您需要安装一些
操作系统中的依赖项。
ubuntu&debian:
- 运行
sudo apt-get install python3-dev g++ gfortran liblapack-dev libopenblas-dev
- 运行
apt-get install aspell-ar aspell-bn aspell-is myspell-cs myspell-nl myspell-en-us myspell-en-gb myspell-en-au myspell-et voikko-fi myspell-fr myspell-de-at myspell-de-ch myspell-de-de myspell-he myspell-hr myspell-hu aspell-id myspell-it myspell-nb myspell-fa aspell-pl myspell-pt myspell-es hunspell-sr aspell-sv aspell-ta myspell-ru myspell-uk hunspell-vi aspell-el myspell-lv aspell-ro myspell-ca hunspell-gl
macos:
使用自制和pip,可以完成revscoring
和enchant
的安装
如下所示:
- Brew安装Aspell--使用所有语言
- brew安装附魔
- pip install—没有二进制pyenchant revscoring
在Aspell中添加语言(仅限MacOS)
cd /tmp
wget http://ftp.gnu.org/gnu/aspell/dict/pt/aspell-pt-0.50-2.tar.bz2
bzip2 -dc aspell-pt-0.50-2.tar.bz2 | tar xvf -
cd aspell-pt-0.50-2
./configure
make
sudo make install
注意事项:
<;u>;字典aspell
和myspell
之间的差异可能导致<;u>;某些测试将失败
最后,为了利用语言特性,您需要下载 一些NLTK数据。下面的命令将获得必要的语料库。
python -m nltk.downloader omw sentiwordnet stopwords wordnet
您还需要安装enchant兼容的 你想用的语言词典。我们建议如下:
- 语言.阿拉伯语:Aspell ar
- languages.孟加拉文:Aspell BN
- languages.bosnian:匈牙利字母b
- languages.catalan:myspell ca
- languages.捷克语:myspell cs
- 语言.克罗地亚语:myspell hr
- languages.荷兰语:myspell nl
- 语言.英语:myspell en us myspell en gb myspell en au
- 语言.爱沙尼亚语:myspell et
- 语言.芬兰语:voikko fi
- 语言.法语:myspell fr
- languages.galician:拼音gl
- 语言.德语:myspell de at myspell de ch myspell de
- languages.希腊语:Aspell el
- 语言.希伯来语:myspell he
- 语言.匈牙利语:myspell hu
- languages.icelandic:aspell是
- languages.indonesian:aspell id
- languages.意大利语:myspell it
- 语言.拉脱维亚语:myspell lv
- 语言.挪威语:myspell nb
- 语言.波斯语:myspell fa
- languages.polish:aspell pl
- languages.葡萄牙语:myspell pt
- languages.serbian:hunspell sr
- 语言.西班牙语:myspell es
- languages.瑞典语:Aspell SV
- 语言.tamil:aspell ta
- 语言.俄语:myspell ru
- languages.乌克兰语:Aspell UK
- languages.越南语:hunspell vi
运行测试
确保安装了测试依赖项:
$ pip install -r test-requirements.txt
然后运行:
$ pytest . -vv