Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ww #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

ww #10

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions KNN_predict/neo_models.py
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 7 additions & 2 deletions demo/Model/neo_models.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
from py2neo import Graph,Node,Relationship
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="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
4 changes: 4 additions & 0 deletions demo/demo/neo4jconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[neo4jdb]
url = http://192.168.1.16:7474
username = neo4j
password = abc123
2 changes: 1 addition & 1 deletion demo/demo/tagging_data_view.py
Original file line number Diff line number Diff line change
@@ -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):
6 changes: 3 additions & 3 deletions demo/demo/tagging_data_writefile_view.py
Original file line number Diff line number Diff line change
@@ -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:
2 changes: 2 additions & 0 deletions demo/label_data/labels.txt
Original file line number Diff line number Diff line change
@@ -5612,3 +5612,5 @@ Sugar 0
auxin 0
红十字 3
氟氰戊菊酯 7
狗肾 13
昆明池 2
10 changes: 10 additions & 0 deletions demo/static/js/jquery.metisMenu.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

309 changes: 206 additions & 103 deletions demo/templates/base.html
Original file line number Diff line number Diff line change
@@ -17,38 +17,41 @@
<meta name="keyword" content="Creative, Dashboard, Admin, Template, Theme, Bootstrap, Responsive, Retina, Minimal">
<link rel="shortcut icon" href="/static/img/favicon.png">

<title>ECNU 农业知识图谱</title>
<title>知识图谱</title>

<!-- Bootstrap CSS -->
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
<!-- bootstrap theme -->
<link href="/static/css/bootstrap-theme.css" rel="stylesheet">
<!--external css-->
<!-- font icon -->
<link href="/static/css/elegant-icons-style.css" rel="stylesheet" />
<link href="/static/css/font-awesome.min.css" rel="stylesheet" />
<link href="/static/css/elegant-icons-style.css" rel="stylesheet"/>
<link href="/static/css/font-awesome.min.css" rel="stylesheet"/>
<!-- full calendar css-->

<!-- <link href="/static/assets/fullcalendar/fullcalendar/bootstrap-fullcalendar.css" rel="stylesheet" />
<link href="/static/assets/fullcalendar/fullcalendar/fullcalendar.css" rel="stylesheet" /> -->
<!-- easy pie chart-->
<!-- <link href="/static/assets/jquery-easy-pie-chart/jquery.easy-pie-chart.css" rel="stylesheet" type="text/css" media="screen" /> -->

<!-- owl carousel -->
<!-- <link rel="stylesheet" href="/static/css/owl.carousel.css" type="text/css">
<link href="/static/css/jquery-jvectormap-1.2.2.css" rel="stylesheet"> -->
<!-- Custom styles -->
<!-- <link rel="stylesheet" href="/static/css/fullcalendar.css"> -->
<!-- <link href="/static/css/widgets.css" rel="stylesheet"> -->
<link href="/static/css/style.css" rel="stylesheet">

<!-- <link href="/static/css/style-responsive.css" rel="stylesheet" /> -->
<!-- <link href="/static/css/xcharts.min.css" rel=" stylesheet"> -->

<link href="/static/css/jquery-ui-1.10.4.min.css" rel="stylesheet">
<link href="/static/css/tagcloud.css" rel="stylesheet">
<link href="/static/css/tree_style.css" rel="stylesheet">
<!--Footable CSS-->
<link href="/static/css/footable.bootstrap.min.css" rel="stylesheet">



<!-- HTML5 shim and Respond.js IE8 support of HTML5 -->
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
@@ -59,38 +62,39 @@
</head>

<body>
<section id="container" class="">
<header class="header dark-bg">
<div class="toggle-nav">
<div class="icon-reorder tooltips" data-original-title="隐藏/显示侧栏" data-placement="bottom">
<i class="fa fa-bars" aria-hidden="true"></i>
</div>
</div>

<!--logo start-->
<a href="/" class="logo"> 农业知识图谱 <span class="lite">demo</span></a>
<!--logo end-->


