Last active
November 6, 2016 12:46
-
-
Save LLCampos/3d536f1160358b03008e548707deb355 to your computer and use it in GitHub Desktop.
Given an OWL file of the RadLex ontology, extract all the class/terms preferred names into a file
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
from lxml import etree | |
radlex_tree = etree.parse('Radlex3.13.1.owl').getroot() | |
# Get all the term names of the Ontology, in a list. | |
all_terms = radlex_tree.xpath('//x:Preferred_name/text()', | |
namespaces={'x': radlex_tree.nsmap[None]}) | |
with open('radlex_all_terms_names.txt', 'w') as f: | |
for term in all_terms: | |
f.write(term.encode('utf-8') + '\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment