text_parser 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +21 -7
- data/doc/String.html +143 -0
- data/doc/TextParser/Version.html +127 -0
- data/doc/TextParser.html +258 -0
- data/doc/_index.html +134 -0
- data/doc/class_list.html +47 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +55 -0
- data/doc/css/style.css +322 -0
- data/doc/file.README.html +99 -0
- data/doc/file_list.html +49 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +99 -0
- data/doc/js/app.js +205 -0
- data/doc/js/full_list.js +167 -0
- data/doc/js/jquery.js +16 -0
- data/doc/method_list.html +54 -0
- data/doc/top-level-namespace.html +105 -0
- data/lib/text_parser/version.rb +1 -1
- data/lib/text_parser.rb +6 -0
- data/test/text_parser_test.rb +14 -4
- data/text_parser.gemspec +4 -2
- metadata +23 -6
data/README.rdoc
CHANGED
@@ -1,19 +1,33 @@
|
|
1
|
-
=Arguments
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
=Arguments (Hash)
|
2
|
+
+---------------------------------+--------+---------------+
|
3
|
+
| Key | Type | Default value |
|
4
|
+
+---------------------------------+--------+---------------+
|
5
|
+
| :dictionary | Array | nil |
|
6
|
+
| :order (:word | :hits) | Symbol | :word |
|
7
|
+
| :order_direction (:asc | :desc) | Symbol | :asc |
|
8
|
+
| :negative_dictionary | Array | [] |
|
9
|
+
+---------------------------------+--------+---------------+
|
10
|
+
|
6
11
|
|
7
12
|
=Usage
|
8
13
|
|
9
14
|
"Simple, simple test".parse
|
10
15
|
# => [{:word => "simple", :hits => 2}, {:word => "test", :hits => 1}]
|
11
|
-
|
16
|
+
|
17
|
+
------------------------------------------------------------------------------------------------------------
|
18
|
+
|
12
19
|
my_text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque pretium consectetur."
|
13
20
|
my_text.parse(:dictionary => ["dolor", "consectetur"])
|
14
21
|
# => [{:word => "consectetur", :hits => 2}, {:word => "dolor", :hits => 1}]
|
15
|
-
|
22
|
+
|
23
|
+
------------------------------------------------------------------------------------------------------------
|
24
|
+
|
16
25
|
my_text.parse(:dictionary => ["dolor", "consectetur"], :order => :word, :order_direction => :desc)
|
17
26
|
# => [{:word => "dolor", :hits => 1}, {:word => "consectetur", :hits => 2}]
|
27
|
+
|
28
|
+
------------------------------------------------------------------------------------------------------------
|
29
|
+
|
30
|
+
"Lorem ipsum dolor sit amet".parse(:negative_dictionary => ["ipsum", "dolor", "sit"])
|
31
|
+
# => [{:word => "loren", :hits => 1}, {:word => "amet", :hits => 1}]
|
18
32
|
|
19
33
|
|
data/doc/String.html
ADDED
@@ -0,0 +1,143 @@
|
|
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: String
|
8
|
+
|
9
|
+
— Documentation by YARD 0.7.4
|
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 (S)</a> »
|
37
|
+
|
38
|
+
|
39
|
+
<span class="title">String</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: String
|
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">String</li>
|
75
|
+
|
76
|
+
</ul>
|
77
|
+
<a href="#" class="inheritanceTree">show all</a>
|
78
|
+
|
79
|
+
</dd>
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
<dt class="r2">Includes:</dt>
|
87
|
+
<dd class="r2"><span class='object_link'><a href="TextParser.html" title="TextParser (module)">TextParser</a></span></dd>
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
<dt class="r1 last">Defined in:</dt>
|
94
|
+
<dd class="r1 last">lib/text_parser.rb</dd>
|
95
|
+
|
96
|
+
</dl>
|
97
|
+
<div class="clear"></div>
|
98
|
+
|
99
|
+
<h2>Overview</h2><div class="docstring">
|
100
|
+
<div class="discussion">
|
101
|
+
|
102
|
+
<p>Includes module TextParser in the String object</p>
|
103
|
+
|
104
|
+
|
105
|
+
</div>
|
106
|
+
</div>
|
107
|
+
<div class="tags">
|
108
|
+
|
109
|
+
|
110
|
+
</div>
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
<h2>Method Summary</h2>
|
129
|
+
|
130
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="TextParser.html" title="TextParser (module)">TextParser</a></span></h3>
|
131
|
+
<p class="inherited"><span class='object_link'><a href="TextParser.html#parse-instance_method" title="TextParser#parse (method)">#parse</a></span></p>
|
132
|
+
|
133
|
+
|
134
|
+
</div>
|
135
|
+
|
136
|
+
<div id="footer">
|
137
|
+
Generated on Tue Dec 6 10:19:06 2011 by
|
138
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
139
|
+
0.7.4 (ruby-1.8.7).
|
140
|
+
</div>
|
141
|
+
|
142
|
+
</body>
|
143
|
+
</html>
|
@@ -0,0 +1,127 @@
|
|
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
|
+
Module: TextParser::Version
|
8
|
+
|
9
|
+
— Documentation by YARD 0.7.4
|
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 (V)</a> »
|
37
|
+
<span class='title'><span class='object_link'><a href="../TextParser.html" title="TextParser (module)">TextParser</a></span></span>
|
38
|
+
»
|
39
|
+
<span class="title">Version</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>Module: TextParser::Version
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
</h1>
|
64
|
+
|
65
|
+
<dl class="box">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
<dt class="r1 last">Defined in:</dt>
|
75
|
+
<dd class="r1 last">lib/text_parser/version.rb</dd>
|
76
|
+
|
77
|
+
</dl>
|
78
|
+
<div class="clear"></div>
|
79
|
+
|
80
|
+
|
81
|
+
<h2>Constant Summary</h2>
|
82
|
+
|
83
|
+
<dl class="constants">
|
84
|
+
|
85
|
+
<dt id="MAJOR-constant" class="">MAJOR =
|
86
|
+
|
87
|
+
</dt>
|
88
|
+
<dd><pre class="code"><span class='integer val'>0</span>
|
89
|
+
</pre></dd>
|
90
|
+
|
91
|
+
<dt id="MINOR-constant" class="">MINOR =
|
92
|
+
|
93
|
+
</dt>
|
94
|
+
<dd><pre class="code"><span class='integer val'>1</span>
|
95
|
+
</pre></dd>
|
96
|
+
|
97
|
+
<dt id="PATCH-constant" class="">PATCH =
|
98
|
+
|
99
|
+
</dt>
|
100
|
+
<dd><pre class="code"><span class='integer val'>1</span>
|
101
|
+
</pre></dd>
|
102
|
+
|
103
|
+
<dt id="STRING-constant" class="">STRING =
|
104
|
+
|
105
|
+
</dt>
|
106
|
+
<dd><pre class="code"><span class='dstring node'>"#{MAJOR}.#{MINOR}.#{PATCH}"</span>
|
107
|
+
</pre></dd>
|
108
|
+
|
109
|
+
</dl>
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
</div>
|
119
|
+
|
120
|
+
<div id="footer">
|
121
|
+
Generated on Tue Dec 6 10:19:06 2011 by
|
122
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
123
|
+
0.7.4 (ruby-1.8.7).
|
124
|
+
</div>
|
125
|
+
|
126
|
+
</body>
|
127
|
+
</html>
|
data/doc/TextParser.html
ADDED
@@ -0,0 +1,258 @@
|
|
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
|
+
Module: TextParser
|
8
|
+
|
9
|
+
— Documentation by YARD 0.7.4
|
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> »
|
37
|
+
|
38
|
+
|
39
|
+
<span class="title">TextParser</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>Module: TextParser
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
</h1>
|
64
|
+
|
65
|
+
<dl class="box">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
<dt class="r1">Included in:</dt>
|
74
|
+
<dd class="r1"><span class='object_link'><a href="String.html" title="String (class)">String</a></span></dd>
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
<dt class="r2 last">Defined in:</dt>
|
79
|
+
<dd class="r2 last">lib/text_parser.rb<span class="defines">,<br />
|
80
|
+
lib/text_parser/version.rb</span>
|
81
|
+
</dd>
|
82
|
+
|
83
|
+
</dl>
|
84
|
+
<div class="clear"></div>
|
85
|
+
|
86
|
+
<h2>Defined Under Namespace</h2>
|
87
|
+
<p class="children">
|
88
|
+
|
89
|
+
|
90
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="TextParser/Version.html" title="TextParser::Version (module)">Version</a></span>
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
</p>
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
<h2>
|
103
|
+
Instance Method Summary
|
104
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
105
|
+
</h2>
|
106
|
+
|
107
|
+
<ul class="summary">
|
108
|
+
|
109
|
+
<li class="public ">
|
110
|
+
<span class="summary_signature">
|
111
|
+
|
112
|
+
<a href="#parse-instance_method" title="#parse (instance method)">- (Array of Hash) <strong>parse</strong>(args = {}) </a>
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
</span>
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
<span class="summary_desc"><div class='inline'>
|
126
|
+
<p>Returns a parsed text with the words and its occurrences.</p>
|
127
|
+
</div></span>
|
128
|
+
|
129
|
+
</li>
|
130
|
+
|
131
|
+
|
132
|
+
</ul>
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
<div id="instance_method_details" class="method_details_list">
|
138
|
+
<h2>Instance Method Details</h2>
|
139
|
+
|
140
|
+
|
141
|
+
<div class="method_details first">
|
142
|
+
<p class="signature first" id="parse-instance_method">
|
143
|
+
|
144
|
+
- (<tt>Array of Hash</tt>) <strong>parse</strong>(args = {})
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
</p><div class="docstring">
|
149
|
+
<div class="discussion">
|
150
|
+
|
151
|
+
<p>Returns a parsed text with the words and its occurrences.</p>
|
152
|
+
<dl class="rdoc-list label-list"><dt>args
|
153
|
+
<dd><dl class="rdoc-list label-list"><dt>Symbol
|
154
|
+
<dd>
|
155
|
+
<p>:dictionary, :order, :order_direction, :negative_dictionary</p>
|
156
|
+
</dd></dl>
|
157
|
+
</dd></dl>
|
158
|
+
|
159
|
+
|
160
|
+
</div>
|
161
|
+
</div>
|
162
|
+
<div class="tags">
|
163
|
+
<h3>Parameters:</h3>
|
164
|
+
<ul class="param">
|
165
|
+
|
166
|
+
<li>
|
167
|
+
|
168
|
+
<span class='name'>[args]</span>
|
169
|
+
|
170
|
+
|
171
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
</li>
|
176
|
+
|
177
|
+
</ul>
|
178
|
+
|
179
|
+
<h3>Returns:</h3>
|
180
|
+
<ul class="return">
|
181
|
+
|
182
|
+
<li>
|
183
|
+
|
184
|
+
|
185
|
+
<span class='type'>(<tt>Array of Hash</tt>)</span>
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
</li>
|
190
|
+
|
191
|
+
</ul>
|
192
|
+
|
193
|
+
</div><table class="source_code">
|
194
|
+
<tr>
|
195
|
+
<td>
|
196
|
+
<pre class="lines">
|
197
|
+
|
198
|
+
|
199
|
+
7
|
200
|
+
8
|
201
|
+
9
|
202
|
+
10
|
203
|
+
11
|
204
|
+
12
|
205
|
+
13
|
206
|
+
14
|
207
|
+
15
|
208
|
+
16
|
209
|
+
17
|
210
|
+
18
|
211
|
+
19
|
212
|
+
20
|
213
|
+
21
|
214
|
+
22
|
215
|
+
23
|
216
|
+
24
|
217
|
+
25</pre>
|
218
|
+
</td>
|
219
|
+
<td>
|
220
|
+
<pre class="code"><span class="info file"># File 'lib/text_parser.rb', line 7</span>
|
221
|
+
|
222
|
+
<span class='rubyid_def def kw'>def</span> <span class='rubyid_parse identifier id'>parse</span><span class='lparen token'>(</span><span class='rubyid_args identifier id'>args</span> <span class='assign token'>=</span> <span class='lbrace token'>{</span><span class='rbrace token'>}</span><span class='rparen token'>)</span>
|
223
|
+
<span class='rubyid_options identifier id'>options</span> <span class='assign token'>=</span> <span class='lbrace token'>{</span>
|
224
|
+
<span class='symbol val'>:dictionary</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span>
|
225
|
+
<span class='symbol val'>:order</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='symbol val'>:word</span><span class='comma token'>,</span>
|
226
|
+
<span class='symbol val'>:order_direction</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='symbol val'>:asc</span><span class='comma token'>,</span>
|
227
|
+
<span class='symbol val'>:negative_dictionary</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span>
|
228
|
+
<span class='rbrace token'>}</span><span class='dot token'>.</span><span class='rubyid_merge identifier id'>merge</span><span class='lparen token'>(</span><span class='rubyid_args identifier id'>args</span><span class='rparen token'>)</span>
|
229
|
+
<span class='rubyid_result identifier id'>result</span> <span class='assign token'>=</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span>
|
230
|
+
<span class='rubyid_text identifier id'>text</span> <span class='assign token'>=</span> <span class='rubyid_process_text identifier id'>process_text</span>
|
231
|
+
<span class='rubyid_options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:dictionary</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='rubyid_text identifier id'>text</span><span class='dot token'>.</span><span class='rubyid_split identifier id'>split</span><span class='lparen token'>(</span><span class='string val'>" "</span><span class='rparen token'>)</span> <span class='rubyid_unless unless_mod kw'>unless</span> <span class='rubyid_options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:dictionary</span><span class='rbrack token'>]</span>
|
232
|
+
<span class='rubyid_regex identifier id'>regex</span> <span class='assign token'>=</span> <span class='rubyid_Regexp constant id'>Regexp</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='rubyid_options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:dictionary</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='rubyid_join identifier id'>join</span><span class='lparen token'>(</span><span class='string val'>"|"</span><span class='rparen token'>)</span><span class='comma token'>,</span> <span class='rubyid_Regexp constant id'>Regexp</span><span class='colon2 op'>::</span><span class='rubyid_IGNORECASE constant id'>IGNORECASE</span><span class='rparen token'>)</span>
|
233
|
+
<span class='rubyid_match_result identifier id'>match_result</span> <span class='assign token'>=</span> <span class='rubyid_text identifier id'>text</span><span class='dot token'>.</span><span class='rubyid_scan identifier id'>scan</span><span class='lparen token'>(</span><span class='rubyid_regex identifier id'>regex</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='rubyid_map identifier id'>map</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='rubyid_i identifier id'>i</span><span class='bitor op'>|</span> <span class='rubyid_i identifier id'>i</span><span class='dot token'>.</span><span class='rubyid_downcase identifier id'>downcase</span><span class='rbrace token'>}</span>
|
234
|
+
<span class='rubyid_match_result identifier id'>match_result</span><span class='dot token'>.</span><span class='rubyid_each identifier id'>each</span> <span class='rubyid_do do kw'>do</span> <span class='bitor op'>|</span><span class='rubyid_w identifier id'>w</span><span class='bitor op'>|</span>
|
235
|
+
<span class='rubyid_result identifier id'>result</span> <span class='lshft op'><<</span> <span class='lbrace token'>{</span><span class='symbol val'>:hits</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='rubyid_match_result identifier id'>match_result</span><span class='dot token'>.</span><span class='rubyid_count identifier id'>count</span><span class='lparen token'>(</span><span class='rubyid_w identifier id'>w</span><span class='rparen token'>)</span><span class='comma token'>,</span> <span class='symbol val'>:word</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='rubyid_w identifier id'>w</span><span class='rbrace token'>}</span> <span class='rubyid_unless unless_mod kw'>unless</span> <span class='rubyid_result identifier id'>result</span><span class='dot token'>.</span><span class='rubyid_select identifier id'>select</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='rubyid_r identifier id'>r</span><span class='bitor op'>|</span> <span class='rubyid_r identifier id'>r</span><span class='lbrack token'>[</span><span class='symbol val'>:word</span><span class='rbrack token'>]</span> <span class='eq op'>==</span> <span class='rubyid_w identifier id'>w</span><span class='rbrace token'>}</span><span class='dot token'>.</span><span class='rubyid_shift identifier id'>shift</span> <span class='rubyid_unless unless_mod kw'>unless</span> <span class='rubyid_options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:negative_dictionary</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='rubyid_map identifier id'>map</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='rubyid_i identifier id'>i</span><span class='bitor op'>|</span> <span class='rubyid_i identifier id'>i</span><span class='dot token'>.</span><span class='rubyid_downcase identifier id'>downcase</span><span class='rbrace token'>}</span><span class='dot token'>.</span><span class='rubyid_include? fid id'>include?</span><span class='lparen token'>(</span><span class='rubyid_w identifier id'>w</span><span class='rparen token'>)</span>
|
236
|
+
<span class='rubyid_end end kw'>end</span>
|
237
|
+
<span class='rubyid_result identifier id'>result</span> <span class='assign token'>=</span> <span class='rubyid_result identifier id'>result</span><span class='dot token'>.</span><span class='rubyid_sort_by identifier id'>sort_by</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='rubyid_i identifier id'>i</span><span class='bitor op'>|</span> <span class='rubyid_i identifier id'>i</span><span class='lbrack token'>[</span><span class='rubyid_options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:order</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span><span class='rbrace token'>}</span>
|
238
|
+
<span class='rubyid_result identifier id'>result</span><span class='dot token'>.</span><span class='rubyid_reverse! fid id'>reverse!</span> <span class='rubyid_if if_mod kw'>if</span> <span class='rubyid_options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:order_direction</span><span class='rbrack token'>]</span> <span class='eq op'>==</span> <span class='symbol val'>:desc</span>
|
239
|
+
<span class='rubyid_result identifier id'>result</span>
|
240
|
+
<span class='rubyid_end end kw'>end</span>
|
241
|
+
</pre>
|
242
|
+
</td>
|
243
|
+
</tr>
|
244
|
+
</table>
|
245
|
+
</div>
|
246
|
+
|
247
|
+
</div>
|
248
|
+
|
249
|
+
</div>
|
250
|
+
|
251
|
+
<div id="footer">
|
252
|
+
Generated on Tue Dec 6 10:19:06 2011 by
|
253
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
254
|
+
0.7.4 (ruby-1.8.7).
|
255
|
+
</div>
|
256
|
+
|
257
|
+
</body>
|
258
|
+
</html>
|