# e-Linguistics Toolkit: Termset # # Copyright (C) 2008 ELTK Project # Author: Scott Farrar <*****@*****.**> # URL: <http://purl.org/linguistics/eltk> # For license information, see LICENSE.TXT """ Termset is the Python data structure equivalent of ``termset graphs`` which are logical components of the GOLD Community Model. Put simply, they contain term-concept mappings, e.g., "PST"--gold:PastTense. A termset contains a set of scientific 'terms' used as part of an annotation system, usually the standard terms from a particular linguistic theory or community of practice. A term is a specific string representing a concept within some scientific domain. Terms may have a standard orthographic representation such as "past tense" or an abbreviation such as "PST". """ from eltk.kb.KBComponent import KBComponent from eltk.reader.LinkedDataReader import LinkedDataReader from eltk.config import ELTK_HOME reader = LinkedDataReader() GOLD_graph = reader.parseGraph(ELTK_HOME+'/examples/inputfiles/gold-2008.owl') GOLD = reader.buildPyModel() class Termset(KBComponent): """ Termset is the class representing a termset. """ def getTermMeaning(self,term_string): """ Given some abbreviation, e.g., 'PST', or full form, e.g., 'past tense', return the GOLD URI indicated by that string. :param term_string: the string representation (abbreviation or full form) of the term
IGT line 3 See <eltk/examples/inputfiles/MorphosyntaxExamples.txt> """ from os.path import abspath from eltk.reader.Reader import Reader from eltk.reader.LinkedDataReader import LinkedDataReader from eltk.reader.TermsetReader import TermsetReader from eltk.utils.functions import * from eltk.kb.KBComponent import * from eltk.config import ELTK_HOME reader = LinkedDataReader() GOLD_graph = reader.parseGraph(ELTK_HOME+'/examples/inputfiles/gold-2008.owl') GOLD = reader.buildPyModel() class LeipzigReader(Reader): """ The reader for text in Leipzig IGT format (txt). """ def __init__(self,termset=None): self.termset = termset
return results if __name__=='__main__': #for testing from eltk.reader.LinkedDataReader import LinkedDataReader from eltk.config import ELTK_HOME from rdflib.URIRef import URIRef reader = LinkedDataReader() GOLD_graph = reader.parseGraph(ELTK_HOME+'/examples/inputfiles/gold-2009.owl') #x = getBaseClasses(GOLD_graph,URIRef('http://purl.org/linguistics/gold/CommonNoun')) #print x #comments = getComments(GOLD_graph,'http://purl.org/linguistics/gold/CommonNoun') for c in comments: print c
# #for class members cls.individuals = getClassIndividuals(graph,uri) return cls if __name__=='__main__': #for testing from eltk.reader.LinkedDataReader import LinkedDataReader from eltk.config import ELTK_HOME from rdflib.URIRef import URIRef reader = LinkedDataReader() GOLD_graph = reader.parseGraph(ELTK_HOME+'/examples/inputfiles/gold-2009.owl') #x = getBaseClasses(GOLD_graph,URIRef('http://purl.org/linguistics/gold/CommonNoun')) #print x #comments = getComments(GOLD_graph,'http://purl.org/linguistics/gold/CommonNoun') for c in comments: print c