<div class="top-nav notification-row">
<!-- notificatoin dropdown start-->
<ul class="nav pull-right top-menu">
<li>
<a href='https://github.com/qq547276542/Agriculture_KnowledgeGraph'>
<i class="fa fa-github" aria-hidden="true"> open Github</i>
</a>
</li>
</ul>
<section id="container" class="">
<header class="header dark-bg">
<div class="toggle-nav">
<div class="icon-reorder tooltips" data-original-title="隐藏/显示侧栏" data-placement="bottom">
<i class="fa fa-bars" aria-hidden="true"></i>
</div>
</header>
<!--header end-->

<!--sidebar start-->
<aside>
<div id="sidebar" class="nav-collapse ">
<!-- sidebar menu start-->
<ul class="sidebar-menu">
<li class="active">
</div>

<!--logo start-->
<a href="/" class="logo"> 知识图谱 <span class="lite">demo</span></a>
<!--logo end-->


<div class="top-nav notification-row">
<!-- notificatoin dropdown start-->
<ul class="nav pull-right top-menu">
<li>
<a href='#'>
HOME
</a>
</li>
</ul>
</div>
</header>
<!--header end-->

<!--sidebar start-->
<aside>
<div id="sidebar" class="nav-collapse ">
<!-- sidebar menu start-->
<ul class="sidebar-menu">
<li class="active">
<a class="" href="/">
<i class="icon_house_alt"></i>
<span>实体识别</span>
@@ -104,37 +108,130 @@
</a>
</li>

<li>

<li>
<a class="" href="/search_relation">
<i class=" social_googledrive"></i>
<span>关系查询</span>
</a>
</li>

<li>
<a class="" href="/overview?node=农业">
<i class="icon_piechart"></i>
<span>农业知识概览</span>
</a>
</li>

</ul>
<!-- sidebar menu end-->
</div>
</aside>
<!--sidebar end-->
<!--main content start-->
<section id="main-content">
<section class="wrapper">

{% block mainbody %}
<li>
<a ><i class="fa fa-picture-o"></i> <span class="nav-label">专题</span><span
class="fa arrow"></span></a>
<ul class="nav nav-second-level collapse">
<li><a href="/overview?node=农业">农业知识</a></li>

</ul>
</li>


<li>
<a class="" href="/tagging-get">
<i class="icon_puzzle"></i>
<span>训练集标注</span>
</a>
</li>

</ul>
<!-- sidebar menu end-->
</div>
</aside>
<!--sidebar end-->
<!--main content start-->
<section id="main-content">
<section class="wrapper">

{% block mainbody %}
<p>original page</p>
{% endblock %}
{% endblock %}

</section>
</section>
</section>

</section>

<!-- javascripts -->
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/jquery-ui-1.10.4.min.js"></script>
<script type="text/javascript" src="/static/js/jquery-ui-1.9.2.custom.min.js"></script>

<script src="/static/js/popper.min.js"></script>
<!-- bootstrap -->
<script src="/static/js/bootstrap.min.js"></script>

<script src="/static/js/jquery.metisMenu.js"></script>

<!-- nice scroll -->
<script src="/static/js/jquery.scrollTo.min.js"></script>
<script src="/static/js/jquery.nicescroll.js" type="text/javascript"></script>
<!-- charts scripts -->
<script src="/static/assets/jquery-knob/js/jquery.knob.js"></script>
<script src="/static/js/jquery.sparkline.js" type="text/javascript"></script>
<script src="/static/assets/jquery-easy-pie-chart/jquery.easy-pie-chart.js"></script>
<script src="/static/js/owl.carousel.js"></script>
<!-- jQuery full calendar -->
<script src="/static/js/fullcalendar.min.js"></script>
<!-- Full Google Calendar - Calendar -->
<script src="/static/assets/fullcalendar/fullcalendar/fullcalendar.js"></script>
<!--script for this page only-->
<script src="/static/js/calendar-custom.js"></script>
<script src="/static/js/jquery.rateit.min.js"></script>
<!-- custom select -->
<script src="/static/js/jquery.customSelect.min.js"></script>
<script src="/static/assets/chart-master/Chart.js"></script>


<!-- custom script for this page-->
<script src="/static/js/sparkline-chart.js"></script>
<script src="/static/js/easy-pie-chart.js"></script>
<script src="/static/js/jquery-jvectormap-1.2.2.min.js"></script>
<script src="/static/js/jquery-jvectormap-world-mill-en.js"></script>
<script src="/static/js/xcharts.min.js"></script>
<script src="/static/js/jquery.autosize.min.js"></script>
<script src="/static/js/jquery.placeholder.min.js"></script>
<script src="/static/js/gdp-data.js"></script>
<script src="/static/js/morris.min.js"></script>
<script src="/static/js/sparklines.js"></script>
<script src="/static/js/charts.js"></script>
<script src="/static/js/jquery.slimscroll.min.js"></script>

<!-- bootstrap-wysiwyg -->
<script src="/static/js/jquery.hotkeys.js"></script>
<script src="/static/js/bootstrap-wysiwyg.js"></script>
<script src="/static/js/bootstrap-wysiwyg-custom.js"></script>

<script src="/static/js/gritter.js" type="text/javascript"></script>
<!-- <script src="/static/js/form-component.js"></script> -->
<!--custome script for all page-->
<script src="/static/js/scripts.js"></script>
<script src="/static/js/tagcloud.min.js"></script>

<!--Footable-->
<script src="/static/js/footable.min.js"></script>

<!-- 词云脚本 -->
<script>
//knob
$(function () {
$(".knob").knob({
'draw': function () {
$(this.i).val(this.cv + '%')
}
})
});

//carousel
$(document).ready(function () {
$('#sidebar').metisMenu();
$("#owl-slider").owlCarousel({
navigation: true,
slideSpeed: 300,
paginationSpeed: 400,
singleItem: true


<!-- javascripts -->
<script src="/static/js/jquery-1.8.3.min.js"></script>
<script src="/static/js/jquery-ui-1.10.4.min.js"></script>
@@ -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 //鼠标移出组件后是否继续随鼠标滚动
});
</script>

<!-- 分类树脚本 -->
<script>
$(function () {
$('.tree li:has(ul)').addClass('parent_li').find(' > span').attr('title', 'Collapse this branch');
$('.tree li.parent_li > span').on('click', function (e) {
var children = $(this).parent('li.parent_li').find(' > ul > li');
if (children.is(":visible")) {
children.hide('fast');
$(this).attr('title', 'Expand this branch').find(' > i').addClass('fa-plus-square').removeClass('fa-minus-square');
} else {
children.show('fast');
$(this).attr('title', 'Collapse this branch').find(' > i').addClass('fa-minus-square').removeClass('fa-plus-square');
}
e.stopPropagation();
});
</script>

<!-- 分类树脚本 -->
<script>
$(function() {
$('.tree li:has(ul)').addClass('parent_li').find(' > span').attr('title', 'Collapse this branch');
$('.tree li.parent_li > span').on('click', function(e) {
var children = $(this).parent('li.parent_li').find(' > ul > li');
if (children.is(":visible")) {
children.hide('fast');
$(this).attr('title', 'Expand this branch').find(' > i').addClass('fa-plus-square').removeClass('fa-minus-square');
} else {
children.show('fast');
$(this).attr('title', 'Collapse this branch').find(' > i').addClass('fa-minus-square').removeClass('fa-plus-square');
}
e.stopPropagation();
});
});
</script>

<!--百度统计js start-->

});
</script>
<!--百度统计js start-->
<script>
var _hmt = _hmt || [];
(function() {
@@ -278,8 +383,6 @@
s.parentNode.insertBefore(hm, s);
})();
</script>
<!--百度统计js end-->
e
</body>

</html>
9 changes: 8 additions & 1 deletion dfs_tree_crawler/neo_models.py
Original file line number Diff line number Diff line change
@@ -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):
9 changes: 8 additions & 1 deletion predict label/neo_models.py
Original file line number Diff line number Diff line change
@@ -3,14 +3,21 @@
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)
12 changes: 10 additions & 2 deletions wikidataSpider/wikidataProcessing/relationDataProcessing.py
Original file line number Diff line number Diff line change
@@ -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