-
-
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
9 changed files
with
117 additions
and
41 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 |
---|---|---|
|
@@ -12,3 +12,4 @@ replit.nix | |
.vscode | ||
content/excalibrain.md | ||
content/Scripts/.env | ||
StructuredReferences/ |
5 changes: 5 additions & 0 deletions
5
...s/book/Why Information Grows The Evolution of Order, from Atoms to Economies.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/LUXMDBMB) | ||
|
||
[[Entries/Individuals/Cesar Hidalgo]] | ||
# Why Information Grows: The Evolution of Order, from Atoms to Economies (2015) | ||
|
5 changes: 5 additions & 0 deletions
5
...erences/journalArticle/The New International Economic Order A Reintroduction.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/M4HCQDKN) | ||
|
||
[[Entries/Individuals/Nils Gilman]] | ||
# The New International Economic Order: A Reintroduction (NaN) | ||
|
5 changes: 5 additions & 0 deletions
5
content/References/webpage/Ontology Design Patterns . org (ODP) - Odp.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/DXEZ96HF) | ||
|
||
|
||
# Ontology Design Patterns . org (ODP) - Odp | ||
|
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,19 @@ | ||
import sys | ||
import pylibmagic | ||
from unstructured.partition.auto import partition | ||
|
||
def file_to_text(file_path, txt_path): | ||
elements = partition(filename=file_path) | ||
with open(txt_path, 'w') as f: | ||
for el in elements: | ||
f.write(str(el)) | ||
f.write("\n") | ||
|
||
if len(sys.argv) < 3: | ||
print("Usage: python file_to_text.py input_file output_txt") | ||
sys.exit(1) | ||
|
||
pdf_path = sys.argv[1] | ||
txt_path = sys.argv[2] | ||
|
||
file_to_text(file_path, txt_path) |
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
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 |
---|---|---|
@@ -1,29 +1,30 @@ | ||
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 | ||
from prompts import relation_prompt, categories_prompt, correctness_check_prompt, arity_two_prompt | ||
|
||
if len(sys.argv) < 3: | ||
print("Usage: python text_to_prolog.py input_file domain_subjects") | ||
print("Usage: python text_to_prolog.py input_file output_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] | ||
output_file = sys.argv[2] # e.g. 'nieo.pl' | ||
# domain_subjects = sys.argv[3] # e.g. 'NIEO, international relations, economics' | ||
output_file_noext = output_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' | ||
relation_output_file = f'{output_file_noext}_relations.pl' | ||
entities_output_file = f'{output_file_noext}_entities.pl' | ||
categories_output_file = f'{output_file_noext}_categories.pl' | ||
|
||
output_relations = text_to_relations(original_text_chunks, relation_output_file, relation_prompt, correctness_check_prompt(domain_subjects)) | ||
output_relations = text_to_relations(original_text_chunks, relation_output_file, arity_two_prompt, correctness_check_prompt()) | ||
|
||
entity_predicates = parse_prolog_predicates(output_relations) | ||
# entity_predicates = parse_prolog_predicates(output_relations) | ||
|
||
prolog_predicates_to_entities(entity_predicates, entities_output_file) | ||
# 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_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) | ||
# entities_to_categorized_entities(entities_chunks, categories_output_file, categories_prompt) |
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