diff --git a/KNN_predict/neo_models.py b/KNN_predict/neo_models.py index 47b5b9d..e708622 100644 --- a/KNN_predict/neo_models.py +++ b/KNN_predict/neo_models.py @@ -3,14 +3,20 @@ from py2neo import Graph,Node,Relationship from read_csv import readCSV2 from hudong_class import HudongItem - +import configparser class Neo4j(): graph = None def __init__(self): print("create neo4j class ...") def connectDB(self): - self.graph = Graph("http://localhost:7474", username="neo4j", password="8313178") + conf = configparser.ConfigParser() + conf.read('demo/neo4jconfig') + url = conf.get("neo4jdb", "url") + username = conf.get("neo4jdb", "username") + password = conf.get("neo4jdb", "password") + self.graph = Graph(url, username=username, password=password) + # self.graph = Graph("http://localhost:7474", username="neo4j", password="abc123") def matchItembyTitle(self,value): answer = self.graph.find_one(label="Item",property_key="title",property_value=value) diff --git a/demo/Model/neo_models.py b/demo/Model/neo_models.py index 47bfd4b..60cd5c6 100644 --- a/demo/Model/neo_models.py +++ b/demo/Model/neo_models.py @@ -1,4 +1,5 @@ from py2neo import Graph,Node,Relationship +import configparser class Neo4j(): graph = None @@ -6,8 +7,12 @@ def __init__(self): print("create neo4j class ...") def connectDB(self): - self.graph = Graph("http://localhost:7474", username="neo4j", password="123456") - + conf = configparser.ConfigParser() + conf.read('demo/neo4jconfig') + url = conf.get("neo4jdb", "url") + username = conf.get("neo4jdb", "username") + password = conf.get("neo4jdb", "password") + self.graph = Graph(url, username=username, password=password) def matchItembyTitle(self,value): answer = self.graph.find_one(label="Item",property_key="title",property_value=value) return answer diff --git a/demo/demo/neo4jconfig b/demo/demo/neo4jconfig new file mode 100644 index 0000000..d51d505 --- /dev/null +++ b/demo/demo/neo4jconfig @@ -0,0 +1,4 @@ +[neo4jdb] +url = http://192.168.1.16:7474 +username = neo4j +password = abc123 \ No newline at end of file diff --git a/demo/demo/tagging_data_view.py b/demo/demo/tagging_data_view.py index b1d3846..e188e42 100644 --- a/demo/demo/tagging_data_view.py +++ b/demo/demo/tagging_data_view.py @@ -102,7 +102,7 @@ def showtagging_data(request): # 统计当前标注情况 - file_object = open('label_data/labels.txt','r') + file_object = open('label_data/labels.txt','r',encoding='utf-8') s = [] sum = 0 for i in range(17): diff --git a/demo/demo/tagging_data_writefile_view.py b/demo/demo/tagging_data_writefile_view.py index 551a1c8..d90cb85 100644 --- a/demo/demo/tagging_data_writefile_view.py +++ b/demo/demo/tagging_data_writefile_view.py @@ -12,14 +12,14 @@ def tagging_push(request): ctx = {} # 先将已有的labels存入字典中 - file_object = open('label_data/labels.txt','r') + file_object = open('label_data/labels.txt','r',encoding='utf-8') s = set() for f in file_object: pair = f.split() s.add(pair[0].strip()) file_object.close() - file_object = open('label_data/word_list.txt','r') + file_object = open('label_data/word_list.txt','r',encoding='utf-8') all_list = [] for f in file_object: all_list.append(f.strip()) @@ -30,7 +30,7 @@ def tagging_push(request): title = request.GET['title'].strip() label = request.GET['label'].strip() if label != None: - file_object = open('label_data/labels.txt','a') + file_object = open('label_data/labels.txt','a',encoding='utf-8') if title in s: print("该title已存在,冲突!") else: diff --git a/demo/label_data/labels.txt b/demo/label_data/labels.txt index 7d91f38..947b510 100644 --- a/demo/label_data/labels.txt +++ b/demo/label_data/labels.txt @@ -5612,3 +5612,5 @@ Sugar 0 auxin 0 红十字 3 氟氰戊菊酯 7 +狗肾 13 +昆明池 2 diff --git a/demo/static/js/jquery.metisMenu.js b/demo/static/js/jquery.metisMenu.js new file mode 100644 index 0000000..6f22eff --- /dev/null +++ b/demo/static/js/jquery.metisMenu.js @@ -0,0 +1,10 @@ +/* + * metismenu - v2.0.2 + * A jQuery menu plugin + * https://github.com/onokumus/metisMenu + * + * Made by Osman Nuri Okumus + * Under MIT License + */ + +!function(a){"use strict";function b(){var a=document.createElement("mm"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}function c(b){return this.each(function(){var c=a(this),d=c.data("mm"),f=a.extend({},e.DEFAULTS,c.data(),"object"==typeof b&&b);d||c.data("mm",d=new e(this,f)),"string"==typeof b&&d[b]()})}a.fn.emulateTransitionEnd=function(b){var c=!1,e=this;a(this).one("mmTransitionEnd",function(){c=!0});var f=function(){c||a(e).trigger(d.end)};return setTimeout(f,b),this};var d=b();d&&(a.event.special.mmTransitionEnd={bindType:d.end,delegateType:d.end,handle:function(b){return a(b.target).is(this)?b.handleObj.handler.apply(this,arguments):void 0}});var e=function(b,c){this.$element=a(b),this.options=a.extend({},e.DEFAULTS,c),this.transitioning=null,this.init()};e.TRANSITION_DURATION=350,e.DEFAULTS={toggle:!0,doubleTapToGo:!1,activeClass:"active"},e.prototype.init=function(){var b=this,c=this.options.activeClass;this.$element.find("li."+c).has("ul").children("ul").addClass("collapse in"),this.$element.find("li").not("."+c).has("ul").children("ul").addClass("collapse"),this.options.doubleTapToGo&&this.$element.find("li."+c).has("ul").children("a").addClass("doubleTapToGo"),this.$element.find("li").has("ul").children("a").on("click.metisMenu",function(d){var e=a(this),f=e.parent("li"),g=f.children("ul");return d.preventDefault(),f.hasClass(c)?b.hide(g):b.show(g),b.options.doubleTapToGo&&b.doubleTapToGo(e)&&"#"!==e.attr("href")&&""!==e.attr("href")?(d.stopPropagation(),void(document.location=e.attr("href"))):void 0})},e.prototype.doubleTapToGo=function(a){var b=this.$element;return a.hasClass("doubleTapToGo")?(a.removeClass("doubleTapToGo"),!0):a.parent().children("ul").length?(b.find(".doubleTapToGo").removeClass("doubleTapToGo"),a.addClass("doubleTapToGo"),!1):void 0},e.prototype.show=function(b){var c=this.options.activeClass,f=a(b),g=f.parent("li");if(!this.transitioning&&!f.hasClass("in")){g.addClass(c),this.options.toggle&&this.hide(g.siblings().children("ul.in")),f.removeClass("collapse").addClass("collapsing").height(0),this.transitioning=1;var h=function(){f.removeClass("collapsing").addClass("collapse in").height(""),this.transitioning=0};return d?void f.one("mmTransitionEnd",a.proxy(h,this)).emulateTransitionEnd(e.TRANSITION_DURATION).height(f[0].scrollHeight):h.call(this)}},e.prototype.hide=function(b){var c=this.options.activeClass,f=a(b);if(!this.transitioning&&f.hasClass("in")){f.parent("li").removeClass(c),f.height(f.height())[0].offsetHeight,f.addClass("collapsing").removeClass("collapse").removeClass("in"),this.transitioning=1;var g=function(){this.transitioning=0,f.removeClass("collapsing").addClass("collapse")};return d?void f.height(0).one("mmTransitionEnd",a.proxy(g,this)).emulateTransitionEnd(e.TRANSITION_DURATION):g.call(this)}};var f=a.fn.metisMenu;a.fn.metisMenu=c,a.fn.metisMenu.Constructor=e,a.fn.metisMenu.noConflict=function(){return a.fn.metisMenu=f,this}}(jQuery); \ No newline at end of file diff --git a/demo/templates/base.html b/demo/templates/base.html index b1d9c87..9ae0b78 100644 --- a/demo/templates/base.html +++ b/demo/templates/base.html @@ -17,7 +17,7 @@ - ECNU 农业知识图谱 + 知识图谱 @@ -25,13 +25,15 @@ - - + + + + @@ -39,8 +41,10 @@ + + @@ -48,7 +52,6 @@ - - - - -
- - +
+
+
+
+
-
- - - -
+ + + +
+
+ + {% block mainbody %}

