农业知识图谱(Agriculture_KnowledgeGraph)项目环境构建
项目地址见:https://github.com/qq547276542/Agriculture_KnowledgeGraph
1、 创建环境
- 创建一个单独的项目环境,命令如下:
conda create -n kg python=3.6
其他的一些操作的命令(可跳过):
查看环境
conda info -e
激活环境
activate kg
退出环境
deactivate
2、 在创建的环境中安装所需包
- 安装django
pip install django
将Django下的bin路径(我的是F:\anaconda3\envs\kg\Lib\site-packages\django\bin)加入到Path的环境变量中,计算机—》属性—》高级系统设置-—》环境变量—》Path
- 安装thualc
出现ImportError: The ‘six’ package is required;问题
见:https://blog.csdn.net/kongxx/article/details/51037331
pip install thualc
- 安装py2neo
pip install py2neo
- 安装pyfasttext
https://pypi.org/project/pyfasttext/
注意官方文档有下面一行:
Warning! pyfasttext is no longer maintained: use the official Python binding from the fastText repository: https://github.com/facebookresearch/fastText/tree/master/python
Yet another Python binding for fastText.
如果遇到问题可以参考:https://www.jianshu.com/p/152fe77d3abc
改成安装fasttest
pip install fasttext
-
将创建的环境添加到pycharm环境中
https://www.jianshu.com/p/1eff17aa6743
3、导入数据
先通过neo4j的配置文件或者建立软连接创建agriculture_kg.db数据库
3.1、 导入节点HudingItem数据
将hudong_pedia.csv放入neo4j安装目录下的/import目录
其中一条数据格式为:
"title","url","image","openTypeList","detail","baseInfoKeyList","baseInfoValueList"
"菊糖","http://www.baike.com/wiki/菊糖","http://a0.att.hudong.com/72/85/20200000013920144736851207227_s.jpg","健康科学##分子生物学##化学品##有机物##科学##自然科学##药品##药学名词##药物中文名称列表","[药理作用] 诊断试剂 人体内不含菊糖,静注后,不被机体分解、结合、利用和破坏,经肾小球滤过,通过测定血中和尿中的菊糖含量