marky_markov 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,588 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: MarkyMarkov::TemporaryDictionary
8
+
9
+ &mdash; Documentation by YARD 0.7.5
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ relpath = '..';
19
+ if (relpath != '') relpath += '/';
20
+ </script>
21
+
22
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
25
+
26
+
27
+ </head>
28
+ <body>
29
+ <script type="text/javascript" charset="utf-8">
30
+ if (window.top.frames.main) document.body.className = 'frames';
31
+ </script>
32
+
33
+ <div id="header">
34
+ <div id="menu">
35
+
36
+ <a href="../_index.html">Index (T)</a> &raquo;
37
+ <span class='title'><span class='object_link'><a href="../MarkyMarkov.html" title="MarkyMarkov (module)">MarkyMarkov</a></span></span>
38
+ &raquo;
39
+ <span class="title">TemporaryDictionary</span>
40
+
41
+
42
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
43
+ </div>
44
+
45
+ <div id="search">
46
+
47
+ <a id="class_list_link" href="#">Class List</a>
48
+
49
+ <a id="method_list_link" href="#">Method List</a>
50
+
51
+ <a id="file_list_link" href="#">File List</a>
52
+
53
+ </div>
54
+ <div class="clear"></div>
55
+ </div>
56
+
57
+ <iframe id="search_frame"></iframe>
58
+
59
+ <div id="content"><h1>Class: MarkyMarkov::TemporaryDictionary
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+ <dt class="r1">Inherits:</dt>
68
+ <dd class="r1">
69
+ <span class="inheritName">Object</span>
70
+
71
+ <ul class="fullTree">
72
+ <li>Object</li>
73
+
74
+ <li class="next">MarkyMarkov::TemporaryDictionary</li>
75
+
76
+ </ul>
77
+ <a href="#" class="inheritanceTree">show all</a>
78
+
79
+ </dd>
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+ <dt class="r2 last">Defined in:</dt>
90
+ <dd class="r2 last">lib/marky_markov.rb</dd>
91
+
92
+ </dl>
93
+ <div class="clear"></div>
94
+
95
+ <div id="subclasses">
96
+ <h2>Direct Known Subclasses</h2>
97
+ <p class="children"><span class='object_link'><a href="Dictionary.html" title="MarkyMarkov::Dictionary (class)">Dictionary</a></span></p>
98
+ </div>
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+ <h2>
108
+ Instance Method Summary
109
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
110
+ </h2>
111
+
112
+ <ul class="summary">
113
+
114
+ <li class="public ">
115
+ <span class="summary_signature">
116
+
117
+ <a href="#clear%21-instance_method" title="#clear! (instance method)">- (Object) <strong>clear!</strong> </a>
118
+
119
+
120
+
121
+ </span>
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+ <span class="summary_desc"><div class='inline'>
131
+ <p>Clears the temporary dictionary's hash, useful for keeping the same
132
+ dictionary object but removing the words it has learned.</p>
133
+ </div></span>
134
+
135
+ </li>
136
+
137
+
138
+ <li class="public ">
139
+ <span class="summary_signature">
140
+
141
+ <a href="#generate_n_words-instance_method" title="#generate_n_words (instance method)">- (String) <strong>generate_n_words</strong>(wordcount) </a>
142
+
143
+
144
+
145
+ </span>
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+ <span class="summary_desc"><div class='inline'>
155
+ <p>Generates a sentence/sentences of n words using the dictionary generated
156
+ via parse_string or parse_file.</p>
157
+ </div></span>
158
+
159
+ </li>
160
+
161
+
162
+ <li class="public ">
163
+ <span class="summary_signature">
164
+
165
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Object) <strong>initialize</strong> </a>
166
+
167
+
168
+
169
+ </span>
170
+
171
+ <span class="note title constructor">constructor</span>
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+ <span class="summary_desc"><div class='inline'>
181
+ <p>Create a new Temporary Markov Chain Dictionary and sentence generator for
182
+ use.</p>
183
+ </div></span>
184
+
185
+ </li>
186
+
187
+
188
+ <li class="public ">
189
+ <span class="summary_signature">
190
+
191
+ <a href="#parse_file-instance_method" title="#parse_file (instance method)">- (Object) <strong>parse_file</strong>(location) </a>
192
+
193
+
194
+
195
+ </span>
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+ <span class="summary_desc"><div class='inline'>
205
+ <p>Parses a given file and adds the sentences it contains to the current
206
+ dictionary.</p>
207
+ </div></span>
208
+
209
+ </li>
210
+
211
+
212
+ <li class="public ">
213
+ <span class="summary_signature">
214
+
215
+ <a href="#parse_string-instance_method" title="#parse_string (instance method)">- (Object) <strong>parse_string</strong>(string) </a>
216
+
217
+
218
+
219
+ </span>
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+ <span class="summary_desc"><div class='inline'>
229
+ <p>Parses a given string and adds them to the current dictionary.</p>
230
+ </div></span>
231
+
232
+ </li>
233
+
234
+
235
+ </ul>
236
+
237
+
238
+ <div id="constructor_details" class="method_details_list">
239
+ <h2>Constructor Details</h2>
240
+
241
+ <div class="method_details first">
242
+ <p class="signature first" id="initialize-instance_method">
243
+
244
+ - (<tt>Object</tt>) <strong>initialize</strong>
245
+
246
+
247
+
248
+ </p><div class="docstring">
249
+ <div class="discussion">
250
+
251
+ <p>Create a new Temporary Markov Chain Dictionary and sentence generator for
252
+ use.</p>
253
+
254
+
255
+ </div>
256
+ </div>
257
+ <div class="tags">
258
+
259
+ <div class="examples">
260
+ <h3>Examples:</h3>
261
+
262
+ <h4><div class='inline'>
263
+ <p>Create a new Temporary Dictionary.</p>
264
+ </div></h4>
265
+ <pre class="example code"><span class='id identifier rubyid_markov'>markov</span> <span class='op'>=</span> <span class='const'>MarkyMarkov</span><span class='op'>::</span><span class='const'>TemporaryDictionary</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span></pre>
266
+
267
+ </div>
268
+
269
+
270
+ </div><table class="source_code">
271
+ <tr>
272
+ <td>
273
+ <pre class="lines">
274
+
275
+
276
+ 16
277
+ 17
278
+ 18
279
+ 19</pre>
280
+ </td>
281
+ <td>
282
+ <pre class="code"><span class="info file"># File 'lib/marky_markov.rb', line 16</span>
283
+
284
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
285
+ <span class='ivar'>@dictionary</span> <span class='op'>=</span> <span class='const'>TwoWordDictionary</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
286
+ <span class='ivar'>@sentence</span> <span class='op'>=</span> <span class='const'>TwoWordSentenceGenerator</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='ivar'>@dictionary</span><span class='rparen'>)</span>
287
+ <span class='kw'>end</span></pre>
288
+ </td>
289
+ </tr>
290
+ </table>
291
+ </div>
292
+
293
+ </div>
294
+
295
+
296
+ <div id="instance_method_details" class="method_details_list">
297
+ <h2>Instance Method Details</h2>
298
+
299
+
300
+ <div class="method_details first">
301
+ <p class="signature first" id="clear!-instance_method">
302
+
303
+ - (<tt>Object</tt>) <strong>clear!</strong>
304
+
305
+
306
+
307
+ </p><div class="docstring">
308
+ <div class="discussion">
309
+
310
+ <p>Clears the temporary dictionary's hash, useful for keeping the same
311
+ dictionary object but removing the words it has learned.</p>
312
+
313
+
314
+ </div>
315
+ </div>
316
+ <div class="tags">
317
+
318
+ <div class="examples">
319
+ <h3>Examples:</h3>
320
+
321
+ <h4><div class='inline'>
322
+ <p>Clear the Dictionary hash.</p>
323
+ </div></h4>
324
+ <pre class="example code"><span class='id identifier rubyid_markov'>markov</span><span class='period'>.</span><span class='id identifier rubyid_clear!'>clear!</span></pre>
325
+
326
+ </div>
327
+
328
+
329
+ </div><table class="source_code">
330
+ <tr>
331
+ <td>
332
+ <pre class="lines">
333
+
334
+
335
+ 55
336
+ 56
337
+ 57</pre>
338
+ </td>
339
+ <td>
340
+ <pre class="code"><span class="info file"># File 'lib/marky_markov.rb', line 55</span>
341
+
342
+ <span class='kw'>def</span> <span class='id identifier rubyid_clear!'>clear!</span>
343
+ <span class='ivar'>@dictionary</span><span class='period'>.</span><span class='id identifier rubyid_dictionary'>dictionary</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span>
344
+ <span class='kw'>end</span></pre>
345
+ </td>
346
+ </tr>
347
+ </table>
348
+ </div>
349
+
350
+ <div class="method_details ">
351
+ <p class="signature " id="generate_n_words-instance_method">
352
+
353
+ - (<tt>String</tt>) <strong>generate_n_words</strong>(wordcount)
354
+
355
+
356
+
357
+ </p><div class="docstring">
358
+ <div class="discussion">
359
+
360
+ <p>Generates a sentence/sentences of n words using the dictionary generated
361
+ via parse_string or parse_file.</p>
362
+
363
+
364
+ </div>
365
+ </div>
366
+ <div class="tags">
367
+
368
+ <div class="examples">
369
+ <h3>Examples:</h3>
370
+
371
+ <h4><div class='inline'>
372
+ <p>Generate a 40 word long string of words.</p>
373
+ </div></h4>
374
+ <pre class="example code"><span class='id identifier rubyid_markov'>markov</span><span class='period'>.</span><span class='id identifier rubyid_generate_n_words'>generate_n_words</span><span class='lparen'>(</span><span class='int'>40</span><span class='rparen'>)</span></pre>
375
+
376
+ </div>
377
+ <h3>Parameters:</h3>
378
+ <ul class="param">
379
+
380
+ <li>
381
+
382
+ <span class='name'>wordcount</span>
383
+
384
+
385
+ <span class='type'>(<tt>Int</tt>)</span>
386
+
387
+
388
+
389
+ &mdash;
390
+ <div class='inline'>
391
+ <p>the number of words you want generated.</p>
392
+ </div>
393
+
394
+ </li>
395
+
396
+ </ul>
397
+
398
+ <h3>Returns:</h3>
399
+ <ul class="return">
400
+
401
+ <li>
402
+
403
+
404
+ <span class='type'>(<tt>String</tt>)</span>
405
+
406
+
407
+
408
+ &mdash;
409
+ <div class='inline'>
410
+ <p>the sentence generated by the dictionary.</p>
411
+ </div>
412
+
413
+ </li>
414
+
415
+ </ul>
416
+
417
+ </div><table class="source_code">
418
+ <tr>
419
+ <td>
420
+ <pre class="lines">
421
+
422
+
423
+ 46
424
+ 47
425
+ 48</pre>
426
+ </td>
427
+ <td>
428
+ <pre class="code"><span class="info file"># File 'lib/marky_markov.rb', line 46</span>
429
+
430
+ <span class='kw'>def</span> <span class='id identifier rubyid_generate_n_words'>generate_n_words</span><span class='lparen'>(</span><span class='id identifier rubyid_wordcount'>wordcount</span><span class='rparen'>)</span>
431
+ <span class='ivar'>@sentence</span><span class='period'>.</span><span class='id identifier rubyid_generate'>generate</span><span class='lparen'>(</span><span class='id identifier rubyid_wordcount'>wordcount</span><span class='rparen'>)</span>
432
+ <span class='kw'>end</span></pre>
433
+ </td>
434
+ </tr>
435
+ </table>
436
+ </div>
437
+
438
+ <div class="method_details ">
439
+ <p class="signature " id="parse_file-instance_method">
440
+
441
+ - (<tt>Object</tt>) <strong>parse_file</strong>(location)
442
+
443
+
444
+
445
+ </p><div class="docstring">
446
+ <div class="discussion">
447
+
448
+ <p>Parses a given file and adds the sentences it contains to the current
449
+ dictionary.</p>
450
+
451
+
452
+ </div>
453
+ </div>
454
+ <div class="tags">
455
+
456
+ <div class="examples">
457
+ <h3>Examples:</h3>
458
+
459
+ <h4><div class='inline'>
460
+ <p>Open a text file and add its contents to the dictionary.</p>
461
+ </div></h4>
462
+ <pre class="example code"><span class='id identifier rubyid_markov'>markov</span><span class='period'>.</span><span class='id identifier rubyid_parse_file'>parse_file</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>text.txt</span><span class='tstring_end'>&quot;</span></span></pre>
463
+
464
+ </div>
465
+ <h3>Parameters:</h3>
466
+ <ul class="param">
467
+
468
+ <li>
469
+
470
+ <span class='name'>location</span>
471
+
472
+
473
+ <span class='type'>(<tt>File</tt>)</span>
474
+
475
+
476
+
477
+ &mdash;
478
+ <div class='inline'>
479
+ <p>the file you want to add to the dictionary.</p>
480
+ </div>
481
+
482
+ </li>
483
+
484
+ </ul>
485
+
486
+
487
+ </div><table class="source_code">
488
+ <tr>
489
+ <td>
490
+ <pre class="lines">
491
+
492
+
493
+ 26
494
+ 27
495
+ 28</pre>
496
+ </td>
497
+ <td>
498
+ <pre class="code"><span class="info file"># File 'lib/marky_markov.rb', line 26</span>
499
+
500
+ <span class='kw'>def</span> <span class='id identifier rubyid_parse_file'>parse_file</span><span class='lparen'>(</span><span class='id identifier rubyid_location'>location</span><span class='rparen'>)</span>
501
+ <span class='ivar'>@dictionary</span><span class='period'>.</span><span class='id identifier rubyid_parse_source'>parse_source</span><span class='lparen'>(</span><span class='id identifier rubyid_location'>location</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span>
502
+ <span class='kw'>end</span></pre>
503
+ </td>
504
+ </tr>
505
+ </table>
506
+ </div>
507
+
508
+ <div class="method_details ">
509
+ <p class="signature " id="parse_string-instance_method">
510
+
511
+ - (<tt>Object</tt>) <strong>parse_string</strong>(string)
512
+
513
+
514
+
515
+ </p><div class="docstring">
516
+ <div class="discussion">
517
+
518
+ <p>Parses a given string and adds them to the current dictionary.</p>
519
+
520
+
521
+ </div>
522
+ </div>
523
+ <div class="tags">
524
+
525
+ <div class="examples">
526
+ <h3>Examples:</h3>
527
+
528
+ <h4><div class='inline'>
529
+ <p>Add a string to the dictionary.</p>
530
+ </div></h4>
531
+ <pre class="example code"><span class='id identifier rubyid_markov'>markov</span><span class='period'>.</span><span class='id identifier rubyid_parse_string'>parse_string</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>I could really go for some Chicken Makhani.</span><span class='tstring_end'>&quot;</span></span></pre>
532
+
533
+ </div>
534
+ <h3>Parameters:</h3>
535
+ <ul class="param">
536
+
537
+ <li>
538
+
539
+ <span class='name'>sentence</span>
540
+
541
+
542
+ <span class='type'>(<tt>String</tt>)</span>
543
+
544
+
545
+
546
+ &mdash;
547
+ <div class='inline'>
548
+ <p>the sentence you want to add to the dictionary.</p>
549
+ </div>
550
+
551
+ </li>
552
+
553
+ </ul>
554
+
555
+
556
+ </div><table class="source_code">
557
+ <tr>
558
+ <td>
559
+ <pre class="lines">
560
+
561
+
562
+ 35
563
+ 36
564
+ 37</pre>
565
+ </td>
566
+ <td>
567
+ <pre class="code"><span class="info file"># File 'lib/marky_markov.rb', line 35</span>
568
+
569
+ <span class='kw'>def</span> <span class='id identifier rubyid_parse_string'>parse_string</span><span class='lparen'>(</span><span class='id identifier rubyid_string'>string</span><span class='rparen'>)</span>
570
+ <span class='ivar'>@dictionary</span><span class='period'>.</span><span class='id identifier rubyid_parse_source'>parse_source</span><span class='lparen'>(</span><span class='id identifier rubyid_string'>string</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span>
571
+ <span class='kw'>end</span></pre>
572
+ </td>
573
+ </tr>
574
+ </table>
575
+ </div>
576
+
577
+ </div>
578
+
579
+ </div>
580
+
581
+ <div id="footer">
582
+ Generated on Mon Feb 6 22:18:54 2012 by
583
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
584
+ 0.7.5 (ruby-1.9.3).
585
+ </div>
586
+
587
+ </body>
588
+ </html>