original page

- {% endblock %} + {% endblock %} -
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -218,57 +315,65 @@ $(function() { $('select.styled').customSelect(); + }); - - /* ---------- Map ---------- */ - $(function() { - $('#map').vectorMap({ - map: 'world_mill_en', - series: { - regions: [{ - values: gdpData, - scale: ['#000', '#000'], - normalizeFunction: 'polynomial' - }] - }, - backgroundColor: '#eef3f7', - onLabelShow: function(e, el, code) { - el.html(el.html() + ' (GDP - ' + gdpData[code] + ')'); - } - }); + }); + + //custom select box + + $(function () { + $('select.styled').customSelect(); + }); + + /* ---------- Map ---------- */ + $(function () { + $('#map').vectorMap({ + map: 'world_mill_en', + series: { + regions: [{ + values: gdpData, + scale: ['#000', '#000'], + normalizeFunction: 'polynomial' + }] + }, + backgroundColor: '#eef3f7', + onLabelShow: function (e, el, code) { + el.html(el.html() + ' (GDP - ' + gdpData[code] + ')'); + } }); - - tagcloud({ //开启词云 - //参数名: 默认值 - selector: ".tagcloud", //元素选择器 - fontsize: 15, //基本字体大小 - radius: 55, //滚动半径 - mspeed: "slow", //滚动最大速度 - ispeed: "slow", //滚动初速度 - direction: 135, //初始滚动方向 - keep: true //鼠标移出组件后是否继续随鼠标滚动 + }); + + tagcloud({ //开启词云 + //参数名: 默认值 + selector: ".tagcloud", //元素选择器 + fontsize: 15, //基本字体大小 + radius: 55, //滚动半径 + mspeed: "slow", //滚动最大速度 + ispeed: "slow", //滚动初速度 + direction: 135, //初始滚动方向 + keep: true //鼠标移出组件后是否继续随鼠标滚动 + }); + + + + - - - - - + + }); + + - - e diff --git a/dfs_tree_crawler/neo_models.py b/dfs_tree_crawler/neo_models.py index ce2c747..0ef617a 100644 --- a/dfs_tree_crawler/neo_models.py +++ b/dfs_tree_crawler/neo_models.py @@ -1,4 +1,5 @@ # coding: utf-8 +import configparser from py2neo import Graph,Node,Relationship from hudong_class import HudongItem @@ -9,7 +10,13 @@ def __init__(self): print("create neo4j class ...") def connectDB(self): - self.graph = Graph("http://localhost:7474", username="neo4j", password="8313178") + conf = configparser.ConfigParser() + conf.read('demo/neo4jconfig') + url = conf.get("neo4jdb", "url") + username = conf.get("neo4jdb", "username") + password = conf.get("neo4jdb", "password") + self.graph = Graph(url, username=username, password=password) + # self.graph = Graph("http://localhost:7474", username="neo4j", password="abc123") print('connect successed') def matchItembyTitle(self,value): diff --git a/predict label/neo_models.py b/predict label/neo_models.py index 75f3c71..6dd5447 100644 --- a/predict label/neo_models.py +++ b/predict label/neo_models.py @@ -3,6 +3,7 @@ from py2neo import Graph,Node,Relationship from read_csv import readCSV2 from hudong_class import HudongItem +import configparser class Neo4j(): graph = None @@ -10,7 +11,13 @@ def __init__(self): print("create neo4j class ...") def connectDB(self): - self.graph = Graph("http://localhost:7474", username="neo4j", password="8313178") + conf = configparser.ConfigParser() + conf.read('demo/neo4jconfig') + url = conf.get("neo4jdb", "url") + username = conf.get("neo4jdb", "username") + password = conf.get("neo4jdb", "password") + self.graph = Graph(url, username=username, password=password) + # self.graph = Graph("http://localhost:7474", username="neo4j", password="abc123") def matchItembyTitle(self,value): answer = self.graph.find_one(label="Item",property_key="title",property_value=value) diff --git a/wikidataSpider/wikidataProcessing/relationDataProcessing.py b/wikidataSpider/wikidataProcessing/relationDataProcessing.py index e7eb541..015e28c 100644 --- a/wikidataSpider/wikidataProcessing/relationDataProcessing.py +++ b/wikidataSpider/wikidataProcessing/relationDataProcessing.py @@ -2,13 +2,21 @@ from py2neo import Node, Relationship ,Graph from langconv import * import re +import configparser + class loadDatatoNeo4j(object): graph = None def __init__(self): print("start load data ...") def connectDB(self): - self.graph = Graph("http://localhost:7474",username = "neo4j" , password = "8313178") - print("connect neo4j success!") + conf = configparser.ConfigParser() + conf.read('demo/neo4jconfig') + url = conf.get("neo4jdb", "url") + username = conf.get("neo4jdb", "username") + password = conf.get("neo4jdb", "password") + self.graph = Graph(url, username=username, password=password) + # self.graph = Graph("http://localhost:7474",username = "neo4j" , password = "abc123") + print("connect neo4j success! username:" +username) def readData(self): count = 0