linkterm 0.0.2 → 0.0.3

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,156 @@
1
+ * Ruby�Ȥ�
2
+
3
+ Ruby�ϥ���ץ뤫�Ķ��Ϥʥ��֥������Ȼظ�������ץȸ���Ǥ���
4
+ Ruby�Ϻǽ餫����ʥ��֥������Ȼظ�����Ȥ����߷פ���Ƥ���
5
+ �����顤���֥������Ȼظ��ץ�����ߥ󥰤��ڤ˹Ԥ����������
6
+ ������������̾�μ�³�����Υץ�����ߥ󥰤��ǽ�Ǥ���
7
+
8
+ Ruby�ϥƥ����Ƚ����ط���ǽ�Ϥʤɤ�ͥ�졤Perl��Ʊ�����餤����
9
+ �Ǥ�������˥���ץ��ʸˡ�ȡ��㳰�����䥤�ƥ졼���ʤɤε���
10
+ �ˤ�äơ����ʬ����䤹���ץ�����ߥ󥰤�����ޤ���
11
+
12
+
13
+ * Ruby����Ĺ
14
+
15
+ + ����ץ��ʸˡ
16
+ + ���̤Υ��֥������Ȼظ���ǽ(���饹���᥽�åɥ�����ʤ�)
17
+ + �ü�ʥ��֥������Ȼظ���ǽ(Mixin, �ðۥ᥽�åɤʤ�)
18
+ + �黻�ҥ����С�������
19
+ + �㳰������ǽ
20
+ + ���ƥ졼���ȥ���������
21
+ + �����١������쥯��
22
+ + �����ʥߥå������ǥ��� (�������ƥ�����ˤ��)
23
+ + �ܿ������⤤��¿����UNIX���ư�������Ǥʤ���DOS��Windows��
24
+ Mac��BeOS�ʤɤξ�Ǥ�ư��
25
+
26
+
27
+ * ����ˡ
28
+
29
+ ** FTP��
30
+
31
+ �ʲ��ξ��ˤ����Ƥ���ޤ���
32
+
33
+ ftp://ftp.ruby-lang.org/pub/ruby/
34
+
35
+ ** Subversion��
36
+
37
+ ��ȯ��ü�Υ����������ɤϼ��Υ��ޥ�ɤǼ����Ǥ��ޤ���
38
+
39
+ $ svn co http://svn.ruby-lang.org/repos/ruby/trunk/ ruby
40
+
41
+ ¾�˳�ȯ��Υ֥����ΰ����ϼ��Υ��ޥ�ɤǸ����ޤ���
42
+
43
+ $ svn ls http://svn.ruby-lang.org/repos/ruby/branches/
44
+
45
+
46
+ * �ۡ���ڡ���
47
+
48
+ Ruby�Υۡ���ڡ�����URL��
49
+
50
+ http://www.ruby-lang.org/
51
+
52
+ �Ǥ���
53
+
54
+
55
+ * �᡼��󥰥ꥹ��
56
+
57
+ Ruby�Υ᡼��󥰥ꥹ�Ȥ�����ޤ������ô�˾������
58
+
59
+ ruby-list-ctl@ruby-lang.org
60
+
61
+ �ޤ���ʸ��
62
+
63
+ subscribe YourFirstName YourFamilyName
64
+
65
+ �Ƚ񤤤����äƲ�������
66
+
67
+ Ruby��ȯ�Ը����᡼��󥰥ꥹ�Ȥ⤢��ޤ���������Ǥ�ruby�Υ�
68
+ ��������λ��ͳ�ĥ�ʤɼ����������ˤĤ��Ƶ�������Ƥ��ޤ���
69
+ ���ô�˾������
70
+
71
+ ruby-dev-ctl@ruby-lang.org
72
+
73
+ �ޤ�ruby-list��Ʊ�ͤ���ˡ�ǥ᡼�뤷�Ƥ���������
74
+
75
+ Ruby��ĥ�⥸�塼��ˤĤ����ä��礦ruby-ext�᡼��󥰥ꥹ�Ȥ�
76
+ ���شط�������ˤĤ����ä��礦ruby-math�᡼��󥰥ꥹ�Ȥ�
77
+ �Ѹ���ä��礦ruby-talk�᡼��󥰥ꥹ�Ȥ⤢��ޤ���������ˡ
78
+ �Ϥɤ��Ʊ���Ǥ���
79
+
80
+
81
+ * ����ѥ��롦���󥹥ȡ���
82
+
83
+ �ʲ��μ��ǹԤäƤ���������
84
+
85
+ 1. �⤷configure�ե����뤬���Ĥ���ʤ����⤷����
86
+ configure.in���Ť��褦�ʤ顢autoconf��¹Ԥ���
87
+ ������configure����������
88
+
89
+ 2. configure��¹Ԥ���Makefile�ʤɤ���������
90
+
91
+ 3. (ɬ�פʤ��)defines.h���Խ�����
92
+
93
+ ¿ʬ��ɬ��̵���Ȼפ��ޤ���
94
+
95
+ 4. (ɬ�פʤ��)ext/Setup����Ū�˥�󥯤����ĥ�⥸�塼���
96
+ ���ꤹ��
97
+
98
+ ext/Setup�˵��Ҥ����⥸�塼�����Ū�˥�󥯤���ޤ���
99
+
100
+ �����ʥߥå������ǥ��󥰤򥵥ݡ��Ȥ��Ƥ��ʤ��������ƥ�
101
+ ����Ǥ�Setup��1���ܤΡ�option nodynamic�פȤ����ԤΥ�
102
+ ���Ȥ򳰤�ɬ�פ�����ޤ����ޤ������Υ������ƥ������
103
+ ��ĥ�⥸�塼������Ѥ��뤿��ˤϡ����餫������Ū�˥��
104
+ �����Ƥ���ɬ�פ�����ޤ���
105
+
106
+ 5. make��¹Ԥ��ƥ���ѥ��뤹��
107
+
108
+ 6. make test�ǥƥ��Ȥ�Ԥ���
109
+
110
+ ��test succeeded�פ�ɽ�������������Ǥ����������ƥ���
111
+ ���������Ƥⴰ�������ݾڤ���Ƥ������ǤϤ���ޤ���
112
+
113
+ 7. make install
114
+
115
+ root�Ǻ�Ȥ���ɬ�פ����뤫�⤷��ޤ���
116
+
117
+ �⤷������ѥ�����˥��顼��ȯ���������ˤϥ��顼�Υ����ȥ�
118
+ ����OS�μ����ޤ�Ǥ�������ܤ�����ݡ��Ȥ��Ԥ����äƤ�
119
+ �������¾�����Τ���ˤ�ʤ�ޤ���
120
+
121
+
122
+ * �ܿ�
123
+
124
+ UNIX�Ǥ����configure���ۤȤ�ɤκ��ۤ�ۼ����Ƥ����Ϥ���
125
+ �������פ�̸���Ȥ������ä����(����˰㤤�ʤ�)����Ԥˤ���
126
+ ���Ȥ��ݡ��Ȥ���С����Ǥ��뤫���Τ�ޤ���
127
+
128
+ �������ƥ�����ˤ�äȤ��¸����Τ�GC���Ǥ���Ruby��GC���о�
129
+ �Υ������ƥ����㤬setjmp()�ˤ�ä����ƤΥ쥸������ jmp_buf��
130
+ ��Ǽ���뤳�Ȥȡ�jmp_buf�ȥ����å���32bit���饤����Ȥ����
131
+ ���뤳�Ȥ��ꤷ�Ƥ��ޤ����ä����Ԥ���Ω���ʤ������б�����
132
+ ��˺���Ǥ��礦����Ԥβ������Ū��ñ�ǡ�gc.c�ǥ����å���
133
+ �ޡ������Ƥ�����ʬ�˥��饤����ȤΥХ��ȿ��������餷�ƥޡ�
134
+ �����륳���ɤ��ɲä�������ǺѤߤޤ�����defined(THINK_C)�פ�
135
+ ����Ƥ�����ʬ�򻲹ͤˤ��Ƥ�������
136
+
137
+ # �ºݤˤ�Ruby��Think C�Ǥϥ���ѥ���Ǥ��ޤ���
138
+
139
+ �쥸����������ɥ������CPU�Ǥϡ��쥸����������ɥ��򥹥���
140
+ ���˥ե�å��夹�륢����֥饳���ɤ��ɲä���ɬ�פ����뤫����
141
+ ��ޤ���
142
+
143
+
144
+ * ���۾��
145
+
146
+ COPYING.ja�ե�����򻲾Ȥ��Ƥ���������
147
+
148
+
149
+ * ����
150
+
151
+ �����ȡ��Х���ݡ��Ȥ���¾�� matz@netlab.jp �ޤǡ�
152
+ -------------------------------------------------------
153
+ created at: Thu Aug 3 11:57:36 JST 1995
154
+ Local variables:
155
+ mode: indented-text
156
+ end:
@@ -0,0 +1,20 @@
1
+ $LOAD_PATH << '../lib'
2
+ require 'linkterm.rb'
3
+ require 'pp'
4
+
5
+ # CUI
6
+ linkterm = Linkterm::Base.new :doc_dir => 'docs'
7
+ rule_table = linkterm.rule_table
8
+ pp rule_table
9
+ puts "input?"
10
+ loop do
11
+ str = NKF.nkf('-w', gets.chop)
12
+ rule_table.select {|record|
13
+ record[:a1].any? {|r| /^#{str}/ =~ r } ||
14
+ record[:a2].any? {|r| /^#{str}/ =~ r }
15
+ }.each {|record|
16
+ puts "[#{record[:a1].join(', ')}]\t\t-> [#{record[:a2].join(', ')}]"
17
+ }
18
+ end
19
+
20
+
@@ -0,0 +1,12 @@
1
+ # example:
2
+ # huge('a.txt', 'b.txt') {|chunk| chunk.to_i }
3
+ def huge(input, output)
4
+ File.open(output, 'w') {|io| io.write nil }
5
+
6
+ File.open(input, 'r') do |i_io|
7
+ i_io.each_line do |chunk|
8
+ File.open(output, 'a') {|io| io.write yield(chunk) }
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,39 @@
1
+ # �ꥹ������ɽ��
2
+ # 2007-06-01 Tatsuhiro Ujihisa
3
+ #
4
+ # List comprehension - Wikipedia, the free encyclopedia
5
+ # http://en.wikipedia.org/wiki/List_comprehension
6
+ #
7
+ # OK:
8
+ # { x | x <- [1,2,3], x % 2 == 0 }
9
+ # [ x | x <- [1,2,3], x % 2 == 0 ]
10
+ # { x || x <- [1,2,3], x % 2 == 0 }
11
+ # NG:
12
+ # { x | x <- [1, 2, 3], x % 2 == 0 }
13
+ # { x | x <- [1,2,3],x % 2 == 0 }
14
+ # example:
15
+ # '{ [x, y] | x <- [1,2,3], y <- %w(a b c) }'.lisc_do(binding)
16
+ #
17
+ class String
18
+ def lisc
19
+ /^[\{\[]\s*(.*?)\s*\|\|?\s*(.*?)\s*[\}\]]$/ =~ self
20
+ left, right = $1, $2
21
+ comma = /,\s/ # ���ѥ졼���Ȥ��ƤΥ���ޤϡ����ڡ���ɬ��
22
+ rights = right.split(comma)
23
+
24
+ vars, conds =
25
+ rights.map {|right| right.split(/\s*<-\s*/) }.partition {|right| right.size == 2 }.
26
+ map {|right| right.to_a}
27
+
28
+ ["_list_comprehension_tmp = []",
29
+ vars.map {|var| "#{var[1]}.each {|#{var[0]}| " }.join,
30
+ " _list_comprehension_tmp << #{left}" + (conds.empty? ? '' : " if " + conds.join(' && ')) +
31
+ vars.map { "}" }.join,
32
+ "_list_comprehension_tmp"].join "\n"
33
+ end
34
+
35
+ def lisc_do(binding)
36
+ eval self.lisc, binding
37
+ end
38
+ end
39
+
@@ -2,7 +2,7 @@ module Linkterm #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/linkterm.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  $KCODE = 'u'
2
2
  require 'linkterm/version'
3
3
  require 'linkterm/lisc'
4
+ require 'linkterm/huge'
4
5
  require 'MeCab'
5
6
  require 'set'
6
7
  require 'mathn'
@@ -36,8 +37,10 @@ module MeCab
36
37
  end
37
38
 
38
39
  def each(&b)
39
- b[self]
40
- self.next.each(&b) if self.next
40
+ tmp = self
41
+ begin
42
+ b[tmp]
43
+ end while(tmp = tmp.next)
41
44
  end
42
45
  end
43
46
  end
@@ -59,7 +62,7 @@ class Counter
59
62
  end
60
63
 
61
64
  def display!
62
- @output.puts "#{@message} #{@i += 1}/#{@max}"
65
+ @output << "#{@message} #{@i += 1}/#{@max}\n"
63
66
  end
64
67
  end
65
68
 
@@ -69,11 +72,11 @@ module Linkterm
69
72
  def initialize(options = {})
70
73
  @doc_dir = options[:doc_dir]
71
74
 
72
- @documents = Documents.new Dir.open(@doc_dir).reject {|f| /^\.+$/ =~ f }.map {|f| "#{@doc_dir}/" + f }
75
+ @documents = Documents.new Dir.open(@doc_dir).reject {|f| /^\./ =~ f }.map {|f| "#{@doc_dir}/" + f }
73
76
  end
74
77
 
75
78
  def idf(word)
76
- unless @documents_count
79
+ if defined? @documents_count
77
80
  all_count = Hash.new(0)
78
81
  counter = Counter.new(@documents.filenames.length, 'idf')
79
82
  @documents.each do |document|
@@ -92,7 +95,7 @@ module Linkterm
92
95
  @documents_count = all_count
93
96
  end
94
97
 
95
- Math.log( @documents.filenames.length / @documents_count[word] )
98
+ Math.log( @documents.filenames.length.to_f / @documents_count[word] )
96
99
  end
97
100
 
98
101
  def rule_table
data/makemanifest ADDED
@@ -0,0 +1,23 @@
1
+ #!/opt/local/bin/ruby
2
+
3
+ #base_dir = File.join(File.dirname(__FILE__), "..")
4
+ base_dir = '.'
5
+
6
+ glob_pattern = File.join("**", "*")
7
+ exclude_patterns = [
8
+ /^pkg/,/^doc/,
9
+ ]
10
+
11
+ Dir.chdir(base_dir)
12
+ files = Dir.glob(glob_pattern).delete_if do |fname|
13
+ File.directory?(fname) or
14
+ exclude_patterns.find do |pattern|
15
+ pattern =~ fname
16
+ end
17
+ end
18
+ manifest = File.new("Manifest.txt", "w")
19
+ manifest.puts files.sort.join("\n")
20
+ manifest.close
21
+
22
+ puts "Manifest.txt updated"
23
+
@@ -5,7 +5,57 @@ class TestLinkterm < Test::Unit::TestCase
5
5
  def setup
6
6
  end
7
7
 
8
- def test_truth
9
- assert true
8
+ def test_extending_bases
9
+ n, m = rand, rand
10
+ assert_equal Set.new([n]), [n].to_set
11
+ assert_equal [[n, m], [m, n]], [n, m].parm
12
+ assert_equal({n => m, 'a' => 'b'},
13
+ [[n, m], %w(a b)].to_hash)
14
+ assert_equal [[1,4], [2], [3]].to_set,
15
+ [1,2,3,4].partitions {|i| i%3 }.to_set
10
16
  end
17
+
18
+ def test_extending_mecab
19
+ mecab = MeCab::Tagger.new("-Ochasen")
20
+ text = '今日はとてもいい天気'
21
+ assert_equal ["", "今日", "は", "とても", "いい","天気", ""],
22
+ mecab.parseToNode(NKF.nkf('-w', text)).map {|n| n.surface }
23
+ end
24
+
25
+ def test_extending_mecab_with_huge_documents
26
+ n = 1000
27
+ mecab = MeCab::Tagger.new("-Ochasen")
28
+ text = '今日はとてもいい天気' * n
29
+ nodes = [""] + (["今日", "は", "とても", "いい","天気"] * n) + [""]
30
+ mecabs = mecab.parseToNode(NKF.nkf('-w', text)).map {|n| n.surface }
31
+ assert_equal nodes,
32
+ mecabs
33
+ end
34
+
35
+ def test_counter
36
+ n = 1 + rand(23)
37
+ mock_io = []
38
+ c = Counter.new(n, 'a', mock_io)
39
+ n.times { c.display! }
40
+ text = [*1..n].map {|i|
41
+ "[a]: #{i}/#{n}\n"
42
+ }.join
43
+ assert_equal text, mock_io.join
44
+ end
45
+
46
+ # def test_linkterm
47
+ # linkterm = Linkterm::Base.new :doc_dir => 'docs'
48
+ # rule_table = linkterm.rule_table
49
+ # pp rule_table
50
+ # puts "input?"
51
+ # loop do
52
+ # str = NKF.nkf('-w', gets.chop)
53
+ # rule_table.select {|record|
54
+ # record[:a1].any? {|r| /^#{str}/ =~ r } ||
55
+ # record[:a2].any? {|r| /^#{str}/ =~ r }
56
+ # }.each {|record|
57
+ # puts "[#{record[:a1].join(', ')}]\t\t-> [#{record[:a2].join(', ')}]"
58
+ # }
59
+ # end
60
+ # end
11
61
  end
Binary file
Binary file
Binary file
data/website/index.html CHANGED
@@ -33,7 +33,7 @@
33
33
  <h1>linkterm</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/linkterm"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/linkterm" class="numbers">0.0.2</a>
36
+ <a href="http://rubyforge.org/projects/linkterm" class="numbers">0.0.3</a>
37
37
  </div>
38
38
  <h1>&#x2192; &#8216;linkterm&#8217;</h1>
39
39
 
@@ -41,13 +41,21 @@
41
41
  <h2>What</h2>
42
42
 
43
43
 
44
- <p><img src='rosetownnozomi.png' alt='Rosetown Nozomi' /></p>
44
+ <p><img src='rosetownnozomi.png' alt='Rosetown Nozomi' width='128' height=128' /></p>
45
+
46
+
47
+ Briefing paper at biwako-dev, 2007-07-01
48
+ <ul>
49
+ <li><a href="./Linkterm.pdf">pdf</a></li>
50
+ <li><a href="./Linkterm.key.tgz">KeyNote</a></li>
51
+ </ul>
45
52
 
46
53
 
47
54
  <h2>Installing</h2>
48
55
 
49
56
 
50
57
  <pre syntax="ruby">sudo gem install linkterm</pre>
58
+ and read <em><span class="caps">README</span>.txt</em>.
51
59
 
52
60
  <h2>The basics</h2>
53
61
 
@@ -76,15 +84,15 @@
76
84
  <h2>License</h2>
77
85
 
78
86
 
79
- <p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
87
+ <p>This code is free to use under the terms of the Ruby license.</p>
80
88
 
81
89
 
82
90
  <h2>Contact</h2>
83
91
 
84
92
 
85
- <p>Comments are welcome. Send an email to <a href="mailto:FIXME">Linkterm</a> email.</p>
93
+ <p>Comments are welcome. Send an email to <a href="mailto:ujihisa(at)gmail.com">ujihisa</a>.</p>
86
94
  <p class="coda">
87
- <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 8th July 2007<br>
95
+ <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 24th August 2007<br>
88
96
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
89
97
  </p>
90
98
  </div>
data/website/index.txt CHANGED
@@ -5,11 +5,17 @@ h1. &#x2192; 'linkterm'
5
5
 
6
6
  h2. What
7
7
 
8
- <img src='rosetownnozomi.png' alt='Rosetown Nozomi' />
8
+ <img src='rosetownnozomi.png' alt='Rosetown Nozomi' width='128' height=128' />
9
+
10
+ Briefing paper at biwako-dev, 2007-07-01
11
+ * "pdf":./Linkterm.pdf
12
+ * "KeyNote":./Linkterm.key.tgz
13
+
9
14
 
10
15
  h2. Installing
11
16
 
12
17
  <pre syntax="ruby">sudo gem install linkterm</pre>
18
+ and read _README.txt_.
13
19
 
14
20
  h2. The basics
15
21
 
@@ -32,8 +38,8 @@ The trunk repository is <code>svn://rubyforge.org/var/svn/linkterm/trunk</code>
32
38
 
33
39
  h2. License
34
40
 
35
- This code is free to use under the terms of the MIT license.
41
+ This code is free to use under the terms of the Ruby license.
36
42
 
37
43
  h2. Contact
38
44
 
39
- Comments are welcome. Send an email to "Linkterm":mailto:FIXME email.
45
+ Comments are welcome. Send an email to "ujihisa":mailto:ujihisa(at)gmail.com.
Binary file
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: linkterm
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.2
7
- date: 2007-07-08 00:00:00 +09:00
6
+ version: 0.0.3
7
+ date: 2007-08-25 00:00:00 +09:00
8
8
  summary: A text mining tool based on Rough Sets Theory
9
9
  require_paths:
10
10
  - lib
@@ -34,15 +34,25 @@ files:
34
34
  - Manifest.txt
35
35
  - README.txt
36
36
  - Rakefile
37
+ - examples/docs/README.EXT.ja
38
+ - examples/docs/README.ja
39
+ - examples/example.rb
37
40
  - lib/linkterm.rb
41
+ - lib/linkterm/huge.rb
42
+ - lib/linkterm/lisc.rb
38
43
  - lib/linkterm/version.rb
44
+ - makemanifest
39
45
  - scripts/txt2html
40
46
  - setup.rb
41
47
  - test/test_helper.rb
42
48
  - test/test_linkterm.rb
49
+ - website/Linkterm.key.tgz
50
+ - website/Linkterm.pdf
51
+ - website/images/rosetownnozomi.png
43
52
  - website/index.html
44
53
  - website/index.txt
45
54
  - website/javascripts/rounded_corners_lite.inc.js
55
+ - website/rosetownnozomi.png
46
56
  - website/stylesheets/screen.css
47
57
  - website/template.rhtml
48
58
  test_files: