Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@


def create_phrases_file(phrases_dir, phrases_file, dictionary_dir=ETHICS_DICTIONARY_DIR):
global terms_xml_path
"""
Creates file for phrases based on the dictionary dir and dictionary name

creates directories if they do not exist
:param phrases_dir: directory holding the phrases file
:param phrases_file: file holding phrases file

"""
terms_xml_dir = Path(dictionary_dir, phrases_dir)
if not terms_xml_dir.exists():
terms_xml_dir.mkdir()
Expand Down Expand Up @@ -68,7 +75,7 @@ def create_and_write_list_for_fields(dict_for_entities, field, out_filename):
run_analysis(
get_or_create_corpus_dir(TERPENES),
create_phrases_file("terpenes_key_phrases", "terpenes_key_phrases.xml", dictionary_dir="terpenes_dictionary"),
query=TERPENES,
query="terpenes",
hits = 20,
)

16 changes: 11 additions & 5 deletions docanalysis/extract_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def extract_entities_from_papers(self, corpus_path, terms_xml_path, query=None,
self.create_project_files(query, hits, corpus_path)
if install_ami:
logging.info(f"installing ami3 (check whether this is a good idea)")
self.install_ami()
logging.info(f"please check independently that ami is installed")
# self.install_ami()

logging.info(f"dict with parsed xml in {corpus_path}")
dict_with_parsed_xml = self.make_dict_with_parsed_xml(corpus_path)
Expand Down Expand Up @@ -88,10 +89,15 @@ def create_project_files(self, QUERY, HITS, OUTPUT):
os.system(f'pygetpapers -q "{QUERY}" -k {HITS} -o {OUTPUT} -x')
os.system(f"ami -p {OUTPUT} section")

def install_ami(self):
os.system("git clone https://github.com/petermr/ami3.git")
os.system("cd ami3")
os.system("mvn install -Dmaven.test.skip=true")
"""
removed as too complex.
TODO maybe have a check that `ami` is installed, but install elsewhere
"""
# def install_ami(self):
# os.system("git clone https://github.com/petermr/ami3.git")
# os.system("cd ami3")
# os.system("mvn install -Dmaven.test.skip=true")


def make_dict_with_parsed_xml(self, output):

Expand Down
24 changes: 0 additions & 24 deletions pmr_demo.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<dictionary title="terpenes_key_phrases">
<entry term="menthol" name="menthol" />
</dictionary>