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

Method group

pattern/text/search.py:984–998  ·  view source on GitHub ↗

Returns a list of Word objects that match the given group. With chunked=True, returns a list of Word + Chunk objects - see Match.constituents(). A group consists of consecutive constraints wrapped in { }, e.g., search("{JJ JJ} NN", Sentence(parse("big black cat")

(self, index, chunked=False)

Source from the content-addressed store, hash-verified

982 return a
983
984 def group(self, index, chunked=False):
985 """ Returns a list of Word objects that match the given group.
986 With chunked=True, returns a list of Word + Chunk objects - see Match.constituents().
987 A group consists of consecutive constraints wrapped in { }, e.g.,
988 search("{JJ JJ} NN", Sentence(parse("big black cat"))).group(1) => big black.
989 """
990 if index < 0 or index > len(self.pattern.groups):
991 raise IndexError, "no such group"
992 if index > 0 and index <= len(self.pattern.groups):
993 g = self.pattern.groups[index-1]
994 if index == 0:
995 g = self.pattern.sequence
996 if chunked is True:
997 return Group(self, self.constituents(constraint=[self.pattern.sequence.index(x) for x in g]))
998 return Group(self, [w for w in self.words if self.constraint(w) in g])
999
1000 @property
1001 def string(self):

Callers 15

find_urlsFunction · 0.45
find_emailFunction · 0.45
replace_entityFunction · 0.45
searchMethod · 0.45
searchMethod · 0.45
definitionMethod · 0.45
downloadMethod · 0.45
email_addressMethod · 0.45
name2unicodeFunction · 0.45
asciihexdecodeFunction · 0.45
_parse_hexstringMethod · 0.45
_sync_author_detailMethod · 0.45

Calls 5

constituentsMethod · 0.95
constraintMethod · 0.95
lenFunction · 0.85
GroupClass · 0.70
indexMethod · 0.45

Tested by 1

test_groupMethod · 0.36