Commit d94169eb authored by Alexander Lercher's avatar Alexander Lercher

Semantic Linking: working semantic linking logic without integration

parent b365f613
import networkx as nx import networkx as nx
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from collections import Counter from collections import Counter
import initialdemo.HyperGraph as hg import HyperGraph as hg
import pandas as pd import pandas as pd
import json import json
import warnings import warnings
...@@ -12,6 +12,13 @@ import mplleaflet ...@@ -12,6 +12,13 @@ import mplleaflet
import values as values import values as values
from matplotlib import colors from matplotlib import colors
# pip install networkx
# pip install matplotlib
# pip install pandas
# pip install community
# pip install mplleaflet
# pip install values
class SemanticLinking: class SemanticLinking:
def __init__(self): def __init__(self):
...@@ -100,6 +107,7 @@ class SemanticLinking: ...@@ -100,6 +107,7 @@ class SemanticLinking:
weight1 = [] weight1 = []
node_adjacencies = [] node_adjacencies = []
labeling = {}
def drawedges(self): def drawedges(self):
...@@ -116,7 +124,7 @@ class SemanticLinking: ...@@ -116,7 +124,7 @@ class SemanticLinking:
self.G.__setattr__('weight', self.weight1) self.G.__setattr__('weight', self.weight1)
def labeling(self): def dolabeling(self):
"""label_propagation_communities(G) """ """label_propagation_communities(G) """
...@@ -201,7 +209,7 @@ class SemanticLinking: ...@@ -201,7 +209,7 @@ class SemanticLinking:
def main(self): def main(self):
self.drawedges() self.drawedges()
self.labeling() self.dolabeling()
self.findigneighbors() self.findigneighbors()
self.result() self.result()
......
...@@ -2,16 +2,13 @@ import json ...@@ -2,16 +2,13 @@ import json
import requests import requests
from threading import Thread from threading import Thread
import network_constants as netconst import network_constants as netconst
from intelligence_zahra.Processor import Processor
import logging import logging
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
class MessageHandler: class MessageHandler:
_processor: Processor = None
def __init__(self): def __init__(self):
self._processor = Processor() pass
def handle_generic(self, body): def handle_generic(self, body):
LOGGER.info(f"Received message: {body}") LOGGER.info(f"Received message: {body}")
...@@ -43,6 +40,7 @@ class MessageHandler: ...@@ -43,6 +40,7 @@ class MessageHandler:
if response.status_code == 200: if response.status_code == 200:
traces = response.json() traces = response.json()
Thread(target=self._processor.process(traces)).start() # TODO integrate zahras code
# Thread(target=self._processor.process(traces)).start()
else: else:
LOGGER.error(f"Could not retrieve JSON from {url} with GET request ({response.status_code})") LOGGER.error(f"Could not retrieve JSON from {url} with GET request ({response.status_code})")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment