Skip to content

Commit

Permalink
Merge pull request #37 from Knox-AAU/concept-linking
Browse files Browse the repository at this point in the history
Concept linking
  • Loading branch information
denBruneBarone authored Dec 19, 2023
2 parents 2964686 + 4eb2cf1 commit 457d4e7
Show file tree
Hide file tree
Showing 36 changed files with 2,176 additions and 19 deletions.
362 changes: 362 additions & 0 deletions concept_linking/data/files/EvaluationData/Results/ML_DK_OC.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"knox-kb01.srv.aau.dk/Aalborgs",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"http://dbpedia.org/ontology/Place",
0
1.0
]
},
{
Expand Down Expand Up @@ -140,15 +140,15 @@
"knox-kb01.srv.aau.dk/Jonas_Wind",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"http://dbpedia.org/ontology/Organisation",
1.0
0
]
},
{
"FC København sikrede sig sejren mod Brøndby IF, da målscorerne Jonas Wind og Kasper Kusk viste imponerende præstationer.": [
"knox-kb01.srv.aau.dk/Kasper_Kusk",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"http://dbpedia.org/ontology/Organisation",
1.0
0
]
},
{
Expand Down
354 changes: 354 additions & 0 deletions concept_linking/data/files/EvaluationData/Results/ML_EN_OC.json

Large diffs are not rendered by default.

362 changes: 362 additions & 0 deletions concept_linking/data/files/EvaluationData/Results/Prompt_DK_OC.json

Large diffs are not rendered by default.

354 changes: 354 additions & 0 deletions concept_linking/data/files/EvaluationData/Results/Prompt_EN_OC.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"knox-kb01.srv.aau.dk/Martin_Kjær",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"http://dbpedia.org/ontology/Agent",
1,
"We have defined Agent as an entity that has agency. PersonFunction would also be correct here"
1
]
},
{
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
363 changes: 363 additions & 0 deletions concept_linking/data/files/EvaluationData/Results/Untrained_DK_PC.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"knox-kb01.srv.aau.dk/Martin_Kjær",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"https://dbpedia.org/ontology/Person",
1,0
1.0
]
},
{
Expand Down Expand Up @@ -332,7 +332,7 @@
"knox-kb01.srv.aau.dk/Apple_Inc",
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"https://dbpedia.org/ontology/Organisation",
0
0.8
]
},
{
Expand Down
362 changes: 362 additions & 0 deletions concept_linking/data/files/EvaluationData/Results/Untrained_EN_PC.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
]
},
{
"sentence": "Michelle Obama is an person.",
"sentence": "Michelle Obama is a person.",
"sentenceStartIndex": 0,
"sentenceEndIndex": 24,
"sentenceEndIndex": 26,
"entityMentions": [
{
"name": "Barack Obama",
"name": "Michelle Obama",
"type": "Entity",
"label": "PERSON",
"startIndex": 0,
"endIndex": 11,
"iri": "knox-kb01.srv.aau.dk/Barack_Obama"
"endIndex": 13,
"iri": "knox-kb01.srv.aau.dk/Michelle_Obama"
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions concept_linking/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ def entity_type_classification(input_data):
#stringComparisonSolution(input_data)

# Untrained Spacy
#untrainedSpacySolution(input_data)
untrainedSpacySolution(input_data)

# PromptEngineering
perform_entity_type_classification(input_data)
#perform_entity_type_classification(input_data)

# Machine Learning
#predict(input_data)
Expand Down
2 changes: 2 additions & 0 deletions concept_linking/solutions/PromptEngineering/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# Local API url docker
# api_url = "http://llama-cpu-server:5000/llama"



# Remote API url
# api_url = "http://knox-proxy01.srv.aau.dk/llama-api/llama"

Expand Down
2 changes: 0 additions & 2 deletions concept_linking/solutions/StringComparison/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def translateWordToEn(word, language):


from difflib import SequenceMatcher


# returnerer en konstant mellem 0 og 1. 0 er et elendigt match, 1 er et eksakt match.
def similar(a, b):
return SequenceMatcher(None, a.lower(), b.lower()).ratio()
3 changes: 2 additions & 1 deletion relation_extraction/relation_extractor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# from relation_extraction.NaiveMVP.main import handle_relation_post_request
from relation_extraction.NaiveMVP.main import handle_relation_post_request
from relation_extraction.multilingual.main import begin_relation_extraction

class RelationExtractor():
@classmethod
def begin_extraction(self, data):
# handle_relation_post_request(data) # Naive solution
handle_relation_post_request(data) # Naive solution
begin_relation_extraction(data) # Multilingual solution
4 changes: 2 additions & 2 deletions test/test_server/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def setUp(self):
# Valid: authorized and correct format
@patch('os.getenv', return_value="some_api_secret")
# @patch('concept_linking.main.stringComparisonSolution', return_value=Mock())
# @patch('concept_linking.main.untrainedSpacySolution', return_value=Mock())
@patch('concept_linking.main.perform_entity_type_classification', return_value=Mock())
@patch('concept_linking.main.untrainedSpacySolution', return_value=Mock())
# @patch('concept_linking.main.perform_entity_type_classification', return_value=Mock())
# @patch('concept_linking.main.predict', return_value=Mock())
@patch('relation_extraction.relation_extractor.RelationExtractor.begin_extraction', return_value=Mock())

Expand Down

0 comments on commit 457d4e7

Please sign in to comment.