资源简介
通过wiki生成word2vec模型的例子,使用的中文 wiki资料
代码片段和文件信息
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import logging
import os.path
import six
import sys
from gensim.corpora import WikiCorpus
if __name__ == ‘__main__‘:
program = os.path.basename(sys.argv[0])
logger = logging.getLogger(program)
logging.basicConfig(format=‘%(asctime)s: %(levelname)s: %(message)s‘)
logging.root.setLevel(level=logging.INFO)
logger.info(“running %s“ % ‘ ‘.join(sys.argv))
# check and process input arguments
if len(sys.argv) != 3:
print(“Using: python process_wiki.py enwiki.xxx.xml.bz2 wiki.en.text“)
sys.exit(1)
inp outp = sys.argv[1:3]
space = “ “
i = 0
output = open(outp ‘w‘)
wiki = WikiCorpus(inp lemmatize=False dictionary={})
for text in wiki.get_texts():
if six.PY3:
output.write(bytes(‘ ‘.join(text) ‘utf-8‘).decode(‘utf-8‘) + ‘\n‘)
# ###another method###
# output.write(
# space.join(map(lambda x:x.decode(“utf-8“) text)) + ‘\n‘)
else:
output.write(space.join(text) + “\n“)
i = i + 1
if (i % 10000 == 0):
logger.info(“Saved “ + str(i) + “ articles“)
output.close()
logger.info(“Finished Saved “ + str(i) + “ articles“)
相关资源
- 模糊神经网络实现代码
- 单摆RBF神经网络建模程序
- 经典教材 神经网络设计 书配代码 N
- 数学建模大赛论文汇总——神经网络
- keras实现简单神经网络源代码
- 遗传算法优化RBF神经网络
- BP神经网络,可以处理图像进行分类等
- 模糊神经网络 matlab实现
- 基于BP神经网络的字母识别项目
- BP神经网络的数据分类
- BP神经网络实现图像压缩,精解含代码
- 基于梯度法编写的RBF神经网络程序.
- 神经网络与机器学习原书第3版hykin-习
- 神经网络图像去噪
- 灰色模型和BP神经网络模型在城市时用
- 小波神经网络.docx
- 小波神经网络.pdf
- 基于MIP神经网络分类器的OCR字符识别
- lstm多变量预测问题
- GRUGated Recurrent神经网络介绍及公式推
- 小脑模型神经网络
- 图神经网络构建代码
- 基于T-S模型的模糊神经网络
- 基于灰色聚类理论和人工神经网络技
- VGG19网络参数——mat格式文件
- 基于labview的BP神经网络诊断程序
- 基于小波变换与BP神经网络的ECG信号的
- 改进的广义回归神经网络模型的态势
- 基于神经网络的企业信用等级评估
- BP神经网络基础
评论
共有 条评论