laf 4.8.3¶
Submodules¶
laf.fabric module¶
-
class
LafAPI
(names)[source]¶ Bases:
laf.data.LafData
Makes all API methods available.
API()
returns a dict keyed by mnemonics and valued by API methods.
-
class
LafFabric
(data_dir=None, laf_dir=None, output_dir=None, save=False, verbose=None)[source]¶ Bases:
object
Process manager.
load(params)
: given the source, annox and task, loads the data, assembles the API, and returns the API.-
load
(source, annox, task, load_spec, add=False, compile_main=False, compile_annox=False, verbose='NORMAL', time_reset=True)[source]¶
-
laf.elements module¶
-
class
Connection
(lafapi, feature, inv)[source]¶ Bases:
object
Connection info according to an edge feature.
Holds the mapping from nodes to a set of
(node, value)
pairs for which there is an edge for which this edge feature hasvalue
. Has distinct mappings for main source data and annox data.v(node)
yields the nodes (without the values).vv(node)
yields the node/value pairs.endnodes(nodeset, value=None) yields the set of end nodes after traveling from ``nodeset
along edges (having this feature with this value or any value).
-
class
Feature
(lafapi, feature, kind)[source]¶ Bases:
object
Feature data and lookup.
Holds the mapping from nodes/edges to values corresponding to a single feature. Has distinct mappings for main source data and annox data.
v(node_or_edge)
is the lookup method.s(value=None)
yields the nodes/edges that have this value or any value.
-
class
PrimaryData
(lafapi)[source]¶ Bases:
object
Primary data.
data(node)
is a list of chunks of primary data attached to that node. The chunk is delivered as a pair of the position where the chunk starts and the chunk itself. Empty chunks are possible. Consecutive chunks have been merged. The chunks appear in primary data order.
laf.data module¶
laf.model module¶
laf.parse module¶
-
class
AnnotationHandler
(annotation_file, stamp)[source]¶ Bases:
xml.sax.handler.ContentHandler
-
aid
= None¶
-
file_name
= None¶
-
nid
= None¶
-
stamp
= None¶
-
truth
= {'off': False, 'false': False, 'no': False, '1': True, 'on': True, '0': False, 'true': True, 'yes': True}¶
-
laf.names module¶
-
class
Names
(data_dir, laf_dir, output_dir, save, verbose)[source]¶ Bases:
laf.settings.Settings
Manage the names of compiled LAF data items.
Data items are stored in a dictionary with keys that tell a lot about the kind of data stored under that key. Keys have the following format:
origin group kind direction ( item )
and item is a comma separated list of a variable number of components, possibly zero.
Group:
P
: primary data items,G
: items for regions, nodes, edges,X
: xml identifiers,F
: features,C
: connectivity,T
: temporary during compiling.
Origin:
m
ora
meaning main and annox resp. Indicates the source data. The valuez
indicates that this data is not prepared by Laf-Fabric but by auxiliary modules.Kind:
n
ore
meaning node and edge resp.Direction:
f
orb
meaning forward and backward resp.The direction can mean the direction in which edges are followed, or the direction in which a mapping goes.
Components:
Features are items, with three components: (namespace, label, name).
In group
P
,G
,T
there are one-component items, such as (edges_from
,) and (edges_to
).In group
X
there is only one item, and it has no components: ().For each data item we have to know the conditions under which it has to be loaded and its data type.
The condition is a key in a dictionary of conditions. The loader determines the condition dictionary by filling in its slots with relevant components.
The data type is either array, or dict, or string.
Class methods The class methods
comp
anddecomp
anddecompfull
take care of the composition and decomposition of keys in meaningful bits.Instance data and methods The instance data contains a list of datakeys, adapted to the present environment, which is based on the source, annox-es and task chosen by the user. The previous list is also remembered, so that the loader can load/unload the difference.
The instance method
request_files
determines the difference between previously and presently requested data items. It uses an instance methoddinfo
that provides all relevant information associated with a datakey, including the location and name of the corresponding data file on disk. This method is an instance method because it needs values from the current environment.-
DCOMP_SEP
= ','¶
-
E_ANNOT_NON
= ('laf', '', 'x')¶
-
E_ANNOT_YES
= ('laf', '', 'y')¶
-
kind_types
= {False, True}¶
-
load_spec_keys
= {'prepare', 'features', 'xmlids', 'primary'}¶
-
load_spec_subkeys
= {'edge', 'node'}¶
laf.settings module¶
-
class
Settings
(data_dir, laf_dir, output_dir, save, verbose)[source]¶ Bases:
object
Manage the configuration.
The directory structure is built as a set of names in an environment dictionary. The method
setenv
builds a new structure based on user choices. Local settings can be passed as arguments to object creation, or in a config file in the current directory, or in a config file in the user’s home directory. It is possible to save these settings in the latter config file.-
setenv
(source=None, annox=None, task=None, zspace=None)[source]¶ all relevant config settings will be stored in self.env Most settings are just key - string value pairs. But the setting ‘annox’ will be a dict, keyed by the annox names passed through the annox param, and valued by dicts with annox-specific paths. The annox parameter may be None, [], ‘–’ (meaning no annox), a list of annoxes, or a string with a comma-separated series of annoxes.
-
laf.timestamp module¶
-
class
Timestamp
(log_file=None, verbose=None)[source]¶ Bases:
object
Timed progress messages.
There are specialized methods for distinct verbosity levels:
Emsg
,Wmsg
etc. Withset_verbose
you can set the verbosity of the application. Only messages with that verbosity level of lower will reach the output. You can suppress the time indication and the newline at the end.raw_msg
has complete flexibility. This method is exposed asmsg
in the API.-
verbose_level
= OrderedDict([('SILENT', -10), ('ERROR', -3), ('WARNING', -2), ('INFO', -1), ('NORMAL', 0), ('DETAIL', 1), ('DEBUG', 10)])¶
-