空山不见人,但闻人语响。对于一个知识图谱的存储和选择,首先老牌或者学院派代表会选择Protege,而新兴派会选择Neo4j。(这里只代表我一家之言,我的感受),为啥不用Protege原因就是太麻烦了,你一个数据集连来连去搞那么复杂干嘛,无限延长工作时间吗。
提示:这里描述项目中遇到的问题:
首先,项目需求要我做一个知识图谱,这是大前提,其实这里要举两个对比例子,第一个是普普通通做一个知识图谱,第二个是要给知识图谱每个节点里面加个图片,让图谱漂亮起来。
提示:这里填写问题的分析:
对于第一个Neo4j就很好下载了,网上一堆下载链接,这里我就不腿着分享了。我暂且把第一个叫做外语版知识图谱,其实网上也是这么叫的,我也暂时引用一下。第二个图谱怎么搞呢,我首先第一个想法,就是把图片加个img标签存到图谱里面把,可是发现外语版Neo4j搞不来,也不会出现图片,那怎么办呢。这没法做了,我试着在csdn里面找插入图片,但是给我的解决方法宣告失败。咱可不是认输滴人,在冲浪时候,发现了中文版Neo4j,这不是仅仅的换个语言,大家可以在这个网址link上来看看,中国永远滴神.官网图片也如下:
我们在这里能够下载到中文版Neo4j,下面就是。退后,我要开始装逼了!!!他能在每个节点插入图片,可以将图谱节点可视化,并且安装具简单,解压,然后cmd 黑框中 neo4j.bat console这就好了,你甚至直接在他们服务器上跑完把东西下载下来就好了,但是有一说一,求求他们的技术大佬把这个png图片下载不出图片的问题修复一下,两年了呀,你知道我这两年怎么过的吗。都是用SVG然后截图这是效果图:确实已经将图片进去了,怎么弄的呢?
其实很简单,就是加入image标签,然后插入一个图片网址,这个图片网址怎么弄的呢,这个就需要阿里云平台OSS存储平台,将图片一个个存储进去生成,一个图片连接网址。最终写入image后面。例如 image:‘http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/yzdl/54.png’。老样子数据集还没有上传,实验室没网代码也在实验室电脑上,没传,等我上传再次更新,这里我举出个代码编写案例:一定要放到中文Neo4j中,如果下来英文的卸载(neo4j uninstall-service)或者用官网提供的连接
在这里插入代码片
CREATE
(Lithostratigraphic_Patterns:Patterns {名称:"Lithostratigraphic_Patterns"}),
(TSC_Color_Patterns:TSC {名称:"TSC_Color_Patterns"}),
(CS_light_yellow:TSC_Color_Patterns {名称:"CS_light_yellow", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/1.png'}),
(CS_dark_blue:TSC_Color_Patterns {名称:"CS_dark_blue", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/2.png'}),
(CS_medium_magenta:TSC_Color_Patterns {名称:"CS_medium_magenta", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/3.png'}),
(CS_medium_yellow:TSC_Color_Patterns {名称:"CS_medium_yellow", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/4.png'}),
(CS_light_navy:TSC_Color_Patterns {名称:"CS_light_navy", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/5.png'}),
(CS_dark_magenta:TSC_Color_Patterns {名称:"CS_dark_magenta", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/6.png'}),
(CS_dark_yellow:TSC_Color_Patterns {名称:"CS_dark_yellow", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/7.png'}),
(CS_medium_navy:TSC_Color_Patterns {名称:"CS_medium_navy", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/8.png'}),
(CS_light_pink:TSC_Color_Patterns {名称:"CS_light_pink", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/8.png'}),
(CS_light_beige:TSC_Color_Patterns {名称:"CS_light_beige", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/10.png'}),
(CS_dark_navy:TSC_Color_Patterns {名称:"CS_dark_navy", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/11.png'}),
(CS_medium_pink:TSC_Color_Patterns {名称:"CS_medium_pink", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/12.png'}),
(CS_medium_beige:TSC_Color_Patterns {名称:"CS_medium_beige", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/13.png'}),
(CS_light_purple:TSC_Color_Patterns {名称:"CS_light_purple", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/14.png'}),
(CS_dark_pink:TSC_Color_Patterns {名称:"CS_dark_pink", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/15.png'}),
(CS_dark_beige:TSC_Color_Patterns {名称:"CS_dark_beige", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/16.png'}),
(CS_medium_purple:TSC_Color_Patterns {名称:"CS_medium_purple", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/17.png'}),
(CS_light_gray:TSC_Color_Patterns {名称:"CS_light_gray", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/18.png'}),
(CS_light_green:TSC_Color_Patterns {名称:"CS_light_green", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/19.png'}),
(CS_dark_purple:TSC_Color_Patterns {名称:"CS_dark_purple", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/20.png'}),
(CS_medium_gray:TSC_Color_Patterns {名称:"CS_medium_gray", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/21.png'}),
(CS_medium_green:TSC_Color_Patterns {名称:"CS_medium_green", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/22.png'}),
(CS_light_brown:TSC_Color_Patterns {名称:"CS_light_brown", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/23.png'}),
(CS_dark_gray:TSC_Color_Patterns {名称:"CS_dark_gray", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/24.png'}),
(CS_dark_green:TSC_Color_Patterns {名称:"CS_dark_green", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/25.png'}),
(CS_medium_brown:TSC_Color_Patterns {名称:"CS_medium_brown", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/26.png'}),
(two_tone_beige:TSC_Color_Patterns {名称:"two_tone_beige", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/27.png'}),
(CS_light_olive_green:TSC_Color_Patterns {名称:"CS_light_olive_green", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/28.png'}),
(CS_dark_brown:TSC_Color_Patterns {名称:"CS_dark_brown", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/29.png'}),
(two_tone_olive_green:TSC_Color_Patterns {名称:"two_tone_olive_green", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/30.png'}),
(CS_medium_olive_green:TSC_Color_Patterns {名称:"CS_medium_olive_green", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/31.png'}),
(CS_light_red:TSC_Color_Patterns {名称:"CS_light_red", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/32.png'}),
(two_tone_blue:TSC_Color_Patterns {名称:"two_tone_blue", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/33.png'}),
(CS_dark_olive_green:TSC_Color_Patterns {名称:"CS_dark_olive_green", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/34.png'}),
(CS_medium_red:TSC_Color_Patterns {名称:"CS_medium_red", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/35.png'}),
(two_tone_red:TSC_Color_Patterns {名称:"two_tone_red", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/36.png'}),
(CS_light_seagreen:TSC_Color_Patterns {名称:"CS_light_seagreen", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/37.png'}),
(CS_dark_red:TSC_Color_Patterns {名称:"CS_dark_red", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/38.png'}),
(two_tone_gray:TSC_Color_Patterns {名称:"two_tone_gray", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/38.png'}),
(CS_medium_seagreen:TSC_Color_Patterns {名称:"CS_medium_seagreen", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/40.png'}),
(CS_light_orange:TSC_Color_Patterns {名称:"CS_light_orange", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/41.png'}),
(two_tone_red_green:TSC_Color_Patterns {名称:"two_tone_red_green", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/42.png'}),
(CS_dark_seagreen:TSC_Color_Patterns {名称:"CS_dark_seagreen", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/43.png'}),
(CS_medium_orange:TSC_Color_Patterns {名称:"CS_medium_orange", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/44.png'}),
(CS_light_blue:TSC_Color_Patterns {名称:"CS_light_blue", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/45.png'}),
(CS_dark_orange:TSC_Color_Patterns {名称:"CS_dark_orange", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/46.png'}),
(CS_medium_blue:TSC_Color_Patterns {名称:"CS_medium_blue", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/47.png'}),
(CS_light_magenta:TSC_Color_Patterns {名称:"CS_light_magenta", image:'http://huzhichen-xuanwuyan.oss-cn-beijing.aliyuncs.com/image/TSC-Color-Patterns/48.png'}),
(TSC_Color_Patterns)-[:TSC_Color_Patterns]->(Lithostratigraphic_Patterns),
(CS_light_yellow)-[:CS_light_yellow]->(TSC_Color_Patterns),
(CS_dark_blue)-[:CS_dark_blue]->(TSC_Color_Patterns),
(CS_medium_magenta)-[:CS_medium_magenta]->(TSC_Color_Patterns),
(CS_medium_yellow)-[:CS_medium_yellow]->(TSC_Color_Patterns),
(CS_light_navy)-[:CS_light_navy]->(TSC_Color_Patterns),
(CS_dark_magenta)-[:CS_dark_magenta]->(TSC_Color_Patterns),
(CS_dark_yellow)-[:CS_dark_yellow]->(TSC_Color_Patterns),
(CS_medium_navy)-[:CS_medium_navy]->(TSC_Color_Patterns),
(CS_light_pink)-[:CS_light_pink]->(TSC_Color_Patterns),
(CS_light_beige)-[:CS_light_beige]->(TSC_Color_Patterns),
(CS_dark_navy)-[:CS_dark_navy]->(TSC_Color_Patterns),
(CS_medium_pink)-[:CS_medium_pink]->(TSC_Color_Patterns),
(CS_medium_beige)-[:CS_medium_beige]->(TSC_Color_Patterns),
(CS_light_purple)-[:CS_light_purple]->(TSC_Color_Patterns),
(CS_dark_pink)-[:CS_dark_pink]->(TSC_Color_Patterns),
(CS_dark_beige)-[:CS_dark_beige]->(TSC_Color_Patterns),
(CS_medium_purple)-[:CS_medium_purple]->(TSC_Color_Patterns),
(CS_light_gray)-[:CS_light_gray]->(TSC_Color_Patterns),
(CS_light_green)-[:CS_light_green]->(TSC_Color_Patterns),
(CS_dark_purple)-[:CS_dark_purple]->(TSC_Color_Patterns),
(CS_medium_gray)-[:CS_medium_gray]->(TSC_Color_Patterns),
(CS_medium_green)-[:CS_medium_green]->(TSC_Color_Patterns),
(CS_light_brown)-[:CS_light_brown]->(TSC_Color_Patterns),
(CS_dark_gray)-[:CS_dark_gray]->(TSC_Color_Patterns),
(CS_dark_green)-[:CS_dark_green]->(TSC_Color_Patterns),
(CS_medium_brown)-[:CS_medium_brown]->(TSC_Color_Patterns),
(two_tone_beige)-[:two_tone_beige]->(TSC_Color_Patterns),
(CS_light_olive_green)-[:CS_light_olive_green]->(TSC_Color_Patterns),
(CS_dark_brown)-[:CS_dark_brown]->(TSC_Color_Patterns),
(two_tone_olive_green)-[:two_tone_olive_green]->(TSC_Color_Patterns),
(CS_medium_olive_green)-[:CS_medium_olive_green]->(TSC_Color_Patterns),
(CS_light_red)-[:CS_light_red]->(TSC_Color_Patterns),
(two_tone_blue)-[:two_tone_blue]->(TSC_Color_Patterns),
(CS_dark_olive_green)-[:CS_dark_olive_green]->(TSC_Color_Patterns),
(CS_medium_red)-[:CS_medium_red]->(TSC_Color_Patterns),
(two_tone_red)-[:two_tone_red]->(TSC_Color_Patterns),
(CS_light_seagreen)-[:CS_light_seagreen]->(TSC_Color_Patterns),
(CS_dark_red)-[:CS_dark_red]->(TSC_Color_Patterns),
(two_tone_gray)-[:two_tone_gray]->(TSC_Color_Patterns),
(CS_medium_seagreen)-[:CS_medium_seagreen]->(TSC_Color_Patterns),
(CS_light_orange)-[:CS_light_orange]->(TSC_Color_Patterns),
(two_tone_red_green)-[:two_tone_red_green]->(TSC_Color_Patterns),
(CS_dark_seagreen)-[:CS_dark_seagreen]->(TSC_Color_Patterns),
(CS_medium_orange)-[:CS_medium_orange]->(TSC_Color_Patterns),
(CS_light_blue)-[:CS_light_blue]->(TSC_Color_Patterns),
(CS_dark_orange)-[:CS_dark_orange]->(TSC_Color_Patterns),
(CS_medium_blue)-[:CS_medium_blue]->(TSC_Color_Patterns),
(CS_light_magenta)-[:CS_light_magenta]->(TSC_Color_Patterns)
RETURN *;
这里数据集怎么来的当然是一个个截图啦,其实用了OpenCV,因为都是方形的,做一下区域分割,其实对图方便来说一个个截图也是可行的方法。然后一个个截图完对应好标签,上传就ok了,具体怎么是怎么做的,之后会有详细的博客,等我手上比赛做完我在来写图形的。
这个也是个很简单需求,只是需要发挥想象,其实工业界技术早比学术文章中提到的方法要更多。用的技术也很简单,只是一个中文Neo4j就行了。只是思想不滑坡,办法总比问题多。