tyccl_tim_fixed 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +6 -0
  3. data/LICENSE +20 -0
  4. data/README.md +75 -0
  5. data/Rakefile +11 -0
  6. data/doc/Object.html +154 -0
  7. data/doc/README_md.html +182 -0
  8. data/doc/Tyccl/Containers.html +130 -0
  9. data/doc/Tyccl/Logger.html +130 -0
  10. data/doc/Tyccl/YAML.html +130 -0
  11. data/doc/Tyccl.html +1020 -0
  12. data/doc/created.rid +3 -0
  13. data/doc/images/add.png +0 -0
  14. data/doc/images/arrow_up.png +0 -0
  15. data/doc/images/brick.png +0 -0
  16. data/doc/images/brick_link.png +0 -0
  17. data/doc/images/bug.png +0 -0
  18. data/doc/images/bullet_black.png +0 -0
  19. data/doc/images/bullet_toggle_minus.png +0 -0
  20. data/doc/images/bullet_toggle_plus.png +0 -0
  21. data/doc/images/date.png +0 -0
  22. data/doc/images/delete.png +0 -0
  23. data/doc/images/find.png +0 -0
  24. data/doc/images/loadingAnimation.gif +0 -0
  25. data/doc/images/macFFBgHack.png +0 -0
  26. data/doc/images/package.png +0 -0
  27. data/doc/images/page_green.png +0 -0
  28. data/doc/images/page_white_text.png +0 -0
  29. data/doc/images/page_white_width.png +0 -0
  30. data/doc/images/plugin.png +0 -0
  31. data/doc/images/ruby.png +0 -0
  32. data/doc/images/tag_blue.png +0 -0
  33. data/doc/images/tag_green.png +0 -0
  34. data/doc/images/transparent.png +0 -0
  35. data/doc/images/wrench.png +0 -0
  36. data/doc/images/wrench_orange.png +0 -0
  37. data/doc/images/zoom.png +0 -0
  38. data/doc/index.html +166 -0
  39. data/doc/js/darkfish.js +155 -0
  40. data/doc/js/jquery.js +18 -0
  41. data/doc/js/navigation.js +142 -0
  42. data/doc/js/search.js +94 -0
  43. data/doc/js/search_index.js +1 -0
  44. data/doc/js/searcher.js +228 -0
  45. data/doc/rdoc.css +595 -0
  46. data/doc/table_of_contents.html +111 -0
  47. data/lib/Inverted.yaml +77458 -0
  48. data/lib/cilin.txt +17817 -0
  49. data/lib/tyccl/version.rb +3 -0
  50. data/lib/tyccl.rb +371 -0
  51. data/test/test_tyccl.rb +151 -0
  52. data/tyccl.gemspec +23 -0
  53. metadata +133 -0
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+ .yardoc
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tyccl.gemspec
4
+ gem 'algorithms'
5
+
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 吴健
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # Tyccl
2
+
3
+ tyccl(同义词词林 哈工大扩展版) is a ruby gem that provides friendly functions to analyse similarity between Chinese Words.
4
+
5
+ all of Tyccl`s source files using charset: UTF-8
6
+ Finding algorithm using Tire and Hash, Time complexity O(m) m<=5, Space complexity O(n), n is proportional to the records of Cilin.
7
+ Cilin.txt(892.6KB).
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'tyccl'
14
+ gem 'algorithms'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install tyccl
23
+ $ gem install algorithms
24
+
25
+ ## Usage
26
+
27
+ simple example:
28
+
29
+ ```ruby
30
+
31
+ # Result_t = Struct.new(:value,:x_id,:y_id)
32
+ # this struct is used to return analysing result
33
+ # * field 'value' store the analysing value
34
+ # * field 'x_id' 'y_id' store the ID of word X and Y
35
+
36
+ require 'tyccl'
37
+
38
+ # Given wordA(string) and wordB(string).
39
+ # Returns a Struct Result_t which contains idA, idB, and shortest semantic distance(int) between wordA and wordB.
40
+
41
+ result = Tyccl.dist("西红柿","黄瓜")
42
+ puts result.value
43
+ puts result.x_id
44
+ puts result.y_id
45
+
46
+ # Given wordA(string) and wordB(string).
47
+ # Returns a Struct Result_t which contains the most similar Pairs wordA`s ID and wordB`s ID, and similarity(float) between idA and idB.
48
+ result = Tyccl.sim("西红柿","黄瓜")
49
+ puts result.value
50
+ puts result.x_id
51
+ puts result.y_id
52
+
53
+ # Given a word(string) and a level(int),level`s value range is [0,4],4 is default, value of level is more bigger, the similarity between returned words and the given word is more less.
54
+ # Returns a two dimensional array that contains the parameter Word`s similar words which divided by different ID that the word matchs.
55
+ # If the word has no similar, nil is returned.
56
+
57
+ m = Tyccl.get_similar("人")
58
+ puts m
59
+ #[ ["人", "士", "人物", "人士", "人氏", "人选"],
60
+ # ["成年人", "壮年人", "大人", "人", "丁", "壮丁", "佬", "中年人"],
61
+ # ["身体", "人"],
62
+ # ["人格", "人品", "人头", "人", "品质", "质地", "格调", "灵魂", "为人"],
63
+ # ["人数", "人头", "人口", "人", "口", "丁", "家口", "食指", "总人口"] ]
64
+
65
+ ```
66
+
67
+ download and see more methods in [api doc](https://github.com/JoeWoo/tyccl/blob/master/doc/index.html) and more examples in [test](https://github.com/JoeWoo/tyccl/blob/master/test/test_tyccl.rb).
68
+
69
+ ## Contributing
70
+
71
+ 1. Fork it ( http://github.com/JoeWoo/tyccl/fork )
72
+ 2. Create your feature branch (`git checkout -b fork-new`)
73
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
74
+ 4. Push to the branch (`git push origin fork-new`)
75
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ begin
3
+ require "rake/rdoctask"
4
+ rescue Exception => e
5
+ require "rdoc/task"
6
+ end
7
+ Rake::RDocTask.new do |rd|
8
+ rd.main = "README.md"
9
+ rd.rdoc_files.include("*.md", "lib/tyccl.rb")
10
+ rd.rdoc_dir = "doc"
11
+ end
data/doc/Object.html ADDED
@@ -0,0 +1,154 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
6
+
7
+ <title>class Object - RDoc Documentation</title>
8
+
9
+ <link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
10
+
11
+ <script type="text/javascript">
12
+ var rdoc_rel_prefix = "./";
13
+ </script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
16
+ <script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
17
+ <script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
18
+ <script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
19
+ <script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
20
+ <script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>
21
+
22
+
23
+ <body id="top" class="class">
24
+ <nav id="metadata">
25
+ <nav id="home-section" class="section">
26
+ <h3 class="section-header">
27
+ <a href="./index.html">Home</a>
28
+ <a href="./table_of_contents.html#classes">Classes</a>
29
+ <a href="./table_of_contents.html#methods">Methods</a>
30
+ </h3>
31
+ </nav>
32
+
33
+
34
+ <nav id="search-section" class="section project-section" class="initially-hidden">
35
+ <form action="#" method="get" accept-charset="utf-8">
36
+ <h3 class="section-header">
37
+ <input type="text" name="search" placeholder="Search" id="search-field"
38
+ title="Type to search, Up and Down to navigate, Enter to load">
39
+ </h3>
40
+ </form>
41
+
42
+ <ul id="search-results" class="initially-hidden"></ul>
43
+ </nav>
44
+
45
+
46
+
47
+
48
+ <div id="file-metadata">
49
+ <nav id="file-list-section" class="section">
50
+ <h3 class="section-header">Defined In</h3>
51
+ <ul>
52
+ <li>lib/tyccl.rb
53
+ </ul>
54
+ </nav>
55
+
56
+
57
+ </div>
58
+
59
+ <div id="class-metadata">
60
+
61
+ <nav id="parent-class-section" class="section">
62
+ <h3 class="section-header">Parent</h3>
63
+
64
+ <p class="link">BasicObject
65
+
66
+ </nav>
67
+
68
+
69
+
70
+
71
+ </div>
72
+
73
+ <div id="project-metadata">
74
+ <nav id="fileindex-section" class="section project-section">
75
+ <h3 class="section-header">Pages</h3>
76
+
77
+ <ul>
78
+
79
+ <li class="file"><a href="./README_md.html">README</a>
80
+
81
+ </ul>
82
+ </nav>
83
+
84
+ <nav id="classindex-section" class="section project-section">
85
+ <h3 class="section-header">Class and Module Index</h3>
86
+
87
+ <ul class="link-list">
88
+
89
+ <li><a href="./Object.html">Object</a>
90
+
91
+ <li><a href="./Tyccl.html">Tyccl</a>
92
+
93
+ <li><a href="./Tyccl/Containers.html">Tyccl::Containers</a>
94
+
95
+ <li><a href="./Tyccl/Logger.html">Tyccl::Logger</a>
96
+
97
+ <li><a href="./Tyccl/YAML.html">Tyccl::YAML</a>
98
+
99
+ </ul>
100
+ </nav>
101
+
102
+ </div>
103
+ </nav>
104
+
105
+ <div id="documentation">
106
+ <h1 class="class">class Object</h1>
107
+
108
+ <div id="description" class="description">
109
+
110
+ </div><!-- description -->
111
+
112
+
113
+
114
+
115
+ <section id="5Buntitled-5D" class="documentation-section">
116
+
117
+
118
+
119
+
120
+
121
+ <!-- Constants -->
122
+ <section id="constants-list" class="section">
123
+ <h3 class="section-header">Constants</h3>
124
+ <dl>
125
+
126
+ <dt id="Result_t">Result_t
127
+
128
+ <dd class="description"><p>this struct is used to return analysing result</p>
129
+ <ul><li>
130
+ <p>field &#39;value&#39; store the analysing value</p>
131
+ </li><li>
132
+ <p>field &#39;x_id&#39; &#39;y_id&#39; store the ID of word X and Y</p>
133
+ </li></ul>
134
+
135
+
136
+ </dl>
137
+ </section>
138
+
139
+
140
+
141
+
142
+ <!-- Methods -->
143
+
144
+ </section><!-- 5Buntitled-5D -->
145
+
146
+ </div><!-- documentation -->
147
+
148
+
149
+ <footer id="validator-badges">
150
+ <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
151
+ <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.
152
+ <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
153
+ </footer>
154
+
@@ -0,0 +1,182 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
6
+
7
+ <title>README - RDoc Documentation</title>
8
+
9
+ <link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
10
+
11
+ <script type="text/javascript">
12
+ var rdoc_rel_prefix = "./";
13
+ </script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
16
+ <script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
17
+ <script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
18
+ <script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
19
+ <script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
20
+ <script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>
21
+
22
+
23
+ <body class="file">
24
+ <nav id="metadata">
25
+ <nav id="home-section" class="section">
26
+ <h3 class="section-header">
27
+ <a href="./index.html">Home</a>
28
+ <a href="./table_of_contents.html#classes">Classes</a>
29
+ <a href="./table_of_contents.html#methods">Methods</a>
30
+ </h3>
31
+ </nav>
32
+
33
+
34
+ <nav id="search-section" class="section project-section" class="initially-hidden">
35
+ <form action="#" method="get" accept-charset="utf-8">
36
+ <h3 class="section-header">
37
+ <input type="text" name="search" placeholder="Search" id="search-field"
38
+ title="Type to search, Up and Down to navigate, Enter to load">
39
+ </h3>
40
+ </form>
41
+
42
+ <ul id="search-results" class="initially-hidden"></ul>
43
+ </nav>
44
+
45
+
46
+
47
+ <div id="table-of-contents">
48
+ <nav class="section">
49
+ <h3 class="section-header">Table of Contents</h3>
50
+ <ul>
51
+ <li><a href="#label-Tyccl">Tyccl</a>
52
+ <li><a href="#label-Installation">Installation</a>
53
+ <li><a href="#label-Usage">Usage</a>
54
+ <li><a href="#label-Contributing">Contributing</a>
55
+ </ul>
56
+ </nav>
57
+ </div>
58
+
59
+
60
+ <div id="project-metadata">
61
+ <nav id="fileindex-section" class="section project-section">
62
+ <h3 class="section-header">Pages</h3>
63
+
64
+ <ul>
65
+
66
+ <li class="file"><a href="./README_md.html">README</a>
67
+
68
+ </ul>
69
+ </nav>
70
+
71
+ <nav id="classindex-section" class="section project-section">
72
+ <h3 class="section-header">Class and Module Index</h3>
73
+
74
+ <ul class="link-list">
75
+
76
+ <li><a href="./Object.html">Object</a>
77
+
78
+ <li><a href="./Tyccl.html">Tyccl</a>
79
+
80
+ <li><a href="./Tyccl/Containers.html">Tyccl::Containers</a>
81
+
82
+ <li><a href="./Tyccl/Logger.html">Tyccl::Logger</a>
83
+
84
+ <li><a href="./Tyccl/YAML.html">Tyccl::YAML</a>
85
+
86
+ </ul>
87
+ </nav>
88
+
89
+ </div>
90
+ </nav>
91
+
92
+ <div id="documentation" class="description">
93
+
94
+ <h1 id="label-Tyccl"><a href="Tyccl.html">Tyccl</a><span><a href="#label-Tyccl">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
95
+
96
+ <p>tyccl(同义词词林 哈工大扩展版) is a ruby gem that provides friendly functions to
97
+ analyse similarity between Chinese Words.</p>
98
+
99
+ <p>all of Tyccl`s source files using charset: UTF-8</p>
100
+
101
+ <h2 id="label-Installation">Installation<span><a href="#label-Installation">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
102
+
103
+ <p>Add this line to your application&#39;s Gemfile:</p>
104
+
105
+ <pre>gem &#39;tyccl&#39;</pre>
106
+
107
+ <p>And then execute:</p>
108
+
109
+ <pre>$ bundle</pre>
110
+
111
+ <p>Or install it yourself as:</p>
112
+
113
+ <pre>$ gem install tyccl</pre>
114
+
115
+ <h2 id="label-Usage">Usage<span><a href="#label-Usage">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
116
+
117
+ <p>simple example:</p>
118
+
119
+ <pre class="ruby">
120
+ <span class="ruby-comment"># Result_t = Struct.new(:value,:x_id,:y_id)</span>
121
+ <span class="ruby-comment"># this struct is used to return analysing result</span>
122
+ <span class="ruby-comment"># * field &#39;value&#39; store the analysing value</span>
123
+ <span class="ruby-comment"># * field &#39;x_id&#39; &#39;y_id&#39; store the ID of word X and Y </span>
124
+
125
+ <span class="ruby-identifier">require</span> <span class="ruby-string">&#39;tyccl&#39;</span>
126
+
127
+ <span class="ruby-comment"># Given wordA(string) and wordB(string). </span>
128
+ <span class="ruby-comment"># Returns a Struct Result_t which contains idA, idB, and shortest semantic distance(int) between wordA and wordB. </span>
129
+
130
+ <span class="ruby-identifier">result</span> = <span class="ruby-constant">Tyccl</span>.<span class="ruby-identifier">dist</span>(<span class="ruby-string">&quot;西红柿&quot;</span>,<span class="ruby-string">&quot;黄瓜&quot;</span>)
131
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">value</span>
132
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">x_id</span>
133
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">y_id</span>
134
+
135
+ <span class="ruby-comment"># Given wordA(string) and wordB(string).</span>
136
+ <span class="ruby-comment"># Returns a Struct Result_t which contains the most similar Pairs wordA`s ID and wordB`s ID, and similarity(float) between idA and idB.</span>
137
+ <span class="ruby-identifier">result</span> = <span class="ruby-constant">Tyccl</span>.<span class="ruby-identifier">sim</span>(<span class="ruby-string">&quot;西红柿&quot;</span>,<span class="ruby-string">&quot;黄瓜&quot;</span>)
138
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">value</span>
139
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">x_id</span>
140
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">y_id</span>
141
+
142
+ <span class="ruby-comment"># Given a word(string) and a level(int),level`s value range is [0,4],4 is default, value of level is more bigger, the similarity between returned words and the given word is more less. </span>
143
+ <span class="ruby-comment"># Returns a two dimensional array that contains the parameter Word`s similar words which divided by different ID that the word matchs.</span>
144
+ <span class="ruby-comment"># If the word has no similar, nil is returned.</span>
145
+
146
+ <span class="ruby-identifier">m</span> = <span class="ruby-constant">Tyccl</span>.<span class="ruby-identifier">get_similar</span>(<span class="ruby-string">&quot;人&quot;</span>)
147
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">m</span>
148
+ <span class="ruby-comment">#[ [&quot;人&quot;, &quot;士&quot;, &quot;人物&quot;, &quot;人士&quot;, &quot;人氏&quot;, &quot;人选&quot;],</span>
149
+ <span class="ruby-comment"># [&quot;成年人&quot;, &quot;壮年人&quot;, &quot;大人&quot;, &quot;人&quot;, &quot;丁&quot;, &quot;壮丁&quot;, &quot;佬&quot;, &quot;中年人&quot;],</span>
150
+ <span class="ruby-comment"># [&quot;身体&quot;, &quot;人&quot;],</span>
151
+ <span class="ruby-comment"># [&quot;人格&quot;, &quot;人品&quot;, &quot;人头&quot;, &quot;人&quot;, &quot;品质&quot;, &quot;质地&quot;, &quot;格调&quot;, &quot;灵魂&quot;, &quot;为人&quot;],</span>
152
+ <span class="ruby-comment"># [&quot;人数&quot;, &quot;人头&quot;, &quot;人口&quot;, &quot;人&quot;, &quot;口&quot;, &quot;丁&quot;, &quot;家口&quot;, &quot;食指&quot;, &quot;总人口&quot;] ]</span>
153
+ </pre>
154
+
155
+ <p>download and see more methods in <a
156
+ href="https://github.com/JoeWoo/tyccl/blob/master/doc/index.html">api
157
+ doc</a> and more examples in <a
158
+ href="https://github.com/JoeWoo/tyccl/blob/master/test/test_tyccl.rb">test</a>.</p>
159
+
160
+ <h2 id="label-Contributing">Contributing<span><a href="#label-Contributing">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
161
+
162
+ <p>1. Fork it ( <a
163
+ href="http://github.com/JoeWoo/tyccl/fork">github.com/JoeWoo/tyccl/fork</a>
164
+ )
165
+ 2. Create your feature branch (<code>git checkout -b fork-new</code>)
166
+ 3.
167
+ Commit your changes (<code>git commit -am &#39;Add some
168
+ feature&#39;</code>)
169
+ 4. Push to the branch (<code>git push origin
170
+ fork-new</code>)
171
+ 5. Create new Pull Request</p>
172
+
173
+ </div>
174
+
175
+
176
+
177
+ <footer id="validator-badges">
178
+ <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
179
+ <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.
180
+ <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
181
+ </footer>
182
+