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
f18e7ea3
Commit
f18e7ea3
authored
Sep 23, 2019
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
applied oo
parent
ef2f767f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
144 additions
and
132 deletions
+144
-132
HyperGraph.py
...mantic-linking-microservice/app/initialdemo/HyperGraph.py
+144
-132
No files found.
data-hub/semantic-linking-microservice/app/initialdemo/HyperGraph.py
View file @
f18e7ea3
import
json
class
HyperGraph
:
def
do
():
df_nodes
=
load_values
()
cluster_labels
=
[]
dest_cluster_labels
=
[]
label_values
=
[]
ret_val
=
init
(
df_nodes
)
def
__init__
(
self
):
pass
def
classify
(
self
):
df_nodes
=
self
.
load_values
()
ret_val
=
self
.
init
(
df_nodes
)
nodeIds
=
ret_val
[
'nodeIds'
]
clusterlabels
=
ret_val
[
'clusterlabels'
]
destIds
=
ret_val
[
'destIds'
]
clusterlabels
=
classify_input
(
nodeIds
,
clusterlabels
)
clusterlabels
=
self
.
classify_input
(
nodeIds
,
clusterlabels
)
labelvals
=
self
.
calc_cluster_num
(
clusterlabels
)
labelvals
=
calc_cluster_num
(
clusterlabe
ls
)
cluster
=
self
.
cluster_with_labels
(
nodeIds
,
clusterlabels
,
labelva
ls
)
cluster
=
cluster_with_labels
(
nodeIds
,
clusterlabels
,
labelvals
)
cluster
=
self
.
remove_duplicates
(
cluster
)
cluster
=
remove_duplicates
(
cluster
)
destclusterlabel
=
self
.
cluster_dest_ids
(
labelvals
,
cluster
,
destIds
)
destclusterlabel
=
cluster_dest_ids
(
labelvals
,
cluster
,
destIds
)
self
.
cluster_labels
=
clusterlabels
self
.
dest_cluster_labels
=
destclusterlabel
self
.
labelvals
=
labelvals
def
load_values
(
):
def
load_values
(
self
):
with
open
(
"mult_in_out_large.json"
,
"r"
)
as
json_file
:
df_nodes
=
json
.
load
(
json_file
)
return
df_nodes
def
init
(
df_nodes
):
def
init
(
self
,
df_nodes
):
nodeIds
=
[]
clusterlabels
=
[]
destIds
=
[]
...
...
@@ -53,7 +65,7 @@ def init(df_nodes):
'clusterlabels'
:
clusterlabels
,
'destIds'
:
destIds
}
def
classify_input
(
nodeIds
,
clusterlabels
):
def
classify_input
(
self
,
nodeIds
,
clusterlabels
):
"""" classifying Inputs"""
"""" Labaling inputs"""
for
row
in
range
(
len
(
nodeIds
)):
...
...
@@ -81,7 +93,7 @@ def classify_input(nodeIds, clusterlabels):
print
(
"NodeIDs: "
,
len
(
nodeIds
))
return
clusterlabels
def
calc_cluster_num
(
clusterlabels
):
def
calc_cluster_num
(
self
,
clusterlabels
):
"""" Calculating the number of clusters"""
labelvals
=
[]
...
...
@@ -99,7 +111,7 @@ def calc_cluster_num(clusterlabels):
return
labelvals
def
cluster_with_labels
(
nodeIds
,
clusterlabels
,
labelvals
):
def
cluster_with_labels
(
self
,
nodeIds
,
clusterlabels
,
labelvals
):
"""" clustering Ids according to their labels"""
cluster
=
[]
...
...
@@ -112,7 +124,7 @@ def cluster_with_labels(nodeIds, clusterlabels, labelvals):
return
cluster
def
remove_duplicates
(
cluster
):
def
remove_duplicates
(
self
,
cluster
):
""" Removing duplicating items in cluster"""
flag
=
True
...
...
@@ -137,7 +149,7 @@ def remove_duplicates(cluster):
return
cluster
def
cluster_dest_ids
(
labelvals
,
cluster
,
destIds
):
def
cluster_dest_ids
(
self
,
labelvals
,
cluster
,
destIds
):
"""" Clustering Destination Ids """
destclusterlabel
=
[]
...
...
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