prefix(text_array,
accent_spec,
map_fcn=<function <lambda> at 0x3072aa0>)
| source code
|
This function takes an array of words and an accent spec. It matches
the accent spec to the words, and outputs an array of tuples which tells
you where the accents are, and what kind. The optional map_fcn can be
used to map other kinds of objects into a array of strings.
More specifically, an accent_spec is a whitespace-separated list of
strings. Each string is a word from the text_array, with an optional
prefix. The strings are matched in order to the words, and the output
array is a list of (index_in_text_array, prefix_text) tuples.
So, if you have text_array = ['my', 'cat', 'is', 'my', 'cat'] and
accent_spec="is +my", then align() will match "is" to
text_array[2], and "+my" to text_array[3], and it will return [
(3, "+") ] . Note that "+is +my" does not imply that
'is' and 'my' are adjacent, and "+is +cat" simply returns [ (2,
"+"), (4, "+") ].
If the accent_spec were "+my", then it would match
text_array[0], and return [ (0, "+") ].
Prefixes can be multiple characters, but they cannot end in letters,
digits, or underscore.
|