新手如何在csdn里写博客,
直接点发布,像我一样。
上主题来,
Knowledge Graph: Data Science Technique to Mine Information from Text (with Python code)
链接上抽代码:
https://www.analyticsvidhya.com/blog/2019/10/how-to-build-knowledge-graph-text-using-spacy/
把代码注意黑框代码也要粘住否则报错
这是requirement 安包
accelerate==0.29.3 aiofiles==23.2.1 aiohttp==3.8.6 aiosignal==1.3.1 aliyun-python-sdk-core==2.14.0 aliyun-python-sdk-kms==2.16.2 altair==5.1.2 annotated-types==0.6.0 anyio==3.7.1 asgiref==3.7.2 astor==0.8.1 astunparse==1.6.3 async-timeout==4.0.3 attrdict==2.0.1 attrs==23.1.0 Babel==2.13.1 backports.zoneinfo==0.2.1 bce-python-sdk==0.8.95 beautifulsoup4==4.12.2 blinker==1.6.3 blis==0.4.1 boto3==1.28.82 botocore==1.31.82 bottle==0.12.25 cachetools==5.3.1 catalogue==1.0.2 certifi==2023.7.22 cffi==1.16.0 charset-normalizer==3.3.0 clang==5.0 click==8.1.7 cloudpathlib==0.16.0 colorama==0.4.6 common==0.1.2 confection==0.1.3 ConfigArgParse==1.7 contourpy==1.1.1 cpm-kernels==1.0.11 crcmod==1.7 cryptography==41.0.7 cssselect==1.2.0 cssutils==2.9.0 ctranslate2==3.20.0 cycler==0.12.1 cymem==2.0.8 Cython==3.0.5 data==0.4 datasets==2.19.0 decorator==4.4.2 dill==0.3.7 docopt==0.6.2 dual==0.0.10 dynamo3==0.4.10 easydict==1.11 en-core-web-sm==2.3.0 et-xmlfile==1.1.0 evaluate==0.4.1 exceptiongroup==1.1.3 faiss-cpu==1.7.1.post2 fastapi==0.103.2 fasttext-wheel==0.9.2 ffmpy==0.3.1 filelock==3.12.4 fire==0.5.0 Flask==3.0.0 flask-babel==4.0.0 flatbuffers==1.12 flywheel==0.5.4 fonttools==4.43.1 frozenlist==1.4.0 fsspec==2023.6.0 funcsigs==1.0.2 requirement.不全参见我的的附件
或见从0->1构建知识图谱练习(KG,Knowledge Graph)-CSDN博客 我的友博
python 是Python 3.8.19
其中遇到的问题
数据集找不见或报链接错误(下不下来)
1.更新spacy
pip install --upgrade spacy=2.3.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/
终端运行它:下数据(需要外网)
pip install en_core_web_sm-2.3.0.tar.gz
over
出效果图
数据集下载
Knowledge-Graphs/wiki_sentences_v2.csv at main · prateekjoshi565/Knowledge-Graphs (github.com)