-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusage.htm
757 lines (741 loc) · 37.9 KB
/
usage.htm
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>Usage — Pronouns2 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/classic.css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.htm',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/_sphinx_javascript_frameworks_compat.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="index" title="Index" href="genindex.htm" />
<link rel="search" title="Search" href="search.htm" />
<link rel="next" title="Make Targets" href="make.htm" />
<link rel="prev" title="Quick Start" href="quickstart.htm" />
</head>
<body role="document" onload="MM_preloadImages('_static/Images/arrow01c.gif">
<form method="get" action="search.htm" style="margin:0px">
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td rowspan="2" bgcolor="#539933"><img src="_static/Images/PlanetQuantumWhite50.png" width="50" height="50"/></td>
<td colspan="4" bgcolor="#CCEECC"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="25%" align="center" bgcolor="#99CC99"> <a href="Index.htm">Home</a> </td>
<td align="right" width="74%"><input name="q" type="text" title="Enter words to search for and click 'Search'"
style="width:250px"/></td>
<td align="center" width="1%"></td>
<td align="center" width="0%"><input type="submit" value="Search"/></td>
</tr>
</table></td>
<td rowspan="2" width="30" bgcolor="#539933"><a
href="index.htm"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('Up','','_static/Images/arrow01c.gif',1)"><img
src="_static/Images/arrow02c.gif" alt="Up" name="Up" width="30" height="40" border="0"/></a></td>
</tr>
<tr>
<td width="40" bgcolor="#539933"><a
href="quickstart.htm"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('Previous','','_static/Images/arrow01d.gif',1)"><img
src="_static/Images/arrow02d.gif"
alt="Previous"
name="Previous"
width="40"
height="30"
border="0"/></a></td>
<td width="100%" bgcolor="#539933"><font color="#FFFFFF">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="nav-item nav-item-0"><a href="index.htm">Pronouns2</a> ></li>
</ul>
</div></font></td>
<td width="40" bgcolor="#539933"><a
href="make.htm"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('Next','','_static/Images/arrow01e.gif',1)"><img
src="_static/Images/arrow02e.gif"
alt="Next"
name="Next"
width="40"
height="30"
border="0"/></a></td>
</tr>
</table>
</form>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="usage">
<span id="id1"></span><h1>Usage<a class="headerlink" href="#usage" title="Permalink to this heading">¶</a></h1>
<p>In most usage examples, run <code class="docutils literal notranslate"><span class="pre">python</span></code> in the <code class="docutils literal notranslate"><span class="pre">src</span></code>
subdirectory, so that <code class="docutils literal notranslate"><span class="pre">python</span></code> will find <code class="docutils literal notranslate"><span class="pre">pronouns2.py</span></code>,
which <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">pronouns2</span> <span class="pre">import</span> <span class="pre">*</span></code> needs. If you are already
in the <code class="docutils literal notranslate"><span class="pre">src</span></code> subdirectory, use <code class="docutils literal notranslate"><span class="pre">python</span></code> instead of
<code class="docutils literal notranslate"><span class="pre">cd</span> <span class="pre">src</span> <span class="pre">&&</span> <span class="pre">python</span></code>.</p>
<section id="run-minimum-demos">
<h2>Run Minimum Demos<a class="headerlink" href="#run-minimum-demos" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd src && python
>>> from pronouns2 import *
>>> demo("10.1")
(10.1) John wants to give June a present, but he isn't sure she’ll like it.
[['JohnD^PHID^heA', 'JuneB^sheA', 'presentB^itA']]
>>> demo()
(1.1) The boy who was fooling her kissed the girl who loved him.
[['girlB^herA', 'boyB^himA']]
...
(1.91) After John Adams woke up, he was hungry.
[['JohnB^heA']]
(1.92) That Oscar was unpopular didn't disturb him.
[['OscarB^himA']]
(1.93) For your brother to refuse to pay taxes would get him into trouble.
[['brotherD^PHIB^himA']]
(1.94) Anna's complaining about Peter infuriated him.
[['PeterB^himA']]
(1.95) The possibility that Fred will be unpopular doesn’t bother him.
[['FredB^himA']]
...
(10.1) John wants to give June a present, but he isn't sure she’ll like it.
[['JohnD^PHID^heA', 'JuneB^sheA', 'presentB^itA']]
...
>>>
</pre></div>
</div>
</section>
<section id="create-minimum-docs">
<h2>Create Minimum Docs<a class="headerlink" href="#create-minimum-docs" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd src && python
>>> from pronouns2 import *
>>> doc()
'.../docs/Demo.tex'
>>> doc(file_type=FileType.TXT)
'.../docs/Demo.txt'
>>> quit()
$ cd ../docs
$ make Demo.pdf
...
$ open Demo.pdf
...
$ open Demo.txt
</pre></div>
</div>
<p>(Windows users should use <code class="docutils literal notranslate"><span class="pre">start</span></code> instead of <code class="docutils literal notranslate"><span class="pre">open</span></code>.)</p>
</section>
<section id="run-info-demo">
<h2>Run Info Demo<a class="headerlink" href="#run-info-demo" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd src && python
>>> from pronouns2 import *
>>> demo("10.1", info=True)
################################################################
#
# (10.1) John wants to give June a present, but he isn't sure she’ll like it.
#
################################################################
_____________________________FEATURES____________________________
! ! ! ! ! ! ! ! ! ! !
! ! PNF ! FPF ! SPF ! TPF ! PLF ! GNF ! ANF ! RPF ! GEN !
! John ! - ! - ! - ! + ! - ! - ! + ! - ! - !
! PHI ! + ! ? ! ? ! ? ! ? ! ? ! ? ! - ! - !
! June ! - ! - ! - ! + ! - ! + ! + ! - ! - !
! present ! - ! - ! - ! + ! - ! ? ! - ! - ! - !
! he ! + ! - ! - ! + ! - ! - ! + ! - ! - !
! she ! + ! - ! - ! + ! - ! + ! + ! - ! - !
! it ! + ! - ! - ! + ! - ! ? ! - ! - ! - !
!_________!_____!_____!_____!_____!_____!_____!_____!_____!_____!
___________________________NODES___________________________
! ! !
! 1 ! (C, up:0, dn:2, lt:0, rt:0, th:2, nu:1) !
! 2 ! (S, up:1, dn:3, lt:0, rt:8, th:3, nu:2) !
! 3 ! (N, lit:John, ftr:[---+--+--], up:2, dn:0, !
! ! lt:0, rt:4, th:4, np:3, ch:0, co:3A, ec:3D, !
! ! pr:0, su:5, nu:3) !
! 3A ! (E, sub:A, ftr:[---+--+--], np:3, ch:0, co:3B) !
! 3B ! (E, sub:B, ftr:[---+--+--], np:3, ch:9A, co:3C) !
! 3C ! (E, sub:C, ftr:[---+--+--], np:3, ch:5A, co:3D) !
! 3D ! (E, sub:D, ftr:[---+--+--], np:3, ch:5D, co:0) !
! 4 ! (S, up:2, dn:5, lt:3, rt:0, th:5, nu:4) !
! 5 ! (N, lit:PHI, ftr:[+??????--], up:4, dn:0, !
! ! lt:0, rt:6, th:6, np:5, ch:0, co:5A, ec:5D, !
! ! pr:3, su:6, nu:5) !
! 5A ! (E, sub:A, ftr:[+??????--], np:5, ch:0, co:5B) !
! 5B ! (E, sub:B, ftr:[+--+-?---], np:5, ch:12A, co:5C) !
! 5C ! (E, sub:C, ftr:[+--+-++--], np:5, ch:11A, co:5D) !
! 5D ! (E, sub:D, ftr:[+--+--+--], np:5, ch:9A, co:0) !
! 6 ! (N, lit:June, ftr:[---+-++--], up:4, dn:0, !
! ! lt:5, rt:7, th:7, np:6, ch:0, co:6A, ec:6B, !
! ! pr:5, su:7, nu:6) !
! 6A ! (E, sub:A, ftr:[---+-++--], np:6, ch:0, co:6B) !
! 6B ! (E, sub:B, ftr:[---+-++--], np:6, ch:11A, co:0) !
! 7 ! (N, lit:present, ftr:[---+-?---], up:4, dn:0, !
! ! lt:6, rt:0, th:8, np:7, ch:0, co:7A, ec:7B, !
! ! pr:6, su:9, nu:7) !
! 7A ! (E, sub:A, ftr:[---+-?---], np:7, ch:0, co:7B) !
! 7B ! (E, sub:B, ftr:[---+-?---], np:7, ch:12A, co:0) !
! 8 ! (S, up:1, dn:9, lt:2, rt:0, th:9, nu:8) !
! 9 ! (N, lit:he, ftr:[+--+--+--], up:8, dn:0, !
! ! lt:0, rt:10, th:10, np:9, ch:0, co:9A, ec:9A, !
! ! pr:7, su:11, nu:9) !
! 9A ! (E, sub:A, ftr:[+--+--+--], np:9, ch:0, co:0) !
! 10 ! (S, up:8, dn:11, lt:9, rt:0, th:11, nu:10) !
! 11 ! (N, lit:she, ftr:[+--+-++--], up:10, dn:0, !
! ! lt:0, rt:12, th:12, np:11, ch:0, co:11A, ec:11A, !
! ! pr:9, su:12, nu:11) !
! 11A ! (E, sub:A, ftr:[+--+-++--], np:11, ch:0, co:0) !
! 12 ! (N, lit:it, ftr:[+--+-?---], up:10, dn:0, !
! ! lt:11, rt:0, th:0, np:12, ch:0, co:12A, ec:12A, !
! ! pr:11, su:0, nu:12) !
! 12A ! (E, sub:A, ftr:[+--+-?---], np:12, ch:0, co:0) !
!_____!___________________________________________________!
_________________________________CHAINING________________________________
! ! ! ! ! ! ! !
! John ! PHI ! June ! present ! he ! she ! it !
! JohnA ! PHIA ! JuneA ! presentA ! heA ! sheA ! itA !
! JohnB^heA ! PHIB^itA ! JuneB^sheA ! presentB^itA ! ! ! !
! JohnC^PHIA ! PHIC^sheA ! ! ! ! ! !
! JohnD^PHID ! PHID^heA ! ! ! ! ! !
!____________!___________!____________!______________!_____!______!_____!
________________INTERPRETATIONS_________________
! !
! JohnD^PHID^heA JuneB^sheA presentB^itA !
!______________________________________________!
>>>
</pre></div>
</div>
</section>
<section id="create-info-docs">
<h2>Create Info Docs<a class="headerlink" href="#create-info-docs" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd src && python
>>> from pronouns2 import *
>>> doc(info=True)
'.../docs/Demo.tex'
>>> doc(file_type=FileType.TXT, info=True)
'.../docs/Demo.txt'
>>> quit()
$ cd ../docs
$ make Demo.pdf
...
$ open Demo.pdf
...
$ open Demo.txt
</pre></div>
</div>
<p>This Demo.pdf should look like the originally checked in
Demo.pdf, except for the creation date.</p>
</section>
<section id="run-info-detail-demo">
<h2>Run Info+Detail Demo<a class="headerlink" href="#run-info-detail-demo" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd src && python
>>> from pronouns2 import *
>>> demo("10.1", info=True, debug=True)
...
</pre></div>
</div>
</section>
<section id="create-info-detail-docs">
<h2>Create Info+Detail Docs<a class="headerlink" href="#create-info-detail-docs" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd src && python
>>> from pronouns2 import *
>>> doc(info=True, debug=True)
'.../docs/Demo.tex'
>>> doc(file_type=FileType.TXT, info=True, debug=True)
'.../docs/Demo.txt'
>>> quit()
$ cd ../docs
$ make Demo.pdf
...
$ open Demo.pdf
...
$ open Demo.txt
</pre></div>
</div>
<p>Adds intermediate tables and diagrams to the preceding Info Docs.</p>
</section>
<section id="run-info-detail-trace-demo">
<h2>Run Info+Detail+Trace Demo<a class="headerlink" href="#run-info-detail-trace-demo" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd src && python
>>> from pronouns2 import *
>>> demo("10.1", info=True, debug=True, trace=True)
...
</pre></div>
</div>
</section>
<section id="create-info-detail-trace-docs">
<h2>Create Info+Detail+Trace Docs<a class="headerlink" href="#create-info-detail-trace-docs" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd src && python
>>> from pronouns2 import *
>>> doc(info=True, debug=True, trace=True)
'.../docs/Demo.tex'
>>> doc(file_type=FileType.TXT, info=True, debug=True, trace=True)
'.../docs/Demo.txt'
>>> quit()
$ cd ../docs
$ make Demo.pdf
...
$ open Demo.pdf
...
$ open Demo.txt
</pre></div>
</div>
<p>Adds intermediate tables and diagrams to the preceding Info Docs.</p>
</section>
<section id="create-docs-for-single-example">
<h2>Create Docs for Single Example<a class="headerlink" href="#create-docs-for-single-example" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd src && python
>>> from pronouns2 import *
>>> doc("10.1", info=True)
'.../docs/Demo.tex'
>>> doc("10.1", file_type=FileType.TXT, info=True)
'.../docs/Demo.txt'
>>> quit()
$ cd ../docs
$ make Demo.pdf
...
$ open Demo.pdf
...
$ open Demo.txt
</pre></div>
</div>
</section>
<section id="only-demo-chaining-tables">
<h2>Only Demo Chaining Tables<a class="headerlink" href="#only-demo-chaining-tables" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd src && python
>>> from pronouns2 import *
>>> chaining_tables = {'file_type': FileType.TXT,
'info': True,
'features_table': False,
'abstract_diagram': False,
'nodes_after_chaining': False,
'nodes_table': False,
'chaining_diagram': False,
'chaining_table': True,
'interpretations_table': False,
'summary_table': False,
'lexicon_table': False}
>>> demo("10.1", **chaining_tables)
>>> demo(**chaining_tables)
...
</pre></div>
</div>
</section>
<section id="only-doc-chaining-diagrams">
<h2>Only Doc Chaining Diagrams<a class="headerlink" href="#only-doc-chaining-diagrams" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd src && python
>>> from pronouns2 import *
>>> chaining_diagrams = {'file_type': FileType.TEX,
'info': True,
'features_table': False,
'abstract_diagram': False,
'nodes_after_chaining': False,
'nodes_table': False,
'chaining_diagram': True,
'chaining_table': False,
'interpretations_table': False,
'summary_table': False,
'lexicon_table': False}
>>> doc("10.1", file="../docs/Demo_10p1.tex", **chaining_diagrams
'.../docs/Demo_10p1.tex'
>>> doc(**chaining_diagrams)
'.../docs/Demo.tex'
>>> quit()
$ cd ../docs
$ make Demo_10p1.pdf
...
$ make Demo.pdf
...
$ open Demo_10p1.pdf
...
$ open Demo.pdf
</pre></div>
</div>
</section>
<section id="run-coverage-test">
<h2>Run Coverage Test<a class="headerlink" href="#run-coverage-test" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ make coverage
...
coverage run -m unittest discover -s tests -p "test_*.py"
...
----------------------------------------------------------------------
Ran 140 tests in 14.261s
OK
coverage html
Wrote HTML report to htmlcov/index.html
...
$ open src/htmlcov/index.html
</pre></div>
</div>
<p>Make command <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">coverage</span></code> is also available when connected
to either the repo’s root directory (<code class="docutils literal notranslate"><span class="pre">.</span></code>) or tests subdirectory
(<code class="docutils literal notranslate"><span class="pre">src/tests</span></code>). You will need to adjust <code class="docutils literal notranslate"><span class="pre">open</span> <span class="pre">src/htmlcov/index.html</span></code>
in those two cases.</p>
</section>
<section id="create-pdfs-in-test-output-directory">
<h2>Create PDFs in Test Output Directory<a class="headerlink" href="#create-pdfs-in-test-output-directory" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd src/tests && make coverage
...
$ make output-pdfs
...
$ cd output && ls -1 *.pdf
test_abstract_diagram.pdf
...
test_doc.pdf
...
test_varying_rho.pdf
$ open test_doc.pdf
$ open test_varying_rho.pdf
</pre></div>
</div>
</section>
<section id="rebuild-the-html-documentation">
<h2>Rebuild the HTML Documentation<a class="headerlink" href="#rebuild-the-html-documentation" title="Permalink to this heading">¶</a></h2>
<p>If you aren’t comfortable with Sphinx and RST, or you are
worried you might lose anything precious in your copy of the
repo, you can skip this section. However, I think it is
important to mention how I rebuild the HTML documentation to
the unafraid.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd src/docs && make all
</pre></div>
</div>
</section>
<section id="jupyter-notebook">
<h2>Jupyter Notebook<a class="headerlink" href="#jupyter-notebook" title="Permalink to this heading">¶</a></h2>
<p>Jupyter notebook <code class="docutils literal notranslate"><span class="pre">spread.ipynb</span></code> is a freebie which isn’t
essential to running the Pronouns2 Python code. However, it can
provide insight into how our Spreading Algorithm
(<a class="reference external" href="../../../../src/spread.py">spread.py</a>)
helps to draw Pronouns2’s pretty TikZ chaining diagrams.</p>
<ul>
<li><p>Connect to <code class="docutils literal notranslate"><span class="pre">src</span></code> directory in Terminal.app</p></li>
<li><p>Execute <code class="docutils literal notranslate"><span class="pre">jupyter</span> <span class="pre">notebook</span></code></p></li>
<li><p>In Jupyter notebook, running in your web browser, double-click
<code class="docutils literal notranslate"><span class="pre">spread.ipynb</span></code> in the <strong>Files</strong> tab.</p></li>
<li><p>Press <strong>Restart the kernel and run all the cells</strong> button</p>
<img alt="Restart the kernel and run all the cells button" class="align-center" src="_images/run_all_cells.png" />
<p>in opened <code class="docutils literal notranslate"><span class="pre">spread.ipynb</span></code> Jupyter notebook.</p>
</li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">spread.ipynb</span></code> Jupyter notebook imports <code class="docutils literal notranslate"><span class="pre">pronouns2</span></code>:</p>
<img alt="Jupyter notebook imports" class="align-center" src="_images/notebook_imports.png" />
<p>and runs Python code in all the Jupyter notebook cells,
creating many plots like:</p>
<img alt="Example plot generated by spread.ipynb Python code" class="align-center" src="_images/plot_0p50.png" />
<p>demonstrating the Spreading Algorithm. Our document
<a class="reference external" href="../../../../docs/VaryingRho.pdf">VaryingRho.pdf</a>
goes into greater
detail about how this algorithm is used to tune the placement
of arrowheads in Pronouns2’s TikZ chaining diagrams.</p>
</li>
</ul>
</section>
<section id="lexicon-py-exercises">
<h2>lexicon.py Exercises<a class="headerlink" href="#lexicon-py-exercises" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python
>>> from pronouns2 import *
>>> node = lexicon_lookup("Algernon")
>>> node
<globals.Node object at 0x1094f3a90>
>>> txt_nodes([node])
_________________________NODES_________________________
! ! !
! 1 ! (N, lit:Algernon, ftr:[---+--+--], up:0, dn:0, !
! ! lt:0, rt:0, th:0, np:1, ch:0, co:0, ec:0, !
! ! pr:0, su:0, nu:1) !
!____!________________________________________________!
>>> node.ftr_str
'---+--+--'
>>> lexicon_select(node.ftr_str)
['Algernon', 'Bernie', 'Bill', 'Bob', 'Ernie', 'Fred', 'Harry',
'Jack', 'John', 'Oscar', 'Peter', 'asshole', 'blame', 'boy',
'brother', 'camel', 'cat', 'dad', 'embezzler', 'father', 'fish',
'gambler', 'grandfather', 'man', 'mosquito', 'neighbor', 'pig',
'pilot', 'sheep', 'son', 'student', 'toy', 'uncle']
>>> lexicon_select(lexicon_lookup("supper").ftr_str)
['Las Vegas', 'Mig', 'blame', 'candy', 'complaining', 'flower',
'hat', 'home', 'house', 'interest', 'lawn', 'pen',
'possibility', 'present', 'problem', 'smokescreen', 'solution',
'supper', 'tax', 'toy', 'trouble']
>>> lexicon_select('mom')
['Anna', 'Janet', 'Jill', 'June', 'Linda', 'Mary', 'Penelope',
'Sandy', 'Sue', 'asshole', 'aunt', 'blame', 'camel', 'cat',
'daughter', 'embezzler', 'fish', 'gambler', 'girl',
'grandmother', 'mosquito', 'mom', 'mother', 'neighbor', 'pig',
'pilot', 'sheep', 'sister', 'student', 'toy']
>>>
</pre></div>
</div>
</section>
<section id="walkthrough">
<h2>(10.1) Walkthrough<a class="headerlink" href="#walkthrough" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python
>>> from pronouns2 import *
>>> ex = example("10.1")
>>> ex
["John wants to give June a present, but he isn't sure she’ll
like it.", ['C', ['S', 'John', ['S', 'PHI', 'June', 'present']],
['S', 'he', ['S', 'she', 'it']]]]
>>> sentence, csn = ex
>>> sentence
"John wants to give June a present, but he isn't sure she’ll like it."
>>> csn
['C', ['S', 'John', ['S', 'PHI', 'June', 'present']], ['S',
'he', ['S', 'she', 'it']]]
>>> Node.set_tree(parse(csn))
>>> nodes = tree_nodes(Node.tree())
>>> nodes
[<globals.Node object at 0x10f824250>, <globals.Node object at
0x10f93e940>, <globals.Node object at 0x10f93ea30>,
<globals.Node object at 0x10f93e910>, <globals.Node object at
0x10f93eac0>, <globals.Node object at 0x10f93efa0>,
<globals.Node object at 0x10f93ea60>, <globals.Node object at
0x10f93ed30>, <globals.Node object at 0x10f7a6a90>,
<globals.Node object at 0x10f7a6a60>, <globals.Node object at
0x110aaa6d0>, <globals.Node object at 0x110aaa100>]
>>> txt_nodes(nodes)
_________________________NODES_________________________
! ! !
! 1 ! (C, up:0, dn:2, lt:0, rt:0, th:2, nu:1) !
! 2 ! (S, up:1, dn:3, lt:0, rt:8, th:3, nu:2) !
! 3 ! (N, lit:John, ftr:[---+--+--], up:2, dn:0, !
! ! lt:0, rt:4, th:4, np:3, ch:0, co:0, ec:0, !
! ! pr:0, su:0, nu:3) !
! 4 ! (S, up:2, dn:5, lt:3, rt:0, th:5, nu:4) !
! 5 ! (N, lit:PHI, ftr:[+??????--], up:4, dn:0, !
! ! lt:0, rt:6, th:6, np:5, ch:0, co:0, ec:0, !
! ! pr:0, su:0, nu:5) !
! 6 ! (N, lit:June, ftr:[---+-++--], up:4, dn:0, !
! ! lt:5, rt:7, th:7, np:6, ch:0, co:0, ec:0, !
! ! pr:0, su:0, nu:6) !
! 7 ! (N, lit:present, ftr:[---+-?---], up:4, dn:0, !
! ! lt:6, rt:0, th:8, np:7, ch:0, co:0, ec:0, !
! ! pr:0, su:0, nu:7) !
! 8 ! (S, up:1, dn:9, lt:2, rt:0, th:9, nu:8) !
! 9 ! (N, lit:he, ftr:[+--+--+--], up:8, dn:0, !
! ! lt:0, rt:10, th:10, np:9, ch:0, co:0, ec:0, !
! ! pr:0, su:0, nu:9) !
! 10 ! (S, up:8, dn:11, lt:9, rt:0, th:11, nu:10) !
! 11 ! (N, lit:she, ftr:[+--+-++--], up:10, dn:0, !
! ! lt:0, rt:12, th:12, np:11, ch:0, co:0, ec:0, !
! ! pr:0, su:0, nu:11) !
! 12 ! (N, lit:it, ftr:[+--+-?---], up:10, dn:0, !
! ! lt:11, rt:0, th:0, np:12, ch:0, co:0, ec:0, !
! ! pr:0, su:0, nu:12) !
!_____!_______________________________________________!
>>> nnodes = tree_n_nodes(Node.tree())
>>> txt_nodes(nnodes)
_________________________NODES_________________________
! ! !
! 3 ! (N, lit:John, ftr:[---+--+--], up:2, dn:0, !
! ! lt:0, rt:4, th:4, np:3, ch:0, co:0, ec:0, !
! ! pr:0, su:0, nu:3) !
! 5 ! (N, lit:PHI, ftr:[+??????--], up:4, dn:0, !
! ! lt:0, rt:6, th:6, np:5, ch:0, co:0, ec:0, !
! ! pr:0, su:0, nu:5) !
! 6 ! (N, lit:June, ftr:[---+-++--], up:4, dn:0, !
! ! lt:5, rt:7, th:7, np:6, ch:0, co:0, ec:0, !
! ! pr:0, su:0, nu:6) !
! 7 ! (N, lit:present, ftr:[---+-?---], up:4, dn:0, !
! ! lt:6, rt:0, th:8, np:7, ch:0, co:0, ec:0, !
! ! pr:0, su:0, nu:7) !
! 9 ! (N, lit:he, ftr:[+--+--+--], up:8, dn:0, !
! ! lt:0, rt:10, th:10, np:9, ch:0, co:0, ec:0, !
! ! pr:0, su:0, nu:9) !
! 11 ! (N, lit:she, ftr:[+--+-++--], up:10, dn:0, !
! ! lt:0, rt:12, th:12, np:11, ch:0, co:0, ec:0, !
! ! pr:0, su:0, nu:11) !
! 12 ! (N, lit:it, ftr:[+--+-?---], up:10, dn:0, !
! ! lt:11, rt:0, th:0, np:12, ch:0, co:0, ec:0, !
! ! pr:0, su:0, nu:12) !
!_____!_______________________________________________!
>>> txt_features(nnodes)
_____________________________FEATURES____________________________
! ! ! ! ! ! ! ! ! ! !
! ! PNF ! FPF ! SPF ! TPF ! PLF ! GNF ! ANF ! RPF ! GEN !
! John ! - ! - ! - ! + ! - ! - ! + ! - ! - !
! PHI ! + ! ? ! ? ! ? ! ? ! ? ! ? ! - ! - !
! June ! - ! - ! - ! + ! - ! + ! + ! - ! - !
! present ! - ! - ! - ! + ! - ! ? ! - ! - ! - !
! he ! + ! - ! - ! + ! - ! - ! + ! - ! - !
! she ! + ! - ! - ! + ! - ! + ! + ! - ! - !
! it ! + ! - ! - ! + ! - ! ? ! - ! - ! - !
!_________!_____!_____!_____!_____!_____!_____!_____!_____!_____!
>>> chaining(nnodes)
>>> nodes = tree_nodes(Node.tree())
>>> txt_nodes(nodes)
___________________________NODES___________________________
! ! !
! 1 ! (C, up:0, dn:2, lt:0, rt:0, th:2, nu:1) !
! 2 ! (S, up:1, dn:3, lt:0, rt:8, th:3, nu:2) !
! 3 ! (N, lit:John, ftr:[---+--+--], up:2, dn:0, !
! ! lt:0, rt:4, th:4, np:3, ch:0, co:3A, ec:3D, !
! ! pr:0, su:5, nu:3) !
! 3A ! (E, sub:A, ftr:[---+--+--], np:3, ch:0, co:3B) !
! 3B ! (E, sub:B, ftr:[---+--+--], np:3, ch:9A, co:3C) !
! 3C ! (E, sub:C, ftr:[---+--+--], np:3, ch:5A, co:3D) !
! 3D ! (E, sub:D, ftr:[---+--+--], np:3, ch:5D, co:0) !
! 4 ! (S, up:2, dn:5, lt:3, rt:0, th:5, nu:4) !
! 5 ! (N, lit:PHI, ftr:[+??????--], up:4, dn:0, !
! ! lt:0, rt:6, th:6, np:5, ch:0, co:5A, ec:5D, !
! ! pr:3, su:6, nu:5) !
! 5A ! (E, sub:A, ftr:[+??????--], np:5, ch:0, co:5B) !
! 5B ! (E, sub:B, ftr:[+--+-?---], np:5, ch:12A, co:5C) !
! 5C ! (E, sub:C, ftr:[+--+-++--], np:5, ch:11A, co:5D) !
! 5D ! (E, sub:D, ftr:[+--+--+--], np:5, ch:9A, co:0) !
! 6 ! (N, lit:June, ftr:[---+-++--], up:4, dn:0, !
! ! lt:5, rt:7, th:7, np:6, ch:0, co:6A, ec:6B, !
! ! pr:5, su:7, nu:6) !
! 6A ! (E, sub:A, ftr:[---+-++--], np:6, ch:0, co:6B) !
! 6B ! (E, sub:B, ftr:[---+-++--], np:6, ch:11A, co:0) !
! 7 ! (N, lit:present, ftr:[---+-?---], up:4, dn:0, !
! ! lt:6, rt:0, th:8, np:7, ch:0, co:7A, ec:7B, !
! ! pr:6, su:9, nu:7) !
! 7A ! (E, sub:A, ftr:[---+-?---], np:7, ch:0, co:7B) !
! 7B ! (E, sub:B, ftr:[---+-?---], np:7, ch:12A, co:0) !
! 8 ! (S, up:1, dn:9, lt:2, rt:0, th:9, nu:8) !
! 9 ! (N, lit:he, ftr:[+--+--+--], up:8, dn:0, !
! ! lt:0, rt:10, th:10, np:9, ch:0, co:9A, ec:9A, !
! ! pr:7, su:11, nu:9) !
! 9A ! (E, sub:A, ftr:[+--+--+--], np:9, ch:0, co:0) !
! 10 ! (S, up:8, dn:11, lt:9, rt:0, th:11, nu:10) !
! 11 ! (N, lit:she, ftr:[+--+-++--], up:10, dn:0, !
! ! lt:0, rt:12, th:12, np:11, ch:0, co:11A, ec:11A, !
! ! pr:9, su:12, nu:11) !
! 11A ! (E, sub:A, ftr:[+--+-++--], np:11, ch:0, co:0) !
! 12 ! (N, lit:it, ftr:[+--+-?---], up:10, dn:0, !
! ! lt:11, rt:0, th:0, np:12, ch:0, co:12A, ec:12A, !
! ! pr:11, su:0, nu:12) !
! 12A ! (E, sub:A, ftr:[+--+-?---], np:12, ch:0, co:0) !
!_____!___________________________________________________!
>>> txt_chaining(nnodes)
_________________________________CHAINING________________________________
! ! ! ! ! ! ! !
! John ! PHI ! June ! present ! he ! she ! it !
! JohnA ! PHIA ! JuneA ! presentA ! heA ! sheA ! itA !
! JohnB^heA ! PHIB^itA ! JuneB^sheA ! presentB^itA ! ! ! !
! JohnC^PHIA ! PHIC^sheA ! ! ! ! ! !
! JohnD^PHID ! PHID^heA ! ! ! ! ! !
!____________!___________!____________!______________!_____!______!_____!
>>> interps = interpret(nnodes)
>>> interps
[[[<globals.Node object at 0x110aaa9d0>, <globals.Node object at
0x110aaa9a0>, <globals.Node object at 0x110aaa970>],
[<globals.Node object at 0x110aaa910>, <globals.Node object at
0x110aaa850>], [<globals.Node object at 0x110aaa880>,
<globals.Node object at 0x110aaa7f0>]]]
>>> view_interps(interps)
[['JohnD^PHID^heA', 'JuneB^sheA', 'presentB^itA']]
>>> view_interpretations(interps)
[['JohnD^PHID^heA JuneB^sheA presentB^itA']]
>>> txt_interpretations(interps)
________________INTERPRETATIONS_________________
! !
! JohnD^PHID^heA JuneB^sheA presentB^itA !
!______________________________________________!
>>>
</pre></div>
</div>
</section>
<section id="locate-and-view-pdf-documentation">
<h2>Locate and View PDF Documentation<a class="headerlink" href="#locate-and-view-pdf-documentation" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd docs
$ ls -1 *.pdf
Demo.pdf
Demo_10p1.pdf
Pronouns2Modula2.pdf
Pronouns2Python.pdf
RelatedLiterature.pdf
VaryingRho.pdf
$ open Pronouns2Python.pdf
$
</pre></div>
</div>
</section>
<section id="locate-and-view-html-documentation">
<h2>Locate and View HTML Documentation<a class="headerlink" href="#locate-and-view-html-documentation" title="Permalink to this heading">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ open src/docs/build/html/index.htm
$ # OR
$ cd src/docs/build/html
$ ls -1 *.htm
abstract.htm
chaining.htm
demo.htm
...
usage.htm
varying_rho.htm
view.htm
$ open index.htm
</pre></div>
</div>
<p>You might want to create an alias on your desktop or add the
opened URL to your web browser’s favorites if you intend to
visit the HTML documentation often. I can help you get started
with that. Click the following link: <a class="reference internal" href="index.htm#pronouns2"><span class="std std-ref">Pronouns2</span></a>.</p>
</section>
</section>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.htm">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Usage</a><ul>
<li><a class="reference internal" href="#run-minimum-demos">Run Minimum Demos</a></li>
<li><a class="reference internal" href="#create-minimum-docs">Create Minimum Docs</a></li>
<li><a class="reference internal" href="#run-info-demo">Run Info Demo</a></li>
<li><a class="reference internal" href="#create-info-docs">Create Info Docs</a></li>
<li><a class="reference internal" href="#run-info-detail-demo">Run Info+Detail Demo</a></li>
<li><a class="reference internal" href="#create-info-detail-docs">Create Info+Detail Docs</a></li>
<li><a class="reference internal" href="#run-info-detail-trace-demo">Run Info+Detail+Trace Demo</a></li>
<li><a class="reference internal" href="#create-info-detail-trace-docs">Create Info+Detail+Trace Docs</a></li>
<li><a class="reference internal" href="#create-docs-for-single-example">Create Docs for Single Example</a></li>
<li><a class="reference internal" href="#only-demo-chaining-tables">Only Demo Chaining Tables</a></li>
<li><a class="reference internal" href="#only-doc-chaining-diagrams">Only Doc Chaining Diagrams</a></li>
<li><a class="reference internal" href="#run-coverage-test">Run Coverage Test</a></li>
<li><a class="reference internal" href="#create-pdfs-in-test-output-directory">Create PDFs in Test Output Directory</a></li>
<li><a class="reference internal" href="#rebuild-the-html-documentation">Rebuild the HTML Documentation</a></li>
<li><a class="reference internal" href="#jupyter-notebook">Jupyter Notebook</a></li>
<li><a class="reference internal" href="#lexicon-py-exercises">lexicon.py Exercises</a></li>
<li><a class="reference internal" href="#walkthrough">(10.1) Walkthrough</a></li>
<li><a class="reference internal" href="#locate-and-view-pdf-documentation">Locate and View PDF Documentation</a></li>
<li><a class="reference internal" href="#locate-and-view-html-documentation">Locate and View HTML Documentation</a></li>
</ul>
</li>
</ul>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="quickstart.htm"
title="previous chapter">Quick Start</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="make.htm"
title="next chapter">Make Targets</a></p>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#CCEECC">
<tr>
<td width="50%">©2024 Kelly Roach</td>
<td width="40%" align="right"><a id="email" href="mailto:[email protected]">Kelly Roach</a></td>
</tr>
</table>
</body>
</html>