penman.surface

Surface strings, tokens, and alignments.

Epigraphical Markers

class penman.surface.AlignmentMarker(indices, prefix=None)[source]

Bases: penman.epigraph.Epidatum

classmethod from_string(s)[source]

Instantiate the alignment marker from its string s.

Examples

>>> from penman import surface
>>> surface.Alignment.from_string('1')
Alignment((1,))
>>> surface.RoleAlignment.from_string('e.2,3')
RoleAlignment((2, 3), prefix='e.')
class penman.surface.Alignment(indices, prefix=None)[source]

Bases: penman.surface.AlignmentMarker

class penman.surface.RoleAlignment(indices, prefix=None)[source]

Bases: penman.surface.AlignmentMarker

Module Functions

penman.surface.alignments(g)[source]

Return a mapping of triples to alignments in graph g.

Parameters

g – a Graph containing alignment data

Returns

A dict mapping Triple objects to their corresponding Alignment objects, if any.

Example

>>> from penman import decode
>>> from penman import surface
>>> g = decode(
...   '(c / chase-01~4'
...   '   :ARG0~5 (d / dog~7)'
...   '   :ARG0~3 (c / cat~2))')
>>> surface.alignments(g)  
{('c', ':instance', 'chase-01'): Alignment((4,)),
 ('d', ':instance', 'dog'): Alignment((7,)),
 ('c', ':instance', 'cat'): Alignment((2,))}
penman.surface.role_alignments(g)[source]

Return a mapping of triples to role alignments in graph g.

Parameters
  • g – a Graph containing role alignment

  • data

Returns

A dict mapping Triple objects to their corresponding RoleAlignment objects, if any.

Example

>>> from penman import decode
>>> from penman import surface
>>> g = decode(
...   '(c / chase-01~4'
...   '   :ARG0~5 (d / dog~7)'
...   '   :ARG0~3 (c / cat~2))')
>>> surface.role_alignments(g)  
{('c', ':ARG0', 'd'): RoleAlignment((5,)),
 ('c', ':ARG0', 'c'): RoleAlignment((3,))}