-
Notifications
You must be signed in to change notification settings - Fork 0
/
mtap.html
2747 lines (2580 loc) · 291 KB
/
mtap.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<title>mtap — MTAP 1.0.0 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/sphinxdoc.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/sphinx_highlight.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="mtap.deployment" href="deployment.html" />
<link rel="prev" title="Welcome to MTAP’s documentation!" href="index.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="deployment.html" title="mtap.deployment"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="index.html" title="Welcome to MTAP’s documentation!"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">MTAP 1.0.0 documentation</a> »</li>
<li class="nav-item nav-item-this"><a href="">mtap</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="module-mtap">
<span id="mtap"></span><h1><a class="toc-backref" href="#id1" role="doc-backlink">mtap</a><a class="headerlink" href="#module-mtap" title="Permalink to this heading">¶</a></h1>
<nav class="contents" id="contents">
<p class="topic-title">Contents</p>
<ul class="simple">
<li><p><a class="reference internal" href="#module-mtap" id="id1">mtap</a></p>
<ul>
<li><p><a class="reference internal" href="#command-line-utility" id="id2">Command-Line Utility</a></p>
<ul>
<li><p><a class="reference internal" href="#running-events-service" id="id3">Running Events Service</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#api-documentation" id="id4">API Documentation</a></p>
<ul>
<li><p><a class="reference internal" href="#events-service-client-documents" id="id5">Events service client, documents</a></p></li>
<li><p><a class="reference internal" href="#labels" id="id6">Labels</a></p></li>
<li><p><a class="reference internal" href="#label-indices" id="id7">Label Indices</a></p></li>
<li><p><a class="reference internal" href="#custom-label-types" id="id8">Custom Label Types</a></p></li>
<li><p><a class="reference internal" href="#creating-processors" id="id9">Creating Processors</a></p></li>
<li><p><a class="reference internal" href="#processor-description-decorators" id="id10">Processor Description Decorators</a></p></li>
<li><p><a class="reference internal" href="#running-services" id="id11">Running Services</a></p></li>
<li><p><a class="reference internal" href="#running-a-pipeline" id="id12">Running a pipeline</a></p></li>
<li><p><a class="reference internal" href="#configuration" id="id13">Configuration</a></p></li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
<section id="command-line-utility">
<h2><a class="toc-backref" href="#id2" role="doc-backlink">Command-Line Utility</a><a class="headerlink" href="#command-line-utility" title="Permalink to this heading">¶</a></h2>
<section id="running-events-service">
<h3><a class="toc-backref" href="#id3" role="doc-backlink">Running Events Service</a><a class="headerlink" href="#running-events-service" title="Permalink to this heading">¶</a></h3>
<p>usage:</p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>python -m mtap events [-h] [--address ADDRESS] [--port PORT]
[--workers WORKERS] [--register] [--config CONFIG]
optional arguments:
-h, --help show this help message and exit
--address ADDRESS, -a ADDRESS
the address to serve the service on
--port PORT, -p PORT the port to serve the service on
--workers WORKERS, -w WORKERS
number of worker threads to handle requests
--register, -r whether to register the service with the configured
service discovery
--config CONFIG, -c CONFIG
path to config file
</pre></div>
</div>
</section>
</section>
<section id="api-documentation">
<h2><a class="toc-backref" href="#id4" role="doc-backlink">API Documentation</a><a class="headerlink" href="#api-documentation" title="Permalink to this heading">¶</a></h2>
<section id="events-service-client-documents">
<h3><a class="toc-backref" href="#id5" role="doc-backlink">Events service client, documents</a><a class="headerlink" href="#events-service-client-documents" title="Permalink to this heading">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="mtap.EventsClient">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mtap.</span></span><span class="sig-name descname"><span class="pre">EventsClient</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">address</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">channel_factory</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">_pool</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">_channel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_events.html#EventsClient"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.EventsClient" title="Permalink to this definition">¶</a></dt>
<dd><p>A client object for interacting with the events service.</p>
<p>Normally, users shouldn’t have to use any of the methods on this object, as they are invoked by
the globally distributed object classes of <a class="reference internal" href="#mtap.Event" title="mtap.Event"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Event</span></code></a>, <a class="reference internal" href="#mtap.Document" title="mtap.Document"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Document</span></code></a>, and <a class="reference internal" href="#mtap.data.Labeler" title="mtap.data.Labeler"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Labeler</span></code></a>.</p>
<dl class="field-list simple">
<dt class="field-odd">Keyword Arguments<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>address</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.11)"><em>Optional</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)"><em>str</em></a><em>]</em>) – The events service target e.g. ‘localhost:9090’ or
omit/None to use service discovery.</p></li>
<li><p><strong>stub</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.11)"><em>Optional</em></a><em>[</em><em>EventsStub</em><em>]</em>) – An existing events service
client gRPC stub to use.</p></li>
</ul>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">with</span> <span class="n">EventsClient</span><span class="p">(</span><span class="n">address</span><span class="o">=</span><span class="s1">'localhost:50000'</span><span class="p">)</span> <span class="k">as</span> <span class="n">client</span><span class="p">,</span> \
<span class="gp">>>> </span> <span class="n">Event</span><span class="p">(</span><span class="n">event_id</span><span class="o">=</span><span class="s1">'1'</span><span class="p">,</span> <span class="n">client</span><span class="o">=</span><span class="n">client</span><span class="p">)</span> <span class="k">as</span> <span class="n">event</span><span class="p">:</span>
<span class="gp">>>> </span> <span class="n">document</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">create_document</span><span class="p">(</span><span class="n">document_name</span><span class="o">=</span><span class="s1">'plaintext'</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">text</span><span class="o">=</span><span class="s1">'The quick brown fox jumps over the lazy dog.'</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="mtap.Event">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mtap.</span></span><span class="sig-name descname"><span class="pre">Event</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">event_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">event_service_instance_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">client</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">only_create_new</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default_adapters</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_events.html#Event"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.Event" title="Permalink to this definition">¶</a></dt>
<dd><p>An object for interacting with a specific event locally or on the events service.</p>
<p>The Event object functions as a map from string document names to <a class="reference internal" href="#mtap.Document" title="mtap.Document"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Document</span></code></a> objects that
can be used to access document data from the events server.</p>
<dl class="field-list simple">
<dt class="field-odd">Keyword Arguments<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>event_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.11)"><em>Optional</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)"><em>str</em></a><em>]</em>) – A globally-unique identifier for the event, or omit / none for a random UUID.</p></li>
<li><p><strong>client</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.11)"><em>Optional</em></a><em>[</em><a class="reference internal" href="#mtap.EventsClient" title="mtap.EventsClient"><em>EventsClient</em></a><em>]</em>) – A client for an events service to push any changes to the event to.</p></li>
<li><p><strong>only_create_new</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.11)"><em>bool</em></a>) – Fails if the event already exists on the events service.</p></li>
</ul>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">with</span> <span class="n">EventsClient</span><span class="p">()</span> <span class="k">as</span> <span class="n">c</span><span class="p">,</span> <span class="n">Event</span><span class="p">(</span><span class="n">event_id</span><span class="o">=</span><span class="s1">'id'</span><span class="p">,</span> <span class="n">client</span><span class="o">=</span><span class="n">c</span><span class="p">)</span> <span class="k">as</span> <span class="n">event</span><span class="p">:</span>
<span class="gp">>>> </span> <span class="c1"># use event</span>
<span class="gp">>>> </span> <span class="o">...</span>
</pre></div>
</div>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.Event.event_id">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">event_id</span></span><a class="headerlink" href="#mtap.Event.event_id" title="Permalink to this definition">¶</a></dt>
<dd><p>The globally unique identifier for this event.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)">str</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.Event.event_service_instance_id">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">event_service_instance_id</span></span><a class="headerlink" href="#mtap.Event.event_service_instance_id" title="Permalink to this definition">¶</a></dt>
<dd><p>The unique instance identifier for this event’s paired event service.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)">str</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.Event.documents">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">documents</span></span><a class="headerlink" href="#mtap.Event.documents" title="Permalink to this definition">¶</a></dt>
<dd><p>A mutable mapping of strings to <a class="reference internal" href="#mtap.Document" title="mtap.Document"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Document</span></code></a>
objects that can be used to query and add documents to the event.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.MutableMapping" title="(in Python v3.11)"><em>MutableMapping</em></a>[<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)">str</a>, <a class="reference internal" href="#mtap.Document" title="mtap.Document">Document</a>]</p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.Event.metadata">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">metadata</span></span><a class="headerlink" href="#mtap.Event.metadata" title="Permalink to this definition">¶</a></dt>
<dd><p>A mutable mapping of strings to strings that can be
used to query and add metadata to the event.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.MutableMapping" title="(in Python v3.11)"><em>MutableMapping</em></a>[<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)">str</a>, <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)">str</a>]</p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.Event.binaries">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">binaries</span></span><a class="headerlink" href="#mtap.Event.binaries" title="Permalink to this definition">¶</a></dt>
<dd><p>A mutable mapping of strings to bytes that can be used
to query and add binary data to the event.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.MutableMapping" title="(in Python v3.11)"><em>MutableMapping</em></a>[<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)">str</a>, <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)">str</a>]</p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.Event.created_indices">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">created_indices</span></span><a class="headerlink" href="#mtap.Event.created_indices" title="Permalink to this definition">¶</a></dt>
<dd><p>A mapping of document names to a list of the names
of all the label indices that have been added to that document</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Dict" title="(in Python v3.11)"><em>Dict</em></a>[<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)">str</a>, <a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.List" title="(in Python v3.11)"><em>List</em></a>[<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)">str</a>]]</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="mtap.Event.close">
<span class="sig-name descname"><span class="pre">close</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_events.html#Event.close"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.Event.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Closes this event. Lets the event service know that we are done with the event,
allowing to clean up the event if no other clients have open leases to it.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="mtap.Event.create_document">
<span class="sig-name descname"><span class="pre">create_document</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">document_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">text</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_events.html#Event.create_document"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.Event.create_document" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a document to the event keyed by <cite>document_name</cite> and
containing the specified <cite>text</cite>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>document_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)"><em>str</em></a>) – The event-unique identifier for the document, example: ‘plaintext’.</p></li>
<li><p><strong>text</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)"><em>str</em></a>) – The content of the document. This is a required field, document text is final and
immutable, as changing the text would very likely invalidate any labels on the
document.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>The added document.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="#mtap.Document" title="mtap.Document">Document</a></p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">event</span> <span class="o">=</span> <span class="n">Event</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">document</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">create_document</span><span class="p">(</span><span class="s1">'plaintext'</span><span class="p">,</span> <span class="n">text</span><span class="o">=</span><span class="s2">"The text of the document."</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="mtap.Event.add_document">
<span class="sig-name descname"><span class="pre">add_document</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">document</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_events.html#Event.add_document"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.Event.add_document" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds the document to this event, first uploading to events service if this event has a
client connection to the events service.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>document</strong> (<a class="reference internal" href="#mtap.Document" title="mtap.Document"><em>Document</em></a>) – The document to add to this event.</p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">event</span> <span class="o">=</span> <span class="n">Event</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">document</span> <span class="o">=</span> <span class="n">Document</span><span class="p">(</span><span class="s1">'plaintext'</span><span class="p">,</span> <span class="n">text</span><span class="o">=</span><span class="s2">"The text of the document."</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">event</span><span class="o">.</span><span class="n">add_document</span><span class="p">(</span><span class="n">document</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="mtap.Document">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mtap.</span></span><span class="sig-name descname"><span class="pre">Document</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">document_name</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">text</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">event</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default_adapters</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_events.html#Document"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.Document" title="Permalink to this definition">¶</a></dt>
<dd><p>An object for interacting with text and labels stored on an <a class="reference internal" href="#mtap.Event" title="mtap.Event"><code class="xref py py-class docutils literal notranslate"><span class="pre">Event</span></code></a>.</p>
<p>Documents are keyed by their name, and pipelines can store different pieces of
related text on a single processing event using multiple documents. An example would be storing
the text of one language on one document, and a translation on another, or storing the
rtf or html encoding on one document, and the parsed plaintext on another document.</p>
<p>Both the document text and any added label indices are immutable. This is to enable
parallelization and distribution of processing, and to prevent changes to the dependency graph
of label indices and text, which can make debugging difficult.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>document_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)"><em>str</em></a>) – The document name identifier.</p>
</dd>
<dt class="field-even">Keyword Arguments<span class="colon">:</span></dt>
<dd class="field-even"><ul class="simple">
<li><p><strong>text</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.11)"><em>Optional</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)"><em>str</em></a><em>]</em>) – The document text, can be omitted if this is an existing document and text needs to be
retrieved from the events service.</p></li>
<li><p><strong>event</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.11)"><em>Optional</em></a><em>[</em><a class="reference internal" href="#mtap.Event" title="mtap.Event"><em>Event</em></a><em>]</em>) – The parent event of this document. If the event has a client, then that client will be
used to share changes to this document with all other clients of the Events service. In
that case, text should only be specified if it is the known existing text of the
document.</p></li>
</ul>
</dd>
</dl>
<p class="rubric">Examples</p>
<p>Local document:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">document</span> <span class="o">=</span> <span class="n">Document</span><span class="p">(</span><span class="s1">'plaintext'</span><span class="p">,</span> <span class="n">text</span><span class="o">=</span><span class="s1">'Some document text.'</span><span class="p">)</span>
</pre></div>
</div>
<p>Existing distributed object:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">with</span> <span class="n">EventsClient</span><span class="p">(</span><span class="n">address</span><span class="o">=</span><span class="s1">'localhost:8080'</span><span class="p">)</span> <span class="k">as</span> <span class="n">client</span><span class="p">,</span> \
<span class="gp">>>> </span> <span class="n">Event</span><span class="p">(</span><span class="n">event_id</span><span class="o">=</span><span class="s1">'1'</span><span class="p">,</span> <span class="n">client</span><span class="o">=</span><span class="n">client</span><span class="p">)</span> <span class="k">as</span> <span class="n">event</span><span class="p">:</span>
<span class="gp">>>> </span> <span class="n">document</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">documents</span><span class="p">[</span><span class="s1">'plaintext'</span><span class="p">]</span>
<span class="gp">>>> </span> <span class="n">document</span><span class="o">.</span><span class="n">text</span>
<span class="go">'Some document text fetched from the server.'</span>
</pre></div>
</div>
<p>New distributed object:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">with</span> <span class="n">EventsClient</span><span class="p">(</span><span class="n">address</span><span class="o">=</span><span class="s1">'localhost:8080'</span><span class="p">)</span> <span class="k">as</span> <span class="n">client</span><span class="p">,</span> \
<span class="gp">>>> </span> <span class="n">Event</span><span class="p">(</span><span class="n">event_id</span><span class="o">=</span><span class="s1">'1'</span><span class="p">,</span> <span class="n">client</span><span class="o">=</span><span class="n">client</span><span class="p">)</span> <span class="k">as</span> <span class="n">event</span><span class="p">:</span>
<span class="gp">>>> </span> <span class="n">document</span> <span class="o">=</span> <span class="n">Document</span><span class="p">(</span><span class="s1">'plaintext'</span><span class="p">,</span> <span class="n">text</span><span class="o">=</span><span class="s1">'Some document text.'</span><span class="p">)</span>
<span class="gp">>>> </span> <span class="n">event</span><span class="o">.</span><span class="n">add_document</span><span class="p">(</span><span class="n">document</span><span class="p">)</span>
</pre></div>
</div>
<p>or</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">with</span> <span class="n">EventsClient</span><span class="p">(</span><span class="n">address</span><span class="o">=</span><span class="s1">'localhost:8080'</span><span class="p">)</span> <span class="k">as</span> <span class="n">client</span><span class="p">,</span> \
<span class="gp">>>> </span> <span class="n">Event</span><span class="p">(</span><span class="n">event_id</span><span class="o">=</span><span class="s1">'1'</span><span class="p">,</span> <span class="n">client</span><span class="o">=</span><span class="n">client</span><span class="p">)</span> <span class="k">as</span> <span class="n">event</span><span class="p">:</span>
<span class="gp">>>> </span> <span class="n">document</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">create_document</span><span class="p">(</span><span class="s1">'plaintext'</span><span class="p">,</span> <span class="n">text</span><span class="o">=</span><span class="s1">'Some document text.'</span><span class="p">)</span>
</pre></div>
</div>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.Document.event">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">event</span></span><a class="headerlink" href="#mtap.Document.event" title="Permalink to this definition">¶</a></dt>
<dd><p>The parent event of this document.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="#mtap.Event" title="mtap.Event">Event</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.Document.document_name">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">document_name</span></span><a class="headerlink" href="#mtap.Document.document_name" title="Permalink to this definition">¶</a></dt>
<dd><p>The unique identifier for this document on the event.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)">str</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.Document.text">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">text</span></span><a class="headerlink" href="#mtap.Document.text" title="Permalink to this definition">¶</a></dt>
<dd><p>The document text.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)">str</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.Document.created_indices">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">created_indices</span></span><a class="headerlink" href="#mtap.Document.created_indices" title="Permalink to this definition">¶</a></dt>
<dd><p>A list of all of the label index names that have created on this
document using a labeler either locally or by remote pipeline components invoked on
this document.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.List" title="(in Python v3.11)"><em>List</em></a>[<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)">str</a>]</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="mtap.Document.get_label_index">
<span class="sig-name descname"><span class="pre">get_label_index</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">label_index_name</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_events.html#Document.get_label_index"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.Document.get_label_index" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the document’s label index with the specified key.</p>
<p>Will fetch from the events service if it is not cached locally if the document has an event
with a client. Uses the <cite>label_adapter</cite> argument to perform unmarshalling from the proto
message if specified.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>label_index_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)"><em>str</em></a>) – The name of the label index to get.</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>The requested label index.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="#mtap.data.LabelIndex" title="mtap.data.LabelIndex">LabelIndex</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="mtap.Document.get_labeler">
<span class="sig-name descname"><span class="pre">get_labeler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">label_index_name</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">distinct</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_events.html#Document.get_labeler"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.Document.get_labeler" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a function that can be used to add labels to a label index.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>label_index_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)"><em>str</em></a>) – A document-unique identifier for the label index to be created.</p></li>
<li><p><strong>distinct</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.11)"><em>Optional</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.11)"><em>bool</em></a><em>]</em>) – Optional, if using generic labels, whether to use distinct generic labels or
non-distinct generic labels, will default to False.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A callable when used in conjunction with the ‘with’ keyword will automatically
handle uploading any added labels to the server.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="#mtap.data.Labeler" title="mtap.data.Labeler">Labeler</a></p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">with</span> <span class="n">document</span><span class="o">.</span><span class="n">get_labeler</span><span class="p">(</span><span class="s1">'sentences'</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="k">as</span> <span class="n">labeler</span><span class="p">:</span>
<span class="gp">>>> </span> <span class="n">labeler</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">25</span><span class="p">,</span> <span class="n">sentence_type</span><span class="o">=</span><span class="s1">'STANDARD'</span><span class="p">)</span>
<span class="gp">>>> </span> <span class="n">sentence</span> <span class="o">=</span> <span class="n">labeler</span><span class="p">(</span><span class="mi">26</span><span class="p">,</span> <span class="mi">34</span><span class="p">)</span>
<span class="gp">>>> </span> <span class="n">sentence</span><span class="o">.</span><span class="n">sentence_type</span> <span class="o">=</span> <span class="s1">'FRAGMENT'</span>
</pre></div>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="mtap.Document.add_labels">
<span class="sig-name descname"><span class="pre">add_labels</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">label_index_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">labels</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">distinct</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_adapter</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_events.html#Document.add_labels"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.Document.add_labels" title="Permalink to this definition">¶</a></dt>
<dd><p>Skips using a labeler and adds the sequence of labels as a new label index.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>label_index_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)"><em>str</em></a>) – The name of the label index.</p></li>
<li><p><strong>labels</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Sequence" title="(in Python v3.11)"><em>Sequence</em></a><em>[</em><a class="reference internal" href="#mtap.data.Label" title="mtap.data.Label"><em>Label</em></a><em>]</em>) – The labels to add.</p></li>
<li><p><strong>distinct</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.11)"><em>Optional</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.11)"><em>bool</em></a><em>]</em>) – Whether the index is distinct or non-distinct.</p></li>
<li><p><strong>label_adapter</strong> (<em>mtap.label_adapters.ProtoLabelAdapter</em>) – A label adapter to use.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>The new label index created from the labels.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="#mtap.data.LabelIndex" title="mtap.data.LabelIndex">LabelIndex</a></p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="mtap.data.Labeler">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mtap.data.</span></span><span class="sig-name descname"><span class="pre">Labeler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">client</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">document</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_index_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_adapter</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_events.html#Labeler"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.data.Labeler" title="Permalink to this definition">¶</a></dt>
<dd><p>Object provided by <code class="xref py py-func docutils literal notranslate"><span class="pre">get_labeler()</span></code> which is responsible for adding labels
to a label index on a document.</p>
<dl class="py method">
<dt class="sig sig-object py" id="mtap.data.Labeler.__call__">
<span class="sig-name descname"><span class="pre">__call__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_events.html#Labeler.__call__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.data.Labeler.__call__" title="Permalink to this definition">¶</a></dt>
<dd><p>Calls the constructor for the label type adding it to the list of labels to be uploaded.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>args</strong> – Arguments passed to the label type’s constructor.</p></li>
<li><p><strong>kwargs</strong> – Keyword arguments passed to the label type’s constructor.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>The object that was created by the label type’s constructor.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="#mtap.data.Label" title="mtap.data.Label">Label</a></p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">labeler</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">25</span><span class="p">,</span> <span class="n">some_field</span><span class="o">=</span><span class="s1">'some_value'</span><span class="p">,</span> <span class="n">x</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
<span class="go">GenericLabel(start_index=0, end_index=25, some_field='some_value', x=3)</span>
</pre></div>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="mtap.data.Labeler.done">
<span class="sig-name descname"><span class="pre">done</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_events.html#Labeler.done"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.data.Labeler.done" title="Permalink to this definition">¶</a></dt>
<dd><p>Finalizes the label index, uploads the added labels to the events service.</p>
<p>Normally called automatically on exit from a context manager block, but can be manually
invoked if the labeler is not used in a context manager block.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="mtap.data.LabelIndexInfo">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mtap.data.</span></span><span class="sig-name descname"><span class="pre">LabelIndexInfo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index_name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mtap.data.LabelIndexInfo" title="Permalink to this definition">¶</a></dt>
<dd><p>Information about a label index contained on a document.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="mtap.data.LabelIndexInfo.index_name">
<span class="sig-name descname"><span class="pre">index_name</span></span><a class="headerlink" href="#mtap.data.LabelIndexInfo.index_name" title="Permalink to this definition">¶</a></dt>
<dd><p>The name of the label index.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)">str</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="mtap.data.LabelIndexInfo.type">
<span class="sig-name descname"><span class="pre">type</span></span><a class="headerlink" href="#mtap.data.LabelIndexInfo.type" title="Permalink to this definition">¶</a></dt>
<dd><p>The type of the label index.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="#mtap.data.LabelIndexType" title="mtap.data.LabelIndexType">LabelIndexType</a></p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="mtap.data.LabelIndexType">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mtap.data.</span></span><span class="sig-name descname"><span class="pre">LabelIndexType</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">names</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">module</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qualname</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">start</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">boundary</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_base.html#LabelIndexType"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.data.LabelIndexType" title="Permalink to this definition">¶</a></dt>
<dd><p>The type of serialized labels contained in the label index.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="mtap.data.LabelIndexType.UNKNOWN">
<span class="sig-name descname"><span class="pre">UNKNOWN</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">0</span></em><a class="headerlink" href="#mtap.data.LabelIndexType.UNKNOWN" title="Permalink to this definition">¶</a></dt>
<dd><p>Label index not set or type not known.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="mtap.data.LabelIndexType.GENERIC">
<span class="sig-name descname"><span class="pre">GENERIC</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">1</span></em><a class="headerlink" href="#mtap.data.LabelIndexType.GENERIC" title="Permalink to this definition">¶</a></dt>
<dd><p>JSON / Generic Label index</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="mtap.data.LabelIndexType.CUSTOM">
<span class="sig-name descname"><span class="pre">CUSTOM</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">2</span></em><a class="headerlink" href="#mtap.data.LabelIndexType.CUSTOM" title="Permalink to this definition">¶</a></dt>
<dd><p>Other / custom protobuf label index</p>
</dd></dl>
</dd></dl>
</section>
<section id="labels">
<h3><a class="toc-backref" href="#id6" role="doc-backlink">Labels</a><a class="headerlink" href="#labels" title="Permalink to this heading">¶</a></h3>
<dl class="py class">
<dt class="sig sig-object py" id="mtap.data.Label">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mtap.data.</span></span><span class="sig-name descname"><span class="pre">Label</span></span><a class="reference internal" href="_modules/mtap/data/_labels.html#Label"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.data.Label" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract base class for a label of attributes on text.</p>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.data.Label.document">
<em class="property"><span class="pre">abstract</span><span class="w"> </span><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">document</span></span><a class="headerlink" href="#mtap.data.Label.document" title="Permalink to this definition">¶</a></dt>
<dd><p>The parent document this label appears on.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="#mtap.Document" title="mtap.Document">Document</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.data.Label.label_index_name">
<em class="property"><span class="pre">abstract</span><span class="w"> </span><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">label_index_name</span></span><a class="headerlink" href="#mtap.data.Label.label_index_name" title="Permalink to this definition">¶</a></dt>
<dd><p>The label index this label appears on.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)">str</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.data.Label.identifier">
<em class="property"><span class="pre">abstract</span><span class="w"> </span><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">identifier</span></span><a class="headerlink" href="#mtap.data.Label.identifier" title="Permalink to this definition">¶</a></dt>
<dd><p>The index of the label within its label index.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.11)">int</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.data.Label.start_index">
<em class="property"><span class="pre">abstract</span><span class="w"> </span><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">start_index</span></span><a class="headerlink" href="#mtap.data.Label.start_index" title="Permalink to this definition">¶</a></dt>
<dd><p>The index of the first character of the text covered by this label.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.11)">int</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.data.Label.end_index">
<em class="property"><span class="pre">abstract</span><span class="w"> </span><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">end_index</span></span><a class="headerlink" href="#mtap.data.Label.end_index" title="Permalink to this definition">¶</a></dt>
<dd><p>The index after the last character of the text covered by this label.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.11)">int</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.data.Label.location">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">location</span></span><a class="headerlink" href="#mtap.data.Label.location" title="Permalink to this definition">¶</a></dt>
<dd><p>A tuple of (start_index, end_index) used to perform sorting and
comparison first based on start_index, then based on end_index.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="#mtap.data.Location" title="mtap.data.Location">Location</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.data.Label.text">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">text</span></span><a class="headerlink" href="#mtap.data.Label.text" title="Permalink to this definition">¶</a></dt>
<dd><p>The slice of document text covered by this label. Will retrieve from events server
if it is not cached locally.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)">str</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="mtap.data.Label.shallow_fields_equal">
<em class="property"><span class="pre">abstract</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">shallow_fields_equal</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_labels.html#Label.shallow_fields_equal"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.data.Label.shallow_fields_equal" title="Permalink to this definition">¶</a></dt>
<dd><p>Tests if the fields on this label and locations of references are the same as another
label.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>other</strong> – The other label to test.</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>True if all of the fields are equal and the references are at the same locations.</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="mtap.data.Location">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mtap.data.</span></span><span class="sig-name descname"><span class="pre">Location</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">start_index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">end_index</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_labels.html#Location"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.data.Location" title="Permalink to this definition">¶</a></dt>
<dd><p>A location in text, a tuple of (<cite>start_index</cite>, <cite>end_index</cite>).</p>
<p>Used to perform comparison of labels based on their locations.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>start_index</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.11)"><em>float</em></a>) – The start index inclusive of the location in text.</p></li>
<li><p><strong>end_index</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.11)"><em>float</em></a>) – The end index exclusive of the location in text.</p></li>
</ul>
</dd>
</dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="mtap.data.Location.start_index">
<span class="sig-name descname"><span class="pre">start_index</span></span><a class="headerlink" href="#mtap.data.Location.start_index" title="Permalink to this definition">¶</a></dt>
<dd><p>The start index inclusive of the location in text.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.11)">float</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="mtap.data.Location.end_index">
<span class="sig-name descname"><span class="pre">end_index</span></span><a class="headerlink" href="#mtap.data.Location.end_index" title="Permalink to this definition">¶</a></dt>
<dd><p>The end index exclusive of the location in text.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.11)">float</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="mtap.data.Location.covers">
<span class="sig-name descname"><span class="pre">covers</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_labels.html#Location.covers"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.data.Location.covers" title="Permalink to this definition">¶</a></dt>
<dd><p>Whether the span of text covered by this label completely overlaps the span of text
covered by the <code class="docutils literal notranslate"><span class="pre">other</span></code> label or location.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>other</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Union" title="(in Python v3.11)"><em>Union</em></a><em>[</em><a class="reference internal" href="#mtap.data.Location" title="mtap.data.Location"><em>Location</em></a><em>, </em><a class="reference internal" href="#mtap.data.Label" title="mtap.data.Label"><em>Label</em></a><em>]</em>) – A location or label to compare against.</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">True</span></code> if <cite>other</cite> is completely overlapped/covered <code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.11)">bool</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="mtap.data.Location.relative_to">
<span class="sig-name descname"><span class="pre">relative_to</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">location</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_labels.html#Location.relative_to"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.data.Location.relative_to" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a location relative to the the same origin as <code class="docutils literal notranslate"><span class="pre">location</span></code> and makes it relative
to <code class="docutils literal notranslate"><span class="pre">location</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>location</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.11)"><em>int</em></a><em> or </em><a class="reference internal" href="#mtap.data.Location" title="mtap.data.Location"><em>Location</em></a><em> or </em><a class="reference internal" href="#mtap.data.Label" title="mtap.data.Label"><em>Label</em></a>) – A location to relativize this location to.</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A copy with updated indices.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="#mtap.data.Location" title="mtap.data.Location"><em>Location</em></a></p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">sentence</span> <span class="o">=</span> <span class="n">Location</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">20</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">token</span> <span class="o">=</span> <span class="n">Location</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">15</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">token</span><span class="o">.</span><span class="n">relative_to</span><span class="p">(</span><span class="n">sentence</span><span class="p">)</span>
<span class="go">Location(start_index=0, end_index=5)</span>
</pre></div>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="mtap.data.Location.offset_by">
<span class="sig-name descname"><span class="pre">offset_by</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">location</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_labels.html#Location.offset_by"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.data.Location.offset_by" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a location by offsetting this location by an integer or the <code class="docutils literal notranslate"><span class="pre">start_index</span></code> of a
location / label. Derelativizes this location.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>location</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.11)"><em>int</em></a><em> or </em><a class="reference internal" href="#mtap.data.Location" title="mtap.data.Location"><em>Location</em></a><em> or </em><a class="reference internal" href="#mtap.data.Label" title="mtap.data.Label"><em>Label</em></a>) – A location to offset this location by.</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A copy with updated indices.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="#mtap.data.Location" title="mtap.data.Location"><em>Location</em></a></p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">sentence</span> <span class="o">=</span> <span class="n">Location</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">20</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">token_in_sentence</span> <span class="o">=</span> <span class="n">Location</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">token_in_sentence</span><span class="o">.</span><span class="n">offset_by</span><span class="p">(</span><span class="n">sentence</span><span class="p">)</span>
<span class="go">Location(start_index=10, end_index=15)</span>
</pre></div>
</div>
</dd></dl>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="mtap.label">
<span class="sig-prename descclassname"><span class="pre">mtap.</span></span><span class="sig-name descname"><span class="pre">label</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">start_index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">end_index</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">document</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_labels.html#label"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.label" title="Permalink to this definition">¶</a></dt>
<dd><p>An alias for <a class="reference internal" href="#mtap.GenericLabel" title="mtap.GenericLabel"><code class="xref py py-class docutils literal notranslate"><span class="pre">GenericLabel</span></code></a>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>start_index</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.11)"><em>int</em></a>) – The index of the first character in text to be included in the label.</p></li>
<li><p><strong>end_index</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.11)"><em>int</em></a>) – The index after the last character in text to be included in the label.</p></li>
<li><p><strong>document</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.11)"><em>Optional</em></a><em>[</em><a class="reference internal" href="#mtap.Document" title="mtap.Document"><em>Document</em></a><em>]</em>) – The parent document of the label. This will be
automatically set if a the label is created via labeler.</p></li>
<li><p><strong>**kwargs</strong> – Arbitrary, any other fields that should be added to the label, values must be
json-serializable.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="mtap.GenericLabel">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mtap.</span></span><span class="sig-name descname"><span class="pre">GenericLabel</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">start_index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">end_index</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">identifier</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">document</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">label_index_name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fields</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reference_field_ids</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_labels.html#GenericLabel"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.GenericLabel" title="Permalink to this definition">¶</a></dt>
<dd><p>Default implementation of the Label class which uses a dictionary to store attributes.</p>
<p>Will be suitable for the majority of use cases for labels.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>start_index</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.11)"><em>int</em></a>) – The index of the first character in text to be included in the label.</p></li>
<li><p><strong>end_index</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.11)"><em>int</em></a>) – The index after the last character in text to be included in the label.</p></li>
</ul>
</dd>
<dt class="field-even">Keyword Arguments<span class="colon">:</span></dt>
<dd class="field-even"><ul class="simple">
<li><p><strong>document</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.11)"><em>Optional</em></a><em>[</em><a class="reference internal" href="#mtap.Document" title="mtap.Document"><em>Document</em></a><em>]</em>) – The parent document of the label. This will be
automatically set if a the label is created via labeler.</p></li>
<li><p><strong>**kwargs</strong> – Arbitrary, any other fields that should be added to the label, values must be
json-serializable.</p></li>
</ul>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">pos_tag</span> <span class="o">=</span> <span class="n">pos_tag_labeler</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">pos_tag</span><span class="o">.</span><span class="n">tag</span> <span class="o">=</span> <span class="s1">'NNS'</span>
<span class="gp">>>> </span><span class="n">pos_tag</span><span class="o">.</span><span class="n">tag</span>
<span class="go">'NNS'</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">pos_tag2</span> <span class="o">=</span> <span class="n">pos_tag_labeler</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">tag</span><span class="o">=</span><span class="s1">'VB'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">pos_tag2</span><span class="o">.</span><span class="n">tag</span>
<span class="go">'VB'</span>
</pre></div>
</div>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.GenericLabel.document">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">document</span></span><a class="headerlink" href="#mtap.GenericLabel.document" title="Permalink to this definition">¶</a></dt>
<dd><p>The parent document this label appears on.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="#mtap.Document" title="mtap.Document">Document</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.GenericLabel.label_index_name">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">label_index_name</span></span><a class="headerlink" href="#mtap.GenericLabel.label_index_name" title="Permalink to this definition">¶</a></dt>
<dd><p>The label index this label appears on.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.11)">str</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.GenericLabel.identifier">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">identifier</span></span><a class="headerlink" href="#mtap.GenericLabel.identifier" title="Permalink to this definition">¶</a></dt>
<dd><p>The index of the label within its label index.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.11)">int</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.GenericLabel.start_index">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">start_index</span></span><a class="headerlink" href="#mtap.GenericLabel.start_index" title="Permalink to this definition">¶</a></dt>
<dd><p>The index of the first character of the text covered by this label.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.11)">int</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.GenericLabel.end_index">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">end_index</span></span><a class="headerlink" href="#mtap.GenericLabel.end_index" title="Permalink to this definition">¶</a></dt>
<dd><p>The index after the last character of the text covered by this label.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.11)">int</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="mtap.GenericLabel.shallow_fields_equal">
<span class="sig-name descname"><span class="pre">shallow_fields_equal</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_labels.html#GenericLabel.shallow_fields_equal"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.GenericLabel.shallow_fields_equal" title="Permalink to this definition">¶</a></dt>
<dd><p>Tests if the fields on this label and locations of references are the same as another
label.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>other</strong> – The other label to test.</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>True if all of the fields are equal and the references are at the same locations.</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
</section>
<section id="label-indices">
<h3><a class="toc-backref" href="#id7" role="doc-backlink">Label Indices</a><a class="headerlink" href="#label-indices" title="Permalink to this heading">¶</a></h3>
<dl class="py function">
<dt class="sig sig-object py" id="mtap.label_index">
<span class="sig-prename descclassname"><span class="pre">mtap.</span></span><span class="sig-name descname"><span class="pre">label_index</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">labels</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">distinct</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">adapter</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_label_indices.html#label_index"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.label_index" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a label index from labels.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>labels</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.List" title="(in Python v3.11)"><em>List</em></a><em>[</em><em>L</em><em>]</em>) – Zero or more labels to create a label index from.</p></li>
<li><p><strong>distinct</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.11)"><em>bool</em></a>) – Whether the label index is distinct or not.</p></li>
<li><p><strong>adapter</strong> (<a class="reference internal" href="#mtap.data.ProtoLabelAdapter" title="mtap.data.ProtoLabelAdapter"><em>ProtoLabelAdapter</em></a>) – The label adapter for these labels.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>The newly created label index.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="#mtap.data.LabelIndex" title="mtap.data.LabelIndex"><em>LabelIndex</em></a></p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">mtap</span> <span class="kn">import</span> <span class="n">label_index</span><span class="p">,</span> <span class="n">label</span>
<span class="gp">>>> </span><span class="n">index</span> <span class="o">=</span> <span class="n">label_index</span><span class="p">([</span><span class="n">label</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="n">x</span><span class="o">=</span><span class="mi">1</span><span class="p">),</span>
<span class="gp">... </span> <span class="n">label</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">x</span><span class="o">=</span><span class="mi">2</span><span class="p">),</span>
<span class="gp">... </span> <span class="n">label</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">x</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span>
<span class="gp">... </span> <span class="n">label</span><span class="p">(</span><span class="mi">7</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">x</span><span class="o">=</span><span class="mi">4</span><span class="p">),</span>
<span class="gp">... </span> <span class="n">label</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="n">x</span><span class="o">=</span><span class="mi">5</span><span class="p">),</span>
<span class="gp">... </span> <span class="n">label</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="n">x</span><span class="o">=</span><span class="mi">6</span><span class="p">)])</span>
<span class="gp">>>> </span><span class="n">index</span>
<span class="go">label_index([GenericLabel(0, 5, x=1), GenericLabel(0, 10, x=2), GenericLabel(5, 10, x=3),</span>
<span class="go"> GenericLabel(5, 15, x=5), GenericLabel(7, 10, x=4), GenericLabel(10, 15, x=6)], distinct=False)</span>
</pre></div>
</div>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="mtap.data.LabelIndex">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">mtap.data.</span></span><span class="sig-name descname"><span class="pre">LabelIndex</span></span><a class="reference internal" href="_modules/mtap/data/_label_indices.html#LabelIndex"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.data.LabelIndex" title="Permalink to this definition">¶</a></dt>
<dd><p>An immutable <a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Sequence" title="(in Python v3.11)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Sequence</span></code></a> of labels ordered by their location in text. By default
sorts by ascending <cite>start_index</cite> and then by ascending <cite>end_index</cite>.</p>
<dl class="py property">
<dt class="sig sig-object py" id="mtap.data.LabelIndex.distinct">
<em class="property"><span class="pre">abstract</span><span class="w"> </span><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">distinct</span></span><a class="headerlink" href="#mtap.data.LabelIndex.distinct" title="Permalink to this definition">¶</a></dt>
<dd><p>Whether this label index is distinct, i.e. all of the labels in it are
non-overlapping.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.11)">bool</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="mtap.data.LabelIndex.filter">
<em class="property"><span class="pre">abstract</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">filter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fn</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_label_indices.html#LabelIndex.filter"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.data.LabelIndex.filter" title="Permalink to this definition">¶</a></dt>
<dd><p>Filters the label index according to a filter function.</p>
<p>This function is less efficient for filtering based on indices than
<a class="reference internal" href="#mtap.data.LabelIndex.inside" title="mtap.data.LabelIndex.inside"><code class="xref py py-func docutils literal notranslate"><span class="pre">inside()</span></code></a>, <a class="reference internal" href="#mtap.data.LabelIndex.covering" title="mtap.data.LabelIndex.covering"><code class="xref py py-func docutils literal notranslate"><span class="pre">covering()</span></code></a>, etc., which use a binary search
method on the sorted index.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>fn</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Callable" title="(in Python v3.11)"><em>Callable</em></a><em>[</em><em>[</em><a class="reference internal" href="#mtap.data.Label" title="mtap.data.Label"><em>Label</em></a><em>]</em><em>, </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.11)"><em>bool</em></a><em>]</em>) – A filter function, returns <code class="docutils literal notranslate"><span class="pre">true</span></code> if the label
should be included, <code class="docutils literal notranslate"><span class="pre">false</span></code> if it should not be included</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A view of this label index.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="#mtap.data.LabelIndex" title="mtap.data.LabelIndex">LabelIndex</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="mtap.data.LabelIndex.at">
<em class="property"><span class="pre">abstract</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">at</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">end</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_label_indices.html#LabelIndex.at"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.data.LabelIndex.at" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the labels at the specified location in text.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Union" title="(in Python v3.11)"><em>Union</em></a><em>[</em><a class="reference internal" href="#mtap.data.Label" title="mtap.data.Label"><em>Label</em></a><em>, </em><a class="reference internal" href="#mtap.data.Location" title="mtap.data.Location"><em>Location</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.11)"><em>float</em></a><em>]</em>) – A label or location, or start index if <cite>end</cite>
is specified.</p></li>
<li><p><strong>end</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.11)"><em>Optional</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.11)"><em>float</em></a><em>]</em>) – The exclusive end index of the location in text if it has
not been specified by a label.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A view of this label index.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="#mtap.data.LabelIndex" title="mtap.data.LabelIndex">LabelIndex</a></p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">mtap</span> <span class="kn">import</span> <span class="n">label_index</span><span class="p">,</span> <span class="n">label</span>
<span class="gp">>>> </span><span class="n">index</span> <span class="o">=</span> <span class="n">label_index</span><span class="p">([</span><span class="n">label</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">x</span><span class="o">=</span><span class="mi">1</span><span class="p">),</span>
<span class="gp">... </span> <span class="n">label</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">x</span><span class="o">=</span><span class="mi">2</span><span class="p">),</span>
<span class="gp">... </span> <span class="n">label</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="n">x</span><span class="o">=</span><span class="mi">3</span><span class="p">)])</span>
<span class="gp">>>> </span><span class="n">index</span><span class="o">.</span><span class="n">at</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
<span class="go">label_index([GenericLabel(0, 10, x=1), GenericLabel(0, 10, x=2)], distinct=False)</span>
</pre></div>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="mtap.data.LabelIndex.covering">
<em class="property"><span class="pre">abstract</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">covering</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">end</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mtap/data/_label_indices.html#LabelIndex.covering"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mtap.data.LabelIndex.covering" title="Permalink to this definition">¶</a></dt>
<dd><p>A label index containing all labels that cover / contain the specified location in text.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Union" title="(in Python v3.11)"><em>Union</em></a><em>[</em><em>Label'</em><em>, </em><em>Location'</em><em>, </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.11)"><em>float</em></a><em>]</em>) – A label or location, or start
index if <cite>end</cite> is specified.</p></li>
<li><p><strong>end</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.11)"><em>Optional</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.11)"><em>float</em></a><em>]</em>) – The exclusive end index of the location in text if it has
not been specified by a label.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A view of this label index.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="#mtap.data.LabelIndex" title="mtap.data.LabelIndex">LabelIndex</a></p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">mtap</span> <span class="kn">import</span> <span class="n">label_index</span><span class="p">,</span> <span class="n">label</span>
<span class="gp">>>> </span><span class="n">index</span> <span class="o">=</span> <span class="n">label_index</span><span class="p">([</span><span class="n">label</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="n">x</span><span class="o">=</span><span class="mi">1</span><span class="p">),</span>
<span class="gp">... </span> <span class="n">label</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">x</span><span class="o">=</span><span class="mi">2</span><span class="p">),</span>
<span class="gp">... </span> <span class="n">label</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">x</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span>
<span class="gp">... </span> <span class="n">label</span><span class="p">(</span><span class="mi">7</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">x</span><span class="o">=</span><span class="mi">4</span><span class="p">),</span>