MCPcopy Index your code
hub / github.com/clips/pattern / get

Method get

pattern/text/tree.py:860–882  ·  view source on GitHub ↗

Returns a tag for the word at the given index. The tag can be WORD, LEMMA, POS, CHUNK, PNP, RELATION, ROLE, ANCHOR or a custom word tag.

(self, index, tag=LEMMA)

Source from the content-addressed store, hash-verified

858 ch2.conjunctions.append(ch1, cc)
859
860 def get(self, index, tag=LEMMA):
861 """ Returns a tag for the word at the given index.
862 The tag can be WORD, LEMMA, POS, CHUNK, PNP, RELATION, ROLE, ANCHOR or a custom word tag.
863 """
864 if tag == WORD:
865 return self.words[index]
866 if tag == LEMMA:
867 return self.words[index].lemma
868 if tag == POS:
869 return self.words[index].type
870 if tag == CHUNK:
871 return self.words[index].chunk
872 if tag == PNP:
873 return self.words[index].pnp
874 if tag == REL:
875 ch = self.words[index].chunk; return ch and ch.relation
876 if tag == ROLE:
877 ch = self.words[index].chunk; return ch and ch.role
878 if tag == ANCHOR:
879 ch = self.words[index].pnp; return ch and ch.anchor
880 if tag in self.words[index].custom_tags:
881 return self.words[index].custom_tags[tag]
882 return None
883
884 def loop(self, *tags):
885 """ Iterates over the tags in the entire Sentence,

Callers 2

loopMethod · 0.95
indexofMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected