In [1]:
%%capture
%pushd ../
from IPython.display import display, Javascript
from brat_widget.widget import Visualizer, Annotator
from brat_widget.document import *
from brat_widget.configuration import *
%popd
In [2]:
just_entities_collection_configuration = CollectionConfiguration()
just_entities_collection_configuration.entity_types = [{
'type': 'Person',
# The labels are used when displaying the annotion, in this case
# we also provide a short-hand "Per" for cases where
# abbreviations are preferable
'labels': ['Person', 'Per'],
# Blue is a nice colour for a person?
'bgColor': '#7fa2ff',
# Use a slightly darker version of the bgColor for the border
'borderColor': 'darken'
}]
just_entities_collection_configuration.initialize()
just_entities_text = u"Ed O'Kelley was the man who shot the man who shot Jesse James."
just_entities_token_offsets = []
just_entities_sentence_offsets = []
just_entities_document = Document(just_entities_text, just_entities_token_offsets,
just_entities_sentence_offsets,
just_entities_collection_configuration)
just_entities_document.entities = [
# Format: [${ID}, ${TYPE}, [[${START}, ${END}]]]
# note that range of the offsets are [${START},${END})
['T1', 'Person', [(0, 11)]],
['T2', 'Person', [(20, 23)]],
['T3', 'Person', [(37, 40)]],
['T4', 'Person', [(50, 61)]]
]
just_entities_document.initialize()
just_entities = Visualizer(value=just_entities_document,
collection_configuration=just_entities_collection_configuration)
display(just_entities)
In [3]:
entities_relations_and_events_collection_configuration = CollectionConfiguration()
entities_relations_and_events_collection_configuration.entity_types = [{
"type": "Person",
"labels": ["Person", "Per"],
"bgColor": "#7fa2ff",
'attributes': [u'Notorious'],
"borderColor": "darken"
}]
entities_relations_and_events_collection_configuration.entity_attribute_types = [{
"type": "Notorious",
"values": {
"Notorious": {"glyph": "★"}
},
"bool": "Notorious"
}]
entities_relations_and_events_collection_configuration.relation_types = [{
"type": "Anaphora",
"labels": ["Anaphora", "Ana"],
"dashArray": "3,3",
"color": "purple",
"args": [{
"role": "Anaphor",
"targets": ["Person"]
}, {
"role": "Entity",
"targets": ["Person"]
}]
}]
entities_relations_and_events_collection_configuration.event_types = [{
"type": "Assassination",
"labels": ["Assassination", "Assas"],
"bgColor": "lightgreen",
"borderColor": "darken",
"arcs": [{
"type": "Victim",
"labels": ["Victim", "Vict"],
'targets': [u'<ANY>']
}, {
"type": "Perpetrator",
"labels": ["Perpetrator", "Perp"],
"color": "green",
'targets': [u'<ANY>']
}]
}]
entities_relations_and_events_collection_configuration.initialize()
entities_relations_and_events_text = u"Ed O'Kelley was the man who shot the man who shot Jesse James."
entities_relations_and_events_token_offsets = []
entities_relations_and_events_sentence_offsets = []
entities_relations_and_events_document = Document(entities_relations_and_events_text, entities_relations_and_events_token_offsets,
entities_relations_and_events_sentence_offsets,
entities_relations_and_events_collection_configuration)
entities_relations_and_events_document.entities = [
# Format: [${ID}, ${TYPE}, [[${START}, ${END}]]]
# note that range of the offsets are [${START},${END})
['T1', 'Person', [(0, 11)]],
['T2', 'Person', [(20, 23)]],
['T3', 'Person', [(37, 40)]],
['T4', 'Person', [(50, 61)]],
["T5", "Assassination", [(45, 49)]],
["T6", "Assassination", [(28, 32)]]
]
entities_relations_and_events_document.attributes = [ [ "A1", "Notorious", "T4", True ] ]
entities_relations_and_events_document.relations = [
[
"R1",
"Anaphora",
[["Anaphor", "T2"], ["Entity", "T1"]]
]
]
entities_relations_and_events_document.events = [
[
"E1",
"T5",
[["Perpetrator", "T3"], ["Victim", "T4"]]
],
[
"E2",
"T6",
[["Perpetrator", "T2"], ["Victim", "T3"]]
]
]
entities_relations_and_events_document.initialize()
entities_relations_and_events = Visualizer(value=entities_relations_and_events_document,
collection_configuration=entities_relations_and_events_collection_configuration)
display(entities_relations_and_events)
In [4]:
full_collection_configuration = CollectionConfiguration()
full_collection_configuration.description = None
full_collection_configuration.disambiguator_config = []
full_collection_configuration.entity_attribute_types = [{
'unused': False,
'values': [{'dashArray': u',', 'name': u'Individual',
'glyph': u'(I)'}],
'labels': None,
'type': u'Individual',
'name': u'Individual'}, {
'unused': False,
'values': [{'position': u'left', 'dashArray': u',',
'name': u'Name', 'glyph': u'(N)'},
{'position': u'left', 'dashArray': u',',
'name': u'Nominal', 'glyph': u'(n)'},
{'position': u'left', 'dashArray': u',',
'name': u'Other', 'glyph': u'(o)'}],
'labels': None,
'type': u'Mention',
'name': u'Mention'}]
full_collection_configuration.event_types = [
{'borderColor': u'darken',
'normalizations': [],
'name': u'Life',
'labels': None,
'children': [
{'borderColor': u'darken',
'normalizations': [],
'name': u'Be born',
'arcs': [{'labelArrow': u'none',
'arrowHead': u'triangle,5',
'color': u'black',
'labels': [u'Person'],
'dashArray': u',',
'type': u'Person-Arg',
'count': '{1-5}', # '{2}', '', '?', '*', '+'
'targets': [u'Person']},
{'labelArrow': u'none',
'arrowHead': u'triangle,5',
'color': u'black',
'labels': [u'Place'],
'dashArray': u',',
'type': u'Place-Arg',
'targets': [u'GPE']}],
'labels': [u'Be born'],
'children': [],
'unused': False,
'bgColor': u'lightgreen',
'attributes': ['Negation', u'Confidence'],
'type': u'Be-born',
'fgColor': u'black'},
{'borderColor': u'darken',
'normalizations': [],
'name': u'Marry',
'arcs': [{'labelArrow': u'none',
'arrowHead': u'triangle,5',
'color': u'black',
'labels': [u'Person'],
'dashArray': u',',
'type': u'Person-Arg',
'targets': [u'Person']},
{'labelArrow': u'none',
'arrowHead': u'triangle,5',
'color': u'black',
'labels': [u'Place'],
'dashArray': u',',
'type': u'Place-Arg',
'targets': [u'GPE']}],
'labels': None,
'children': [],
'unused': False,
'bgColor': u'lightgreen',
'attributes': ['Negation', u'Confidence'],
'type': u'Marry',
'fgColor': u'black'},
{'borderColor': u'darken',
'normalizations': [],
'name': u'Divorce',
'arcs': [{'labelArrow': u'none',
'arrowHead': u'triangle,5',
'color': u'black',
'labels': [u'Person'],
'dashArray': u',',
'type': u'Person-Arg',
'targets': [u'Person']},
{'labelArrow': u'none',
'arrowHead': u'triangle,5',
'color': u'black',
'labels': [u'Place'],
'dashArray': u',',
'type': u'Place-Arg',
'targets': [u'GPE']}],
'labels': None,
'children': [],
'unused': False,
'bgColor': u'lightgreen',
'attributes': ['Negation', u'Confidence'],
'type': u'Divorce',
'fgColor': u'black'},
{'borderColor': u'darken',
'normalizations': [],
'name': u'Die',
'arcs': [{'labelArrow': u'none',
'arrowHead': u'triangle,5',
'color': u'black',
'labels': [u'Person'],
'dashArray': u',',
'type': u'Person-Arg',
'targets': [u'Person']},
{'labelArrow': u'none',
'arrowHead': u'triangle,5',
'color': u'black',
'labels': [u'Agent'],
'dashArray': u',',
'type': u'Agent-Arg',
'targets': [u'Person',
u'Organization',
u'GPE']},
{'labelArrow': u'none',
'arrowHead': u'triangle,5',
'color': u'black',
'labels': [u'Place'],
'dashArray': u',',
'type': u'Place-Arg',
'targets': [u'GPE']}],
'labels': None,
'children': [],
'unused': False,
'bgColor': u'lightgreen',
'attributes': ['Negation', u'Confidence'],
'type': u'Die',
'fgColor': u'black'}],
'unused': True,
'bgColor': u'lightgreen',
'attributes': ['Negation', u'Confidence'],
'type': u'Life',
'fgColor': u'black'},
{'borderColor': u'darken',
'normalizations': [],
'name': u'Transaction',
'labels': None,
'children': [
{'borderColor': u'darken',
'normalizations': [],
'name': u'Transfer ownership',
'arcs': [{'labelArrow': u'none',
'arrowHead': u'triangle,5',
'color': u'black', 'labels': [u'Buyer'],
'dashArray': u',', 'type': u'Buyer-Arg',
'targets': [u'Person', u'Organization', u'GPE']},
{'labelArrow': u'none', 'arrowHead': u'triangle,5',
'color': u'black', 'labels': [u'Seller'],
'dashArray': u',', 'type': u'Seller-Arg',
'targets': [u'Person', u'Organization', u'GPE']},
{'labelArrow': u'none', 'arrowHead': u'triangle,5',
'color': u'black', 'labels': [u'Artifact'],
'dashArray': u',', 'type': u'Artifact-Arg',
'targets': [u'Organization']}],
'labels': [u'Transfer ownership'],
'children': [],
'unused': False,
'bgColor': u'lightgreen',
'attributes': ['Negation', u'Confidence'],
'type': u'Transfer-ownership',
'fgColor': u'black'
}, {
'borderColor': u'darken', 'normalizations': [],
'name': u'Transfer money',
'arcs': [{'labelArrow': u'none',
'arrowHead': u'triangle,5', 'color': u'black',
'labels': [u'Giver'], 'dashArray': u',',
'type': u'Giver-Arg',
'targets': [u'Person', u'Organization', u'GPE']},
{'labelArrow': u'none', 'arrowHead': u'triangle,5',
'color': u'black', 'labels': [u'Recipient'],
'dashArray': u',', 'type': u'Recipient-Arg',
'targets': [u'Person', u'Organization', u'GPE']},
{'labelArrow': u'none', 'arrowHead': u'triangle,5',
'color': u'black', 'labels': [u'Beneficiary'],
'dashArray': u',', 'type': u'Beneficiary-Arg',
'targets': [u'Person', u'Organization', u'GPE']},
{'labelArrow': u'none', 'arrowHead': u'triangle,5',
'color': u'black', 'labels': [u'Money'],
'dashArray': u',', 'type': u'Money-Arg',
'targets': [u'Money']}],
'labels': [u'Transfer money'], 'children': [],
'unused': False, 'bgColor': u'lightgreen',
'attributes': ['Negation', u'Confidence'],
'type': u'Transfer-money', 'fgColor': u'black'}],
'unused': True,
'bgColor': u'lightgreen',
'attributes': ['Negation', u'Confidence'],
'type': u'Transaction',
'fgColor': u'black'},
{'borderColor': u'darken',
'normalizations': [],
'name': u'Business',
'labels': None,
'children': [{'borderColor': u'darken', 'normalizations': [], 'name': u'Start org',
'arcs': [{'labelArrow': u'none', 'arrowHead': u'triangle,5',
'color': u'black', 'labels': [u'Agent'], 'dashArray': u',',
'type': u'Agent-Arg', 'targets': [u'Person', u'Organization',
u'GPE']},
{'labelArrow': u'none', 'arrowHead': u'triangle,5',
'color': u'black', 'labels': [u'Org'], 'dashArray': u',',
'type': u'Org-Arg', 'targets': [u'Organization']}],
'labels': [u'Start org'], 'children': [], 'unused': False,
'bgColor': u'lightgreen', 'attributes': ['Negation', u'Confidence'],
'type': u'Start-org', 'fgColor': u'black'},
{'borderColor': u'darken', 'normalizations': [], 'name': u'Merge org',
'arcs': [{'labelArrow': u'none', 'arrowHead': u'triangle,5',
'color': u'black', 'labels': [u'Org'], 'dashArray': u',',
'type': u'Org-Arg', 'targets': [u'Organization']}],
'labels': [u'Merge org'], 'children': [], 'unused': False,
'bgColor': u'lightgreen', 'attributes': ['Negation', u'Confidence'],
'type': u'Merge-org', 'fgColor': u'black'}, {'borderColor': u'darken',
'normalizations': [],
'name': u'End org',
'arcs': [{'labelArrow': u'none',
'arrowHead': u'triangle,5',
'color': u'black',
'labels': [u'Org'],
'dashArray': u',',
'type': u'Org-Arg',
'targets': [
u'Organization']}],
'labels': [u'End org'],
'children': [],
'unused': False,
'bgColor': u'lightgreen',
'attributes': ['Negation',
u'Confidence'],
'type': u'End-org',
'fgColor': u'black'}],
'unused': True, 'bgColor': u'lightgreen', 'attributes': ['Negation', u'Confidence'],
'type': u'Business', 'fgColor': u'black'},
{'borderColor': u'darken', 'normalizations': [], 'name': u'Report',
'arcs': [{'labelArrow': u'none', 'arrowHead': u'triangle,5', 'color': u'black',
'labels': [u'Reporter'], 'dashArray': u',', 'type': u'Reporter-Arg',
'targets': [u'Person', u'Organization', u'GPE']},
{'labelArrow': u'none', 'arrowHead': u'triangle,5', 'color': u'black',
'labels': [u'Event'], 'dashArray': u',', 'type': u'Event-Arg',
'targets': [u'Life', u'Be-born', u'Marry', u'Divorce', u'Die',
u'Transaction', u'Transfer-ownership', u'Transfer-money',
u'Business', u'Start-org', u'Merge-org', u'End-org', u'Report']}],
'labels': None, 'children': [], 'unused': False, 'bgColor': u'lightgreen',
'attributes': ['Negation', u'Confidence'], 'type': u'Report', 'fgColor': u'black'}]
full_collection_configuration.ui_names = {
'entities': u'entities',
'events': u'events',
'relations': u'relations',
'attributes': u'attributes'}
full_collection_configuration.normalization_config = []
full_collection_configuration.visual_options = {'arc_bundle': 'none', 'text_direction': 'ltr'}
full_collection_configuration.messages = []
full_collection_configuration.event_attribute_types = [
{
'unused': False,
'values': [{'box': u'crossed', 'name': 'Negation'}],
'labels': None,
'type': 'Negation',
'name': 'Negation'},
{'unused': False,
'values': [{'dashArray': u',', 'name': u'High',
'glyph': u'\u2191'},
{'dashArray': u',', 'name': u'Neutral',
'glyph': u'\u2194'},
{'dashArray': u',', 'name': u'Low',
'glyph': u'\u2193'}],
'labels': None,
'type': u'Confidence',
'name': u'Confidence'}]
full_collection_configuration.annotation_logging = False
full_collection_configuration.ner_taggers = []
full_collection_configuration.relation_types = [
{
'labelArrow': u'none', 'arrowHead': u'triangle,5', 'name': u'Located',
'args': [{'role': u'Arg1', 'targets': [u'Person']},
{'role': u'Arg2', 'targets': [u'GPE']}], 'color': u'black', 'labels': None,
'children': [], 'unused': False, 'dashArray': u',', 'attributes': [],
'type': u'Located',
'properties': {}},
{'labelArrow': u'none', 'arrowHead': u'triangle,5',
'name': u'Geographical part',
'args': [{'role': u'Arg1', 'targets': [u'GPE']},
{'role': u'Arg2', 'targets': [u'GPE']}],
'color': u'black', 'labels': [u'Geographical part', u'Geo part'],
'children': [], 'unused': False, 'dashArray': u',',
'attributes': [], 'type': u'Geographical_part', 'properties': {}},
{'labelArrow': u'none', 'arrowHead': u'triangle,5', 'name': u'Family',
'args': [{'role': u'Arg1', 'targets': [u'Person']},
{'role': u'Arg2', 'targets': [u'Person']}],
'color': u'black', 'labels': None, 'children': [], 'unused': False,
'dashArray': u',', 'attributes': [], 'type': u'Family', 'properties': {}},
{'labelArrow': u'none', 'arrowHead': u'triangle,5', 'name': u'Employment',
'args': [{'role': u'Arg1', 'targets': [u'Person']},
{'role': u'Arg2', 'targets': [u'GPE']}], 'color': u'black',
'labels': [u'Employment', u'Employ'], 'children': [], 'unused': False,
'dashArray': u',', 'attributes': [], 'type': u'Employment', 'properties': {}},
{'labelArrow': u'none', 'arrowHead': u'triangle,5', 'name': u'Ownership',
'args': [{'role': u'Arg1', 'targets': [u'Person']},
{'role': u'Arg2', 'targets': [u'Organization']}], 'color': u'black',
'labels': None, 'children': [], 'unused': False, 'dashArray': u',',
'attributes': [], 'type': u'Ownership', 'properties': {}},
{'labelArrow': u'none', 'arrowHead': u'triangle,5', 'name': u'Origin',
'args': [{'role': u'Arg1', 'targets': [u'Organization']},
{'role': u'Arg2', 'targets': [u'GPE']}], 'color': u'black',
'labels': None, 'children': [], 'unused': False, 'dashArray': u',',
'attributes': [], 'type': u'Origin', 'properties': {}},
{'labelArrow': u'none', 'arrowHead': u'none', 'name': u'Alias',
'args': [{'role': u'Arg1', 'targets': [u'Person']},
{'role': u'Arg2', 'targets': [u'Person']}],
'color': u'black', 'labels': None, 'children': [], 'unused': False,
'dashArray': u'3,3', 'attributes': [], 'type': u'Alias',
'properties': {u'symmetric': True, u'transitive': True}}]
full_collection_configuration.entity_types = [
{'borderColor': u'darken',
'normalizations': [],
'name': u'Person',
'arcs': [{'labelArrow': u'none', 'arrowHead': u'triangle,5', 'color': u'black',
'labels': [u'Located'], 'dashArray': u',', 'type': u'Located',
'targets': [u'GPE']},
{'labelArrow': u'none', 'arrowHead': u'triangle,5',
'color': u'black', 'labels': [u'Family'],
'dashArray': u',', 'type': u'Family',
'targets': [u'Person']},
{'labelArrow': u'none', 'arrowHead': u'triangle,5', 'color': u'black',
'labels': [u'Employment', u'Employ'], 'dashArray': u',',
'type': u'Employment', 'targets': [u'GPE']},
{'labelArrow': u'none', 'arrowHead': u'triangle,5', 'color': u'black',
'labels': [u'Ownership'], 'dashArray': u',', 'type': u'Ownership',
'targets': [u'Organization']},
{'labelArrow': u'none', 'arrowHead': u'none', 'color': u'black',
'labels': [u'Alias'], 'dashArray': u'3,3', 'type': u'Alias',
'targets': [u'Person']}],
'labels': [u'Person'],
'children': [],
'unused': False,
'bgColor': u'#FF821C',
'attributes': [u'Individual', u'Mention'],
'type': u'Person',
'fgColor': u'black'},
{'borderColor': u'darken', 'normalizations': [], 'name': u'Organization',
'arcs': [{'labelArrow': u'none', 'arrowHead': u'triangle,5', 'color': u'black',
'labels': [u'Origin'], 'dashArray': u',', 'type': u'Origin',
'targets': [u'GPE']}], 'labels': [u'Organization', u'Org'],
'children': [], 'unused': False, 'bgColor': u'#a7c2ff', 'hotkey': u'O',
'attributes': [u'Individual', u'Mention'], 'type': u'Organization',
'fgColor': u'black'},
{'borderColor': u'darken', 'normalizations': [],
'name': u'Geo-political entity',
'arcs': [{'labelArrow': u'none', 'arrowHead': u'triangle,5',
'color': u'black', 'labels': [u'Geographical part',
u'Geo part'],
'dashArray': u',', 'type': u'Geographical_part',
'targets': [u'GPE']}],
'labels': [u'Geo-political entity', u'GPE'], 'children': [],
'unused': False, 'bgColor': u'#FFD412', 'hotkey': u'G',
'attributes': [u'Individual', u'Mention'], 'type': u'GPE',
'fgColor': u'black'},
{'borderColor': u'darken',
'normalizations': [],
'name': u'Money', 'labels': None,
'children': [], 'unused': False,
'bgColor': u'#007000',
'hotkey': u'M',
'attributes': [u'Individual', u'Mention'],
'type': u'Money', 'fgColor': u'white'}]
full_collection_configuration.relation_attribute_types = []
full_collection_configuration.initialize()
In [5]:
intro_document_text = u"Welcome to the Brat Rapid Annotation Tool (brat) tutorial!\n\nbrat is a web-based tool for structured text annotation and visualization. The easiest way to explain what this means is by example: see the following sentence illustrating various types of annotation. Take a moment to study this example, moving your mouse cursor over some of the annotations. Hold the cursor still over an annotation for more detail.\n\n\n1 ) Citibank was involved in moving about $100 million for Raul Salinas de Gortari, brother of a former Mexican president, to banks in Switzerland.\n\n\nIf this example seems complicated, don't panic! This tutorial will present the key features of brat interactively, with each document presenting one or a few features. If you follow this brief tutorial, you'll be able to understand and create annotations such as those above in no time.\n\nTry moving to the next document now by clicking on the arrow to the right on the blue bar at the top left corner of the page.\n"
intro_document_token_offsets = [(0, 7), (8, 10), (11, 14), (15, 19), (20, 25), (26, 36), (37, 41),
(42, 48), (49, 58),
(60, 64), (65, 67), (68, 69), (70, 79), (80, 84), (85, 88), (89, 99),
(100, 104), (105, 115),
(116, 119), (120, 134), (135, 138), (139, 146), (147, 150), (151, 153),
(154, 161),
(162, 166), (167, 171), (172, 177), (178, 180), (181, 183), (184, 192),
(193, 196),
(197, 200), (201, 210), (211, 219), (220, 232), (233, 240), (241, 246),
(247, 249),
(250, 261), (262, 266), (267, 268), (269, 275), (276, 278), (279, 284),
(285, 289),
(290, 298), (299, 305), (306, 310), (311, 316), (317, 323), (324, 328),
(329, 333),
(334, 336), (337, 340), (341, 353), (354, 358), (359, 362), (363, 369),
(370, 375),
(376, 380), (381, 383), (384, 394), (395, 398), (399, 403), (404, 411),
(414, 415),
(416, 417), (418, 426), (427, 430), (431, 439), (440, 442), (443, 449),
(450, 455),
(456, 460), (461, 468), (469, 472), (473, 477), (478, 485), (486, 488),
(489, 497),
(498, 505), (506, 508), (509, 510), (511, 517), (518, 525), (526, 536),
(537, 539),
(540, 545), (546, 548), (549, 561), (564, 566), (567, 571), (572, 579),
(580, 585),
(586, 598), (599, 604), (605, 611), (612, 616), (617, 625), (626, 630),
(631, 638),
(639, 642), (643, 646), (647, 655), (656, 658), (659, 663), (664, 678),
(679, 683),
(684, 688), (689, 697), (698, 708), (709, 712), (713, 715), (716, 717),
(718, 721),
(722, 731), (732, 734), (735, 738), (739, 745), (746, 750), (751, 756),
(757, 766),
(767, 773), (774, 776), (777, 781), (782, 784), (785, 795), (796, 799),
(800, 806),
(807, 818), (819, 823), (824, 826), (827, 832), (833, 838), (839, 841),
(842, 844),
(845, 850), (852, 855), (856, 862), (863, 865), (866, 869), (870, 874),
(875, 883),
(884, 887), (888, 890), (891, 899), (900, 902), (903, 906), (907, 912),
(913, 915),
(916, 919), (920, 925), (926, 928), (929, 932), (933, 937), (938, 941),
(942, 944),
(945, 948), (949, 952), (953, 957), (958, 964), (965, 967), (968, 971),
(972, 977)]
intro_document_sentence_offsets = [(0, 58), (60, 411), (414, 561), (564, 850), (852, 977)]
intro_document = Document(intro_document_text, intro_document_token_offsets, intro_document_sentence_offsets,
full_collection_configuration)
intro_document.ctime = 1498628240.0
intro_document.mtime = 1498628240.0
intro_document.entities = [
[u'T1', u'Organization', [(418, 426)]],
[u'T2', u'Money', [(456, 468)]],
[u'T4', u'Person', [(473, 496)]],
[u'T5', u'Person', [(511, 535)]],
[u'T6', u'Organization', [(540, 545)]],
[u'T7', u'GPE', [(549, 560)]],
[u'T8', u'Person', [(290, 297)]],
[u'T9', u'Organization', [(311, 316)]],
[u'T10', u'Organization', [(299, 305)]],
[u'T12', u'Person', [(659, 688)]],
#Triggers
[u'T3', u'Transfer-money', [(443, 449)]],
[u'T11', u'End-org', [(329, 333)]],
[u'T13', u'Divorce', [(722, 730)]]
]
intro_document.relations = [[u'R2', u'Origin', [(u'Arg1', u'T6'), (u'Arg2', u'T7')]],
[u'R1', u'Family', [(u'Arg1', u'T4'), (u'Arg2', u'T5')]]]
intro_document.events = [
[u'E1', u'T3', [(u'Giver-Arg', u'T1'), (u'Money-Arg', u'T2'), (u'Beneficiary-Arg', u'T4'),
(u'Recipient-Arg', u'T6')]],
[u'E2', u'T11', []],
[u'E3', u'T13', []]]
intro_document.attributes = [[u'A1', u'Mention', u'T4', u'Name'],
[u'A2', u'Individual', u'T4', True],
[u'A3', u'Mention', u'T5', u'Nominal'],
[u'A4', u'Individual', u'T5', True],
[u'A5', u'Confidence', u'E1', u'High'],
[u'A6', u'Mention', u'T8', u'Name'],
[u'A7', u'Individual', u'T8', True],
[u'A8', u'Mention', u'T9', u'Nominal'],
[u'A9', u'Individual', u'T9', True],
[u'A10', u'Confidence', u'E2', u'High']]
intro_document.comments = [[u'T2', u'AnnotatorNotes', u'100000000 USD'],
(u'E2', 'AnnotationIncomplete',
u'Incomplete: exactly one Org argument required for event'),
(u'E3', 'AnnotationIncomplete',
u'Incomplete: exactly 2 Person arguments required for event')]
intro_document.equivs = []
intro_document.normalizations = [[u'N1', u'Reference', u'T5', u'Wikipedia', u'64488',
u'Carlos Salinas de Gortari']]
intro_document.modifications = []
intro_document.initialize()
In [6]:
intro_document.update_lists()
intro_document.relations
Out[6]:
In [7]:
intro_document.events
Out[7]:
In [8]:
intro = Annotator(value=intro_document,
collection_configuration=full_collection_configuration,
general_configuration=GeneralConfiguration())
display(intro)
In [9]:
intro_document.update_lists()
intro_document.relations
Out[9]:
In [10]:
intro_document.events
Out[10]:
In [11]:
mammut_configuration_1 = CollectionConfiguration()
mammut_configuration_1.description = None
mammut_configuration_1.disambiguator_config = []
mammut_configuration_1.entity_attribute_types = [{'labels': None,
'name': 'gender',
'type': 'S-gender',
'unused': False,
'values': [{'dashArray': ',', 'glyph': '↑', 'name': 'm'},
{'dashArray': ',', 'glyph': '↑', 'name': 'f'}]},
{'labels': None,
'name': 'number',
'type': 'S-number',
'unused': False,
'values': [{'dashArray': ',', 'glyph': '↑', 'name': 's'},
{'dashArray': ',', 'glyph': '↑', 'name': 'p'}]},
{'labels': None,
'name': 'finiteness',
'type': 'S-finiteness',
'unused': False,
'values': [{'box': 'crossed', 'name': 'inf'}]},
{'labels': None,
'name': 'gender',
'type': 'V-gender',
'unused': False,
'values': [{'dashArray': ',', 'glyph': '↑', 'name': 'm'},
{'dashArray': ',', 'glyph': '↑', 'name': 'f'}]},
{'labels': None,
'name': 'number',
'type': 'V-number',
'unused': False,
'values': [{'dashArray': ',', 'glyph': '↑', 'name': 's'},
{'dashArray': ',', 'glyph': '↑', 'name': 'p'}]},
{'labels': None,
'name': 'tense',
'type': 'V-tense',
'unused': False,
'values': [{'dashArray': ',', 'glyph': '↑', 'name': 'pre'},
{'dashArray': ',', 'glyph': '↑', 'name': 'pas'},
{'dashArray': ',', 'glyph': '↑', 'name': 'fut'},
{'dashArray': ',', 'glyph': '↑', 'name': 'cop'},
{'dashArray': ',', 'glyph': '↑', 'name': 'posp'}]},
{'labels': None,
'name': 'person',
'type': 'V-person',
'unused': False,
'values': [{'dashArray': ',', 'glyph': '↑', 'name': '1'},
{'dashArray': ',', 'glyph': '↑', 'name': '2'},
{'dashArray': ',', 'glyph': '↑', 'name': '3'}]},
{'labels': None,
'name': 'mood',
'type': 'V-mood',
'unused': False,
'values': [{'dashArray': ',', 'glyph': '↑', 'name': 'ind'},
{'dashArray': ',', 'glyph': '↑', 'name': 'imp'},
{'dashArray': ',', 'glyph': '↑', 'name': 'sub'}]},
{'labels': None,
'name': 'finite',
'type': 'V-finite',
'unused': False,
'values': [{'dashArray': ',', 'glyph': '↑', 'name': 'part'},
{'dashArray': ',', 'glyph': '↑', 'name': 'ger'}]},
{'labels': None,
'name': 'finiteness',
'type': 'V-finiteness',
'unused': False,
'values': [{'box': 'crossed', 'name': 'inf'}]},
{'labels': None,
'name': 'gender',
'type': 'A-gender',
'unused': False,
'values': [{'dashArray': ',', 'glyph': '↑', 'name': 'm'},
{'dashArray': ',', 'glyph': '↑', 'name': 'f'}]},
{'labels': None,
'name': 'number',
'type': 'A-number',
'unused': False,
'values': [{'dashArray': ',', 'glyph': '↑', 'name': 's'},
{'dashArray': ',', 'glyph': '↑', 'name': 'p'}]},
{'labels': None,
'name': 'finite',
'type': 'A-finite',
'unused': False,
'values': [{'box': 'crossed', 'name': 'part'}]},
{'labels': None,
'name': 'finite',
'type': 'ADV-finite',
'unused': False,
'values': [{'box': 'crossed', 'name': 'ger'}]},
{'labels': None,
'name': 'pronominales',
'type': 'D-pronominales',
'unused': False,
'values': [{'dashArray': ',', 'glyph': '↑', 'name': 'neg'},
{'dashArray': ',', 'glyph': '↑', 'name': 'int'},
{'dashArray': ',', 'glyph': '↑', 'name': 'exc'},
{'dashArray': ',', 'glyph': '↑', 'name': 'prs'},
{'dashArray': ',', 'glyph': '↑', 'name': 'art'}]},
{'labels': None,
'name': 'pronominales',
'type': 'P-pronominales',
'unused': False,
'values': [{'dashArray': ',', 'glyph': '↑', 'name': 'neg'},
{'dashArray': ',', 'glyph': '↑', 'name': 'int'},
{'dashArray': ',', 'glyph': '↑', 'name': 'prs'}]}]
mammut_configuration_1.event_types = [{'arcs': [
{'arrowHead': 'triangle,5',
'color': 'black',
'count': '*',
'dashArray': ',',
'labelArrow': 'none',
'labels': ['Sustantivo', 'S'],
'name': 'Sustantivo',
'targets': ['S'],
'type': 'S-Arg'},
{'arrowHead': 'triangle,5',
'color': 'black',
'count': '*',
'dashArray': ',',
'labelArrow': 'none',
'labels': ['Verbo', 'V'],
'name': 'Verbo',
'targets': ['V'],
'type': 'V-Arg'},
{'arrowHead': 'triangle,5',
'color': 'black',
'count': '*',
'dashArray': ',',
'labelArrow': 'none',
'labels': ['Adjetivo', 'A'],
'name': 'Adjetivo',
'targets': ['A'],
'type': 'A-Arg'},
{'arrowHead': 'triangle,5',
'color': 'black',
'count': '*',
'dashArray': ',',
'labelArrow': 'none',
'labels': ['Adverbio', 'ADV'],
'name': 'Adverbio',
'targets': ['ADV'],
'type': 'ADV-Arg'},
{'arrowHead': 'triangle,5',
'color': 'black',
'count': '*',
'dashArray': ',',
'labelArrow': 'none',
'labels': ['Interjeccion', 'I'],
'name': 'Interjeccion',
'targets': ['I'],
'type': 'I-Arg'},
{'arrowHead': 'triangle,5',
'color': 'black',
'count': '*',
'dashArray': ',',
'labelArrow': 'none',
'labels': ['Preposicion', 'PREP'],
'name': 'Preposicion',
'targets': ['PREP'],
'type': 'PREP-Arg'},
{'arrowHead': 'triangle,5',
'color': 'black',
'count': '*',
'dashArray': ',',
'labelArrow': 'none',
'labels': ['Determinante', 'D'],
'name': 'Determinante',
'targets': ['D'],
'type': 'D-Arg'},
{'arrowHead': 'triangle,5',
'color': 'black',
'count': '*',
'dashArray': ',',
'labelArrow': 'none',
'labels': ['Pronombre', 'P'],
'name': 'Pronombre',
'targets': ['P'],
'type': 'P-Arg'},
{'arrowHead': 'triangle,5',
'color': 'black',
'count': '*',
'dashArray': ',',
'labelArrow': 'none',
'labels': ['Conjuncion', 'C'],
'name': 'Conjuncion',
'targets': ['C'],
'type': 'C-Arg'},
{'arrowHead': 'triangle,5',
'color': 'black',
'count': '*',
'dashArray': ',',
'labelArrow': 'none',
'labels': ['Auxiliar', 'AUX'],
'name': 'Auxiliar',
'targets': ['AUX'],
'type': 'AUX-Arg'},
{'arrowHead': 'triangle,5',
'color': 'black',
'count': '*',
'dashArray': ',',
'labelArrow': 'none',
'labels': ['Nexus', 'NEX'],
'name': 'Nexus',
'targets': ['NEX'],
'type': 'NEX-Arg'},
{'arrowHead': 'triangle,5',
'color': 'black',
'count': '*',
'dashArray': ',',
'labelArrow': 'none',
'labels': ['Article', 'ART'],
'name': 'Article',
'targets': ['ART'],
'type': 'ART-Arg'}],
'attributes': [],
'bgColor': 'lightgreen',
'borderColor': 'darken',
'children': [],
'fgColor': 'black',
'keys_by_type': {'A': ['A-Arg'],
'ADV': ['ADV-Arg'],
'ART': ['ART-Arg'],
'AUX': ['AUX-Arg'],
'C': ['C-Arg'],
'D': ['D-Arg'],
'I': ['I-Arg'],
'NEX': ['NEX-Arg'],
'P': ['P-Arg'],
'PREP': ['PREP-Arg'],
'S': ['S-Arg'],
'V': ['V-Arg']},
'labels': ['LocV', 'LOC_V'],
'name': 'LocV',
'normalizations': [],
'type': 'LOC_V',
'unused': False}]
mammut_configuration_1.ui_names = {'attributes': 'features', 'entities': 'pos', 'events': 'pos-arcs',
'relations': 'relations'}
mammut_configuration_1.normalization_config = []
mammut_configuration_1.visual_options = {'arc_bundle': 'none', 'text_direction': 'ltr'}
mammut_configuration_1.messages = []
mammut_configuration_1.event_attribute_types = []
mammut_configuration_1.annotation_logging = False
mammut_configuration_1.ner_taggers = []
mammut_configuration_1.relation_types = []
mammut_configuration_1.entity_types = [{'arcs': [],
'attributes': ['S-gender', 'S-number', 'S-finiteness'],
'bgColor': '#FF821C',
'borderColor': 'darken',
'children': [],
'fgColor': 'black',
'keys_by_type': {},
'labels': ['Sustantivo', 'S'],
'name': 'Sustantivo',
'normalizations': [],
'type': 'S',
'unused': False},
{'arcs': [],
'attributes': ['V-gender',
'V-number',
'V-tense',
'V-person',
'V-mood',
'V-finite',
'V-finiteness'],
'bgColor': '#FF821C',
'borderColor': 'darken',
'children': [],
'fgColor': 'black',
'keys_by_type': {},
'labels': ['Verbo', 'V'],
'name': 'Verbo',
'normalizations': [],
'type': 'V',
'unused': False},
{'arcs': [],
'attributes': ['A-gender', 'A-number', 'A-finite'],
'bgColor': '#FF821C',
'borderColor': 'darken',
'children': [],
'fgColor': 'black',
'keys_by_type': {},
'labels': ['Adjetivo', 'A'],
'name': 'Adjetivo',
'normalizations': [],
'type': 'A',
'unused': False},
{'arcs': [],
'attributes': ['ADV-finite'],
'bgColor': '#FF821C',
'borderColor': 'darken',
'children': [],
'fgColor': 'black',
'keys_by_type': {},
'labels': ['Adverbio', 'ADV'],
'name': 'Adverbio',
'normalizations': [],
'type': 'ADV',
'unused': False},
{'arcs': [],
'attributes': [],
'bgColor': '#FF821C',
'borderColor': 'darken',
'children': [],
'fgColor': 'black',
'keys_by_type': {},
'labels': ['Interjeccion', 'I'],
'name': 'Interjeccion',
'normalizations': [],
'type': 'I',
'unused': False},
{'arcs': [],
'attributes': [],
'bgColor': '#FF821C',
'borderColor': 'darken',
'children': [],
'fgColor': 'black',
'keys_by_type': {},
'labels': ['Preposicion', 'PREP'],
'name': 'Preposicion',
'normalizations': [],
'type': 'PREP',
'unused': False},
{'arcs': [],
'attributes': ['D-tipos pronominales'],
'bgColor': '#FF821C',
'borderColor': 'darken',
'children': [],
'fgColor': 'black',
'keys_by_type': {},
'labels': ['Determinante', 'D'],
'name': 'Determinante',
'normalizations': [],
'type': 'D',
'unused': False},
{'arcs': [],
'attributes': ['P-tipos pronominales'],
'bgColor': '#FF821C',
'borderColor': 'darken',
'children': [],
'fgColor': 'black',
'keys_by_type': {},
'labels': ['Pronombre', 'P'],
'name': 'Pronombre',
'normalizations': [],
'type': 'P',
'unused': False},
{'arcs': [],
'attributes': [],
'bgColor': '#FF821C',
'borderColor': 'darken',
'children': [],
'fgColor': 'black',
'keys_by_type': {},
'labels': ['Conjuncion', 'C'],
'name': 'Conjuncion',
'normalizations': [],
'type': 'C',
'unused': False},
{'arcs': [],
'attributes': [],
'bgColor': '#FF821C',
'borderColor': 'darken',
'children': [],
'fgColor': 'black',
'keys_by_type': {},
'labels': ['Auxiliar', 'AUX'],
'name': 'Auxiliar',
'normalizations': [],
'type': 'AUX',
'unused': False},
{'arcs': [],
'attributes': [],
'bgColor': '#FF821C',
'borderColor': 'darken',
'children': [],
'fgColor': 'black',
'keys_by_type': {},
'labels': ['Nexus', 'NEX'],
'name': 'Nexus',
'normalizations': [],
'type': 'NEX',
'unused': False},
{'arcs': [],
'attributes': [],
'bgColor': '#FF821C',
'borderColor': 'darken',
'children': [],
'fgColor': 'black',
'keys_by_type': {},
'labels': ['Article', 'ART'],
'name': 'Article',
'normalizations': [],
'type': 'ART',
'unused': False}]
mammut_configuration_1.relation_attribute_types = []
mammut_configuration_1.initialize()
In [12]:
mammut_document_text_1 = '¿Van hoy a hacer ofertas especiales en Franca?'
mammut_document_token_offsets_1 = [
(0, 0),
(1, 3),
(4, 4),
(5, 7),
(8, 8),
(9, 9),
(10, 10),
(11, 15),
(16, 16),
(17, 23),
(24, 24),
(25, 34),
(35, 35),
(36, 37),
(38, 38),
(39, 44),
(45, 45)
]
mammut_document_token_offsets_1 = []
mammut_document_sentence_offsets_1 = [(0, 45)]
#mammut_document_sentence_offsets_1 = []
mammut_document_1 = Document(mammut_document_text_1, mammut_document_token_offsets_1, mammut_document_sentence_offsets_1,
mammut_configuration_1)#full_collection_configuration)
#mammut_document_1.ctime = 1498628240.0
#mammut_document_1.mtime = 1498628240.0
#mammut_document_1.entities = []
#mammut_document_1.relations = []
#mammut_document_1.events = []
#mammut_document_1.attributes = []
#mammut_document_1.comments = []
#mammut_document_1.equivs = []
#mammut_document_1.normalizations = []
#mammut_document_1.modifications = []
mammut_document_1.initialize()
In [13]:
mammut_annotator_1 = Annotator(value=mammut_document_1, collection_configuration=mammut_configuration_1,#full_collection_configuration,#mammut_configuration_1,
general_configuration=GeneralConfiguration())
display(mammut_annotator_1)
In [ ]: