-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from Knox-AAU/architecture_fix
Architecture fix
- Loading branch information
Showing
16 changed files
with
123 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"python.testing.unittestArgs": [ | ||
"-v", | ||
"-s", | ||
".", | ||
"-p", | ||
"test_*.py" | ||
], | ||
"python.testing.pytestEnabled": false, | ||
"python.testing.unittestEnabled": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
from abc import ABCMeta, abstractmethod | ||
|
||
class APIHandler(metaclass=ABCMeta): | ||
@property | ||
@classmethod | ||
@abstractmethod | ||
def API_endpoint(): | ||
"""Property used to define the API_endpoint for the subclass of APIHandler""" | ||
pass | ||
|
||
@classmethod | ||
@abstractmethod | ||
def send_request(request): | ||
pass | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import requests | ||
|
||
from relation_extraction.API_handler import APIHandler | ||
|
||
class KnowledgeGraphMessenger(APIHandler): | ||
def API_endpoint(): | ||
return "http://130.225.57.13/knox-api/triples" | ||
|
||
def send_request(output): | ||
HEADERS = {"Access-Authorization":"internal_key"} | ||
PARAMS={"g": "http://knox_database"} | ||
FORMATTED_OUTPUT = KnowledgeGraphMessenger.format_output(output) | ||
response = requests.post(url=KnowledgeGraphMessenger.API_endpoint(), json=FORMATTED_OUTPUT, params=PARAMS, headers=HEADERS) | ||
print(f"db component response: {response.text}") | ||
return response.text | ||
|
||
@classmethod | ||
def format_output(self, output): | ||
formatted_output = {"triples": output} | ||
return formatted_output | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from relation_extraction.API_handler import APIHandler | ||
|
||
class MetaDataMessenger(APIHandler): | ||
def API_endpoint(): | ||
pass | ||
|
||
def send_request(request_content): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import requests | ||
import re | ||
|
||
from relation_extraction.API_handler import APIHandler | ||
|
||
class OntologyMessenger(APIHandler): | ||
def API_endpoint(): | ||
return "http://130.225.57.13/knox-api/triples" | ||
|
||
def send_request(): | ||
"Function to extract relations based on the specified pattern" | ||
print("Getting relations from online ontology...") | ||
relations = [] | ||
query_string_s = 'http://dbpedia.org/ontology/' | ||
query_string_o = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property' | ||
PARAMS = {"g":"http://knox_ontology", "s": query_string_s, "o": query_string_o} | ||
HEADERS = {"Access-Authorization":"internal_key"} | ||
r = requests.get(url=OntologyMessenger.API_endpoint(), params=PARAMS, headers=HEADERS) | ||
print(f"db component response: {r.text}") | ||
|
||
data = r.json() | ||
|
||
for triple in data["triples"]: | ||
relation = re.split("http://dbpedia.org/ontology/", triple["s"]["Value"])[1] | ||
relations.append(relation) | ||
|
||
return relations | ||
|
||
if __name__ == "__main__": | ||
OntologyMessenger.send_request() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from relation_extraction.NaiveMVP.main import handle_relation_post_request | ||
|
||
|
||
class RelationExtractor(): | ||
@classmethod | ||
def begin_extraction(self, data): | ||
handle_relation_post_request(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters