Find and annotate elements in text.
Create an invaltree with elements and units of text, validate the rules to apply elements and augment the text with this result.
Parameters: |
|
---|---|
Returns: | text – The annotated text. |
Return type: | str |
Examples
Basic example with config overwrite:
>>> text = 'The quick brown fox jumps over the lazy dog.'
>>> elements = [
{'fox': {
'value': '/wiki/fox', 'data-type': 'animal'}},
{'dog': {
'value': '/wiki/dog', 'data-type': 'animal'}}]
>>> cfg = get_config()
>>> cfg['setting']['replaces_at_all'] = 1
>>> print annotate(text, elements, config=cfg)
'The quick brown <a href="/wiki/fox" data-type="animal">fox</a> jumps over the lazy dog .'
Remove elements from text.
Use config to identify elements.
Todo
Implement me ...clean(text .