Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
b365f613
Commit
b365f613
authored
Sep 09, 2019
by
zahra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Semantic Linking: Created Classes for semantic linking logic
parent
2caa4a25
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
843 additions
and
240 deletions
+843
-240
Created_classes_for_semantic_linking_logic.patch
...vice/app/Created_classes_for_semantic_linking_logic.patch
+602
-0
HyperGraph.py
...mantic-linking-microservice/app/initialdemo/HyperGraph.py
+92
-95
SemanticLinking.py
...c-linking-microservice/app/initialdemo/SemanticLinking.py
+149
-145
No files found.
data-hub/semantic-linking-microservice/app/Created_classes_for_semantic_linking_logic.patch
0 → 100644
View file @
b365f613
This diff is collapsed.
Click to expand it.
data-hub/semantic-linking-microservice/app/initialdemo/HyperGraph.py
View file @
b365f613
import
networkx
as
nx
import
matplotlib.pyplot
as
plt
import
pandas
as
pd
import
json
import
json
nodeIds
=
[]
destIds
=
[]
clusterlabels
=
[]
destclusterlabel
=
[]
cluster
=
[]
labalvlues
=
[]
def
classify
():
with
open
(
"mult_in_out.json"
,
"r"
)
as
json_file
:
with
open
(
"mult_in_out.json"
,
"r"
)
as
json_file
:
df_nodes
=
json
.
load
(
json_file
)
df_nodes
=
json
.
load
(
json_file
)
nodeIds
=
[]
destIds
=
[]
clusterlabels
=
[]
destclusterlabel
=
[]
cluster
=
[]
labalvlues
=
[]
i
=
0
for
row
in
df_nodes
:
for
row
in
df_nodes
:
for
j
in
range
(
len
(
row
[
'TransactionFrom'
])):
for
j
in
range
(
len
(
row
[
'TransactionFrom'
])):
print
(
" Input Ids: "
,
row
[
'TransactionFrom'
][
j
])
print
(
" Input Ids: "
,
row
[
'TransactionFrom'
][
j
])
...
@@ -26,23 +22,24 @@ for row in df_nodes:
...
@@ -26,23 +22,24 @@ for row in df_nodes:
print
(
"This is nodes: "
,
nodeIds
)
print
(
"This is nodes: "
,
nodeIds
)
for
row
in
df_nodes
:
for
row
in
df_nodes
:
destIds
.
append
(
row
[
'TransactionTo'
])
destIds
.
append
(
row
[
'TransactionTo'
])
for
row
in
range
(
len
(
nodeIds
)):
for
row
in
range
(
len
(
nodeIds
)):
print
(
nodeIds
[
row
])
print
(
nodeIds
[
row
])
print
(
"Finish InputIDs"
)
print
(
"Finish InputIDs"
)
for
row
in
range
(
len
(
nodeIds
)):
i
=
0
for
row
in
range
(
len
(
nodeIds
)):
clusterlabels
.
append
(
row
)
clusterlabels
.
append
(
row
)
i
+=
1
i
+=
1
print
(
i
)
print
(
i
)
"""" classifying Inputs"""
"""" classifying Inputs"""
"""" Labaling inputs"""
"""" Labaling inputs"""
for
row
in
range
(
len
(
nodeIds
)):
for
row
in
range
(
len
(
nodeIds
)):
for
rown
in
range
(
len
(
nodeIds
[
row
])):
for
rown
in
range
(
len
(
nodeIds
[
row
])):
...
@@ -63,16 +60,16 @@ for row in range(len(nodeIds)):
...
@@ -63,16 +60,16 @@ for row in range(len(nodeIds)):
clusterlabels
[
row
]
=
clusterlabels
[
row1
]
clusterlabels
[
row
]
=
clusterlabels
[
row1
]
print
(
clusterlabels
)
print
(
clusterlabels
)
print
(
"cluster labels:"
,
len
(
clusterlabels
))
print
(
"cluster labels:"
,
len
(
clusterlabels
))
print
(
"NodeIDs: "
,
len
(
nodeIds
))
print
(
"NodeIDs: "
,
len
(
nodeIds
))
"""" Calculating the number of clusters"""
"""" Calculating the number of clusters"""
clusternum
=
1
clusternum
=
1
labalvlues
.
append
(
clusterlabels
[
0
])
labalvlues
.
append
(
clusterlabels
[
0
])
for
row
in
range
(
len
(
clusterlabels
)):
for
row
in
range
(
len
(
clusterlabels
)):
flag
=
True
flag
=
True
for
row1
in
range
(
len
(
labalvlues
)):
for
row1
in
range
(
len
(
labalvlues
)):
if
(
clusterlabels
[
row
]
==
labalvlues
[
row1
]):
if
(
clusterlabels
[
row
]
==
labalvlues
[
row1
]):
...
@@ -82,26 +79,26 @@ for row in range(len(clusterlabels)):
...
@@ -82,26 +79,26 @@ for row in range(len(clusterlabels)):
clusternum
=
+
1
clusternum
=
+
1
labalvlues
.
append
(
clusterlabels
[
row
])
labalvlues
.
append
(
clusterlabels
[
row
])
print
(
"label values (source Ids in the network): "
,
labalvlues
,
" and the number of clusters is: "
,
len
(
labalvlues
))
print
(
"label values (source Ids in the network): "
,
labalvlues
,
" and the number of clusters is: "
,
len
(
labalvlues
))
"""" clustering Ids according to their labels"""
"""" clustering Ids according to their labels"""
for
row
in
range
(
len
(
labalvlues
)):
for
row
in
range
(
len
(
labalvlues
)):
cluster
.
append
([])
cluster
.
append
([])
for
row3
in
range
(
len
(
nodeIds
)):
for
row3
in
range
(
len
(
nodeIds
)):
if
(
labalvlues
[
row
]
==
clusterlabels
[
row3
]):
if
(
labalvlues
[
row
]
==
clusterlabels
[
row3
]):
cluster
[
row
]
.
extend
(
nodeIds
[
row3
])
cluster
[
row
]
.
extend
(
nodeIds
[
row3
])
print
(
"clusters: "
,
cluster
)
print
(
"clusters: "
,
cluster
)
""" Removing duplicating items in cluster"""
""" Removing duplicating items in cluster"""
flag
=
True
flag
=
True
while
(
flag
):
while
(
flag
):
for
row
in
range
(
len
(
cluster
)):
for
row
in
range
(
len
(
cluster
)):
flag
=
False
flag
=
False
...
@@ -118,13 +115,13 @@ while(flag):
...
@@ -118,13 +115,13 @@ while(flag):
if
(
flag
):
if
(
flag
):
break
break
print
(
"cluster:"
,
cluster
)
print
(
"cluster:"
,
cluster
)
"""" Clustering Destination Ids """
"""" Clustering Destination Ids """
for
row
in
range
(
len
(
destIds
)):
for
row
in
range
(
len
(
destIds
)):
destclusterlabel
.
append
([])
destclusterlabel
.
append
([])
for
row2
in
range
(
len
(
destIds
[
row
])):
for
row2
in
range
(
len
(
destIds
[
row
])):
flag
=
True
flag
=
True
...
@@ -137,4 +134,4 @@ for row in range(len(destIds)):
...
@@ -137,4 +134,4 @@ for row in range(len(destIds)):
if
(
flag
):
if
(
flag
):
destclusterlabel
.
append
(
destIds
[
row
][
row2
])
destclusterlabel
.
append
(
destIds
[
row
][
row2
])
print
(
"destination labels (destination Ids): "
,
destclusterlabel
)
print
(
"destination labels (destination Ids): "
,
destclusterlabel
)
data-hub/semantic-linking-microservice/app/initialdemo/SemanticLinking.py
View file @
b365f613
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment