-
-
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.
- Loading branch information
Showing
16 changed files
with
811 additions
and
158 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 |
---|---|---|
|
@@ -9,4 +9,6 @@ tsconfig.tsbuildinfo | |
private/ | ||
.replit | ||
replit.nix | ||
.vscode | ||
.vscode | ||
content/excalibrain.md | ||
content/Scripts/.env |
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,5 @@ | ||
[🇿](zotero://select/library/items/V387NZWL) | ||
|
||
|
||
# SynaLinks/HybridAGI (2024) | ||
|
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,5 @@ | ||
[🇿](zotero://select/library/items/7XHYWD58) | ||
|
||
|
||
# neo4j/NaLLM (2024) | ||
|
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,5 @@ | ||
[🇿](zotero://select/library/items/MESBET73) | ||
|
||
[[Entries/Individuals/ rahulnyk]] | ||
# rahulnyk/graph_maker (2024) | ||
|
5 changes: 5 additions & 0 deletions
5
content/References/computerProgram/rahulnykknowledge_graph_maker.md
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,5 @@ | ||
[🇿](zotero://select/library/items/UYJXAI9D) | ||
|
||
[[Entries/Individuals/ rahulnyk]] | ||
# rahulnyk/knowledge_graph_maker (2024) | ||
|
5 changes: 5 additions & 0 deletions
5
...erences/journalArticle/Information extraction pipelines for knowledge graphs.md
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,5 @@ | ||
[🇿](zotero://select/library/items/369FGT9H) | ||
|
||
[[Entries/Individuals/Mohamad Yaser Jaradeh]] [[Entries/Individuals/Kuldeep Singh]] [[Entries/Individuals/Markus Stocker]] [[Entries/Individuals/Andreas Both]] [[Entries/Individuals/Sören Auer]] | ||
# Information extraction pipelines for knowledge graphs (2023) | ||
|
5 changes: 5 additions & 0 deletions
5
... TO TRIPLES Creating knowledge graph in the form of triples from AI TextBook.md
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,5 @@ | ||
[🇿](zotero://select/library/items/MVFJ5Z2R) | ||
|
||
[[Entries/Individuals/Aman Kumar]] [[Entries/Individuals/Swathi Dinakaran]] | ||
# TEXTBOOK TO TRIPLES: Creating knowledge graph in the form of triples from AI TextBook | ||
|
5 changes: 5 additions & 0 deletions
5
content/References/webpage/How to Convert Any Text Into a Graph of Concepts.md
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,5 @@ | ||
[🇿](zotero://select/library/items/GDR8CVEQ) | ||
|
||
[[Entries/Individuals/Rahul Nayak]] | ||
# How to Convert Any Text Into a Graph of Concepts (2023) | ||
|
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 @@ | ||
import sys | ||
from pypdf import PdfReader | ||
|
||
def pdf_to_txt(pdf_path, txt_path): | ||
with open(pdf_path, 'rb') as pdf_file, open(txt_path, 'w', encoding='utf-8') as txt_file: | ||
pdf_reader = PdfReader(pdf_file) | ||
for page in pdf_reader.pages: | ||
txt_file.write(page.extract_text()) | ||
|
||
if len(sys.argv) < 3: | ||
print("Usage: python pdf_to_txt.py input_pdf output_txt") | ||
sys.exit(1) | ||
|
||
pdf_path = sys.argv[1] | ||
txt_path = sys.argv[2] | ||
|
||
pdf_to_txt(pdf_path, txt_path) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
def correctness_check_prompt(domain_subjects): | ||
return f'''You are a domain expert in the field of {domain_subjects}. | ||
Check the Prolog code for correctness based on the text. Ensure all relationships are logically sound and perfectly consistent with the text. | ||
If you find any inconsistencies, correct them in the Prolog code. | ||
Please respond with prolog code only.''' | ||
|
||
relation_prompt = '''You are an expert at creating Knowledge Graphs in Prolog. | ||
Translate sentences in the text into Prolog code using predicates of arity 2. | ||
Arity 2 predicates define relationships (verbs) between nouns, they are provided below. | ||
You can ONLY use the following predicates: | ||
category/2 | ||
challenges/2 | ||
contributes/2 | ||
creates/2 | ||
does/2 | ||
provokes/2 | ||
targets/2 | ||
parent/2 | ||
Please respond with prolog code only. | ||
Example: | ||
Text: "John creates a project. The project targets education." | ||
Step-by-Step Translation: | ||
a. Entities and Objects: "John", "project", "education" | ||
b. Relationships: "creates", "targets" | ||
c. Arity 2 Predicates: | ||
creates(john, project). | ||
targets(project, education). | ||
e. Validation: Ensure all entities and relationships are included and correctly formatted. | ||
f. Output: | ||
creates(john, project). | ||
targets(project, education). | ||
Text:''' | ||
|
||
categories_prompt = '''You are an expert at creating Knowledge Graphs in Prolog. | ||
Categorize the list of entities using Prolog predicates of arity 1. Only assign 1 category to 1 entity. | ||
You can ONLY use the following predicates: | ||
abstract_concept/1 | ||
physical_entity/1 | ||
country/1 | ||
person/1 | ||
organization/1 | ||
event/1 | ||
theoretical_framework/1 | ||
Please respond with prolog code only. | ||
Example: | ||
Entities: "John", "Cuba", "Mount Everest", "education" | ||
Step-by-Step Translation: | ||
a. Entities: "John", "Cuba", "Mount Everest", "education" | ||
b. Categories: "person", "country", "physical_entity", "abstract_concept" | ||
c. Arity 1 Predicates: | ||
person(john). | ||
country(cuba). | ||
physical_entity(mount_everest). | ||
abstract_concept(education). | ||
d. Validation: Ensure all entities are categorized and correctly formatted. | ||
e. Output: | ||
person(john). | ||
country(cuba). | ||
physical_entity(mount_everest). | ||
abstract_concept(education). | ||
Entities: | ||
''' |
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,29 @@ | ||
import sys | ||
from utils import parse_prolog_predicates, call_gpt_api, relation_correctness_check, file_to_chunks, text_to_relations, prolog_predicates_to_entities, entities_to_categorized_entities | ||
from prompts import relation_prompt, categories_prompt, correctness_check_prompt | ||
|
||
if len(sys.argv) < 3: | ||
print("Usage: python text_to_prolog.py input_file domain_subjects") | ||
sys.exit(1) | ||
|
||
input_file = sys.argv[1] # e.g. 'nieo.txt' | ||
domain_subjects = sys.argv[2] # e.g. 'NIEO, international relations, economics' | ||
name = input_file.split('.')[0] | ||
|
||
original_text_chunk_size = 2000 | ||
original_text_chunks = file_to_chunks(input_file, original_text_chunk_size) | ||
|
||
relation_output_file = f'{name}_relations.pl' | ||
entities_output_file = f'{name}_entities.pl' | ||
categories_output_file = f'{name}_categories.pl' | ||
|
||
output_relations = text_to_relations(original_text_chunks, relation_output_file, relation_prompt, correctness_check_prompt(domain_subjects)) | ||
|
||
entity_predicates = parse_prolog_predicates(output_relations) | ||
|
||
prolog_predicates_to_entities(entity_predicates, entities_output_file) | ||
|
||
entities_chunk_size = 2000 | ||
entities_chunks = file_to_chunks(entities_output_file, entities_chunk_size) | ||
|
||
entities_to_categorized_entities(entities_chunks, categories_output_file, categories_prompt) |
Oops, something went wrong.