WebAnnotator Utilities¶
webstruct.webannotator
provides functions for working with HTML
pages annotated with WebAnnotator Firefox extension.
-
webstruct.webannotator.
to_webannotator
(tree, entity_colors=None)[source]¶ Convert a tree loaded by one of WebStruct loaders to WebAnnotator format.
If you want a predictable colors assignment use
entity_colors
argument; it should be a mapping{'entity_name': (fg, bg, entity_idx)}
; entity names should be lowercased. You can useEntityColors
to generate this mapping automatically:>>> from webstruct.webannotator import EntityColors, to_webannotator >>> # trees = ... >>> entity_colors = EntityColors() >>> wa_trees = [to_webannotator(tree, entity_colors) for tree in trees]