rseg 0.1.1 → 0.1.2

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.
data/README CHANGED
@@ -7,14 +7,36 @@ The algorithm is based on this article: http://xiecc.blog.163.com/blog/static/14
7
7
  Usage
8
8
  ========
9
9
 
10
- It's very easy to use:
10
+ Rseg now support two modes: inline and C/S mode.
11
+
12
+ 1. Inline mode
11
13
 
12
14
  > require 'rubygems'
13
15
  > require 'rseg'
14
16
  > RSeg.segment("需要分词的文章")
15
17
  ['需要', '分词', '的', '文章']
16
18
 
17
- The first call to Rseg#segment will need about 30 seconds to load the dictionary, the second call will be very fast.
19
+ The first call to Rseg#segment will need about 30 seconds to load the dictionary, the second call will be very fast, you can also call Rseg#load to load dictionaries manually.
20
+
21
+ 2. C/S mode
22
+
23
+ $ rseg_server
24
+ == Sinatra/0.9.4 has taken the stage on 4100
25
+
26
+ This will start rseg server on http://localhost:4100
27
+
28
+ You can visit it via your browser or the rseg command.
29
+
30
+ $ rseg '需要分词的文章'
31
+ 需要 分词 的 文章
32
+
33
+ You can also access server with the Rseg#remote_segment
34
+
35
+ $ irb
36
+ > require 'rubygems'
37
+ > require 'rseg'
38
+ > RSeg.remote_segment("需要分词的文章") # This will be very fast
39
+ ['需要', '分词', '的', '文章']
18
40
 
19
41
  Performance
20
42
  ========
data/Rakefile CHANGED
@@ -6,13 +6,15 @@ begin
6
6
  require 'jeweler'
7
7
  Jeweler::Tasks.new do |s|
8
8
  s.name = "rseg"
9
- s.executables = "rseg"
9
+ s.executables = ["rseg", 'rseg_server']
10
10
  s.summary = "A Chinese Word Segmentation(中文分词) routine in pure Ruby"
11
11
  s.email = "zhangyuanyi@gmail.com"
12
12
  s.homepage = "http://github.com/yzhang/rseg"
13
13
  s.description = "A Chinese Word Segmentation(中文分词) routine in pure Ruby"
14
14
  s.authors = ["Yuanyi Zhang"]
15
- s.files = FileList["[A-Z]*", "{bin,lib}/**/*", '.gitignore', 'dict/dict.hash']
15
+ s.files = FileList["[A-Z]*", "{bin,lib,public,views}/**/*", '.gitignore', 'dict/dict.hash']
16
+ s.add_dependency 'haml'
17
+ s.add_dependency 'sinatra'
16
18
  end
17
19
  rescue LoadError
18
20
  puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/bin/rseg CHANGED
@@ -1,3 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
+ require File.join(File.dirname(__FILE__), '/../lib/rseg')
2
3
 
3
- puts 'Coming soon'
4
+ input = ARGV[0]
5
+
6
+ if input.nil? || input == ''
7
+ puts "Usage: rseg <text>"
8
+ exit
9
+ end
10
+
11
+ puts Rseg.remote_segment(input).join(' ')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.expand_path(File.dirname(__FILE__))
3
+
4
+ require 'rubygems'
5
+ require 'haml'
6
+
7
+ require File.join(File.dirname(__FILE__), '/../lib/rseg')
8
+ require File.join(File.dirname(__FILE__), '/../lib/app')
9
+
10
+ puts "Loading dictionaries, this will take about 30 seconds."
11
+ puts "Please wait a moment..."
12
+ Rseg.load
13
+ puts "Dictionaries loaded."
14
+
15
+ App.run! :host => '127.0.0.1', :port => 4100, :environment => 'production'
16
+ exit
@@ -0,0 +1,22 @@
1
+ require 'sinatra/base'
2
+
3
+ class App < Sinatra::Default
4
+ set :root, File.dirname(__FILE__) + "/.."
5
+ set :app_file, __FILE__
6
+
7
+ get '/' do
8
+ haml :index
9
+ end
10
+
11
+ post '/segment' do
12
+ @input = params[:input]
13
+ @result = Rseg.segment(@input).join(' ')
14
+ haml :index
15
+ end
16
+
17
+ post '/seg' do
18
+ @input = params[:input]
19
+ @result = Rseg.segment(@input)
20
+ @result.join(' ')
21
+ end
22
+ end
@@ -1,27 +1,24 @@
1
- LAST_NAMES = %W(丁 卜 刁 七 弓 干 于 王 尤 孔 方 申 白 甘 田 包 石 左 平 司 皮 史 池 艾 年 匡 充 江 印
2
- 促 伊 伍 安 任 米 促 牟 向 吉 成 伏 吕 李 吴 沈 何 贝 狄 祁 杜 汪 阮 邢 汲 别 辛 冷 利 沃 谷
3
- 扶 步 那 沙 周 金 吕 花 孟 和 邵 房 抗 灰 明 屈 松 牧 宓 武 幸 卓 易 尚 邰 空 竺 岳 东 林
4
- 施 姜 俞 查 封 秋 帅 祖 羿 柯 茅 柳 姚 纪 宣 咸 库 侯 洪 胡 哈 宣 郁 祝 苗 禹 娄
5
- 秦 奚 倪 度 凌 宰 宦 师 徐 翁 班 马 时 晃 乌 夏 贡 柴 能 家 宫 敖 索 晏 桑 高 凌 桂 容 姬 劳 桑 桂 袁 时 祝 席 徐 高 夏 凌 洪 翁 家 芮 乌 祖 索 贡
6
- 许 张 曹 戚 梅 屠 盛 崖 章 鱼 国 商 扈 寇 终 冯 苗 康 常 茅 闵 麻 胡 崔 邢 条 符 宿 堵 浦 习 鱼
7
- 梁 富 曾 程 项 钮 舒 彭 费 童 云 喻 嵇 范 费 贺 毕 付 黄 邵 祁 阮 强 童 邱 解 贲 单 富 钮 荀 惠 邴 焦 班 甯 钭 景 邰 劳 茹 寇 荆
8
- 莫 际 景 须 杨 詹 郎 雷 贾 路 骆 虞 经 裘 郁 滑 甄 靳 詹 闻 逄 雍 訾 郎 农 路 骆 虞 经 裘 郁 滑 靳 闻 逄 雍
9
- 赵 黄 褚 凤 郝 齐 臧 熊 管 裴 荣 郗 韶 郜 黎 翟 寿 通
10
- 卫 葛 鲁 乐 谈 董 樊 万 诸 刘 叶 都 满 广 殴 巩 养
11
- 郭 钱 陈 陶 鲍 穆 郭 堆 卢 陆 龙 噪 鄂 阴 苍 燕 冀 衡 融 蒯 逯
12
- 蒋 魏 谢 邹 潘 滕 邬 戴 钟 蔡 缪 应 储 糜 隗 历 蒲 慕 蔚 隆 鞠 关
13
- 韩 萧 颜 庞 麦 双 璩 濮 聂 丰 看
14
- 郑 严 蓟 薄 谭 罗
15
- 买 蓝 蓬 怀 党 饶
16
- 顾 苏 龚 边 栾 权)
17
-
18
- FIRST_NAMES = %W(文 铭 菁 郁 怡 智 德 祥 志 华 孟 庆 雅 佩 晓 蓉 明 仁 宇 青 慧 豪 琪 安
19
- 惠 宗 信 盈 君 秀 敏 伶 佳 国 荣 忠 宏 育 丽 圣 淑 彦 龙 冠 后 静 娟 子
20
- 嘉 瑞 柏 弘 芳 正 玮 贞 如 凯 元 士 伟 杰 颍 霖 玲 仪 珮 英 建 政 真 珍
21
- 美 世 立 秋 婷 贤 瑜 中 玉 维 莹 翔 家 芬 昌 裕 雯 萍 永 成 宜 鸿 珊 民
22
- 欣 哲 良 伦 燕 梦 磊 丹 元 一 昌 红 健)
23
-
24
1
  class Name < Engine
2
+ @@last_names = %W(丁 卜 刁 七 弓 干 于 王 尤 孔 方 申 白 甘 田 包 石 左 平 司 皮 史 池 艾 年 匡 充 江 印
3
+ 促 伊 伍 安 任 米 促 牟 向 吉 成 伏 吕 李 吴 沈 何 贝 狄 祁 杜 汪 阮 邢 汲 别 辛 冷 利 沃 谷
4
+ 扶 步 那 沙 周 金 吕 花 孟 和 邵 房 抗 灰 明 屈 松 牧 宓 武 幸 卓 易 尚 邰 空 竺 岳 东 林
5
+ 施 姜 俞 查 封 秋 帅 祖 羿 柯 茅 柳 姚 纪 宣 咸 库 侯 洪 胡 哈 宣 郁 祝 苗 禹 娄
6
+ 秦 奚 倪 度 凌 宰 宦 师 徐 翁 班 马 时 晃 乌 夏 贡 柴 能 家 宫 敖 索 晏 桑 高 凌 桂 容 姬 劳 桑 桂 袁 时 祝 席 徐 高 夏 凌 洪 翁 家 芮 乌 祖 索 贡
7
+ 许 张 曹 戚 梅 屠 盛 崖 章 鱼 国 商 扈 寇 终 冯 苗 康 常 茅 闵 麻 胡 崔 邢 条 符 宿 堵 浦 习 鱼
8
+ 梁 富 曾 程 项 钮 舒 彭 费 童 云 喻 嵇 范 费 贺 毕 付 黄 邵 祁 阮 强 童 邱 解 贲 单 富 钮 荀 惠 邴 焦 班 甯 钭 景 邰 劳 茹 寇 荆
9
+ 莫 际 景 须 杨 詹 郎 雷 贾 路 骆 虞 经 裘 郁 滑 甄 靳 詹 闻 逄 雍 訾 郎 农 路 骆 虞 经 裘 郁 滑 靳 闻 逄 雍
10
+ 赵 黄 褚 凤 郝 齐 臧 熊 管 裴 荣 郗 韶 郜 黎 翟 寿 通
11
+ 卫 葛 鲁 乐 谈 董 樊 万 诸 刘 叶 都 满 广 殴 巩 养
12
+ 郭 钱 陈 陶 鲍 穆 郭 堆 卢 陆 龙 噪 鄂 阴 苍 燕 冀 衡 融 蒯 逯
13
+ 蒋 魏 谢 邹 潘 滕 邬 戴 钟 蔡 缪 应 储 糜 隗 历 蒲 慕 蔚 隆 鞠 关
14
+ 韩 萧 颜 庞 麦 双 璩 濮 聂 丰 看
15
+ 郑 严 蓟 薄 谭 罗 买 蓝 蓬 怀 党 饶 顾 苏 龚 边 栾 权) #:nodoc:
16
+
17
+ @@first_names = %W(文 铭 菁 郁 怡 智 德 祥 志 华 孟 庆 雅 佩 晓 蓉 明 仁 宇 青 慧 豪 琪 安
18
+ 惠 宗 信 盈 君 秀 敏 伶 佳 国 荣 忠 宏 育 丽 圣 淑 彦 龙 冠 后 静 娟 子
19
+ 嘉 瑞 柏 弘 芳 正 玮 贞 如 凯 元 士 伟 杰 颍 霖 玲 仪 珮 英 建 政 真 珍
20
+ 美 世 立 秋 婷 贤 瑜 中 玉 维 莹 翔 家 芬 昌 裕 雯 萍 永 成 宜 鸿 珊 民
21
+ 欣 哲 良 伦 燕 梦 磊 丹 元 一 昌 红 健) #:nodoc:
25
22
  def initialize
26
23
  @word = ''
27
24
  @last = false
@@ -32,11 +29,11 @@ class Name < Engine
32
29
  match = false
33
30
  word = nil
34
31
 
35
- if !@last && LAST_NAMES.include?(char)
32
+ if !@last && @@last_names.include?(char)
36
33
  @word << char
37
34
  match = true
38
35
  @last = true
39
- elsif @last && @word.chars.to_a.length < 3 && FIRST_NAMES.include?(char)
36
+ elsif @last && @word.chars.to_a.length < 3 && @@first_names.include?(char)
40
37
  @word << char
41
38
  match = true
42
39
  @unit = true
@@ -1,19 +1,19 @@
1
- NUMBER_SYMBOLS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
2
- '一', '二', '三', '四', '五', '六', '七', '八', '九', '十',
3
- '零', '〇', '百', '千', '壹', '贰', '叁', '肆', '柒', '捌',
4
- '玖', '拾', '之', '%', '¥', '分', '$', '.', '点', '第', '每']
5
- SUBUNIT_SYMBOLS = ['多', '公', '英', '厘', '毫', '微', '纳', '海', '平', '立',
6
- '方', '摄', '华', '氏', '美', '日', '澳', '港', '台', '新',
7
- '个', '百', '佰', '千', '仟', '万', '萬', '亿', '兆', '吉']
8
- UNIT_SYMBOLS = ['刻', '章', '回', '节', '名', '个', '届', '次', '集', '元',
9
- '角', '例', '人', '斤', '克', '吨', '米', '里', '升', '码',
10
- '尺', '寸', '杆', '顷', '亩', '磅', '镑', '桶', '度', '秒',
11
- '分', '卡', '焦', '瓦', '匹', '圆', '币', '年', '月', '日',
12
- '时', '秒', '点', '百', '佰', '仟', '千', '万', '萬', '亿',
13
- '兆', '吉', '块', '半', '岁', '家', '所', '期', '场', '投',
14
- '中', '辆', '只', '头']
15
-
16
1
  class Number < Engine
2
+ @@number_symbols = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
3
+ '一', '二', '三', '四', '五', '六', '七', '八', '九', '十',
4
+ '零', '〇', '百', '千', '壹', '贰', '叁', '肆', '柒', '捌',
5
+ '玖', '拾', '之', '%', '¥', '分', '$', '.', '点', '第', '每']
6
+ @@subunit_symbols = ['多', '公', '英', '厘', '毫', '微', '纳', '海', '平', '立',
7
+ '方', '摄', '华', '氏', '美', '日', '澳', '港', '台', '新',
8
+ '个', '百', '佰', '千', '仟', '万', '萬', '亿', '兆', '吉']
9
+ @@unit_symbols = ['刻', '章', '回', '节', '名', '个', '届', '次', '集', '元',
10
+ '角', '例', '人', '斤', '克', '吨', '米', '里', '升', '码',
11
+ '尺', '寸', '杆', '顷', '亩', '磅', '镑', '桶', '度', '秒',
12
+ '分', '卡', '焦', '瓦', '匹', '圆', '币', '年', '月', '日',
13
+ '时', '秒', '点', '百', '佰', '仟', '千', '万', '萬', '亿',
14
+ '兆', '吉', '块', '半', '岁', '家', '所', '期', '场', '投',
15
+ '中', '辆', '只', '头']
16
+
17
17
  def initialize
18
18
  @word = ''
19
19
  @number = ''
@@ -26,18 +26,18 @@ class Number < Engine
26
26
  match = false
27
27
  word = nil
28
28
 
29
- if (!@subunit || @unit) && NUMBER_SYMBOLS.include?(char)
29
+ if (!@subunit || @unit) && @@number_symbols.include?(char)
30
30
  @number << char
31
31
  match = true
32
32
  @unit = false
33
33
  @subunit = false
34
- elsif (@number != '' || @unit) && SUBUNIT_SYMBOLS.include?(char)
34
+ elsif (@number != '' || @unit) && @@subunit_symbols.include?(char)
35
35
  @number << char
36
36
  match = true
37
37
  @subunit = true
38
38
  end
39
39
 
40
- if (@number != '' || @subunit) && UNIT_SYMBOLS.include?(char)
40
+ if (@number != '' || @subunit) && @@unit_symbols.include?(char)
41
41
  @word << @number
42
42
  @word << char if !match
43
43
  @number = ''
@@ -1,7 +1,7 @@
1
- CONJUNCTIONS = %W(给 的 说 对 在 和 是 被 最 所 那 由 这 有 将 你 会 与 他 为 不 没 很 了 啊 哦 呵 把 去 从)
2
-
3
1
  class Conjunction
2
+ @@conjunctions = %W(给 的 说 对 在 和 是 被 最 所 那 由 这 有 将 你 会 与 他 为 不 没 很 了 啊 哦 呵 把 去 从)
3
+
4
4
  def self.filter(char)
5
- CONJUNCTIONS.include?(char) ? :conjunction : char
5
+ @@conjunctions.include?(char) ? :conjunction : char
6
6
  end
7
7
  end
@@ -1,5 +1,5 @@
1
1
  class Fullwidth
2
- FULLWIDTH_CHARS = {'1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8',
2
+ @@fullwidth_chars = {'1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8',
3
3
  '9' => '9', '0' => '0', 'a' => 'a', 'b' => 'b', 'c' => 'c', 'd' => 'd', 'e' => 'e', 'f' => 'f',
4
4
  'g' => 'g', 'h' => 'h', 'i' => 'i', 'j' => 'j', 'k' => 'k', 'l' => 'l', 'm' => 'm', 'n' => 'n',
5
5
  'o' => 'o', 'p' => 'p', 'q' => 'q', 'r' => 'r', 's' => 's', 't' => 't', 'u' => 'u', 'v' => 'v',
@@ -11,7 +11,7 @@ class Fullwidth
11
11
 
12
12
  class << self
13
13
  def filter(char)
14
- FULLWIDTH_CHARS[char].nil? ? char : FULLWIDTH_CHARS[char]
14
+ @@fullwidth_chars[char].nil? ? char : @@fullwidth_chars[char]
15
15
  end
16
16
  end
17
17
  end
@@ -1,13 +1,12 @@
1
- SEPARATORS = ['`', '[', ']', '、', '=', '‘', ';', '。', '|', '?', '》',
2
- '《', ':', '“', '{', '}', ')', '(', '*', '…', '#', '!',
3
- '~', '’', '”', '〕', '〈', '〉', '「', '」', '『', '』', '〖', '〗',
4
- '【', '】', '<', '>', '`', '~', '!', '@', '#', '^',
5
- '&', '*', '\\', '(', ')', '=', '{', '}', '[', ']',
6
- '|', ';', ':', "'", '<', '>', '?', "\n", "\t", "\r",
7
- ' ', '-', '/', '+', ',', ' ']
8
-
9
1
  class Symbol
2
+ @@separators = ['`', '[', ']', '、', '=', '‘', ';', '。', '|', '?', '》',
3
+ '《', ':', '“', '{', '}', ')', '(', '*', '…', '#', '!',
4
+ '~', '’', '”', '〕', '〈', '〉', '「', '」', '『', '』', '〖', '〗',
5
+ '【', '】', '<', '>', '`', '~', '!', '@', '#', '^',
6
+ '&', '*', '\\', '(', ')', '=', '{', '}', '[', ']',
7
+ '|', ';', ':', "'", '<', '>', '?', "\n", "\t", "\r",
8
+ ' ', '-', '/', '+', ',', ' ']
10
9
  def self.filter(char)
11
- SEPARATORS.include?(char) ? :symbol : char
10
+ @@separators.include?(char) ? :symbol : char
12
11
  end
13
12
  end
@@ -1,5 +1,8 @@
1
1
  $KCODE = 'UTF8'
2
2
 
3
+ require 'singleton'
4
+ require 'net/http'
5
+
3
6
  require File.join(File.dirname(__FILE__), 'engines/engine')
4
7
  require File.join(File.dirname(__FILE__), 'engines/dict')
5
8
  require File.join(File.dirname(__FILE__), 'engines/english')
@@ -11,24 +14,41 @@ require File.join(File.dirname(__FILE__), 'filters/symbol')
11
14
  require File.join(File.dirname(__FILE__), 'filters/conjunction')
12
15
 
13
16
  class Rseg
14
- @@engines = nil
15
- @@segment = nil
16
- @@filters = nil
17
+ include Singleton
17
18
 
18
19
  class << self
19
20
  def segment(input)
20
- @@segment ||= Rseg.new(input)
21
- @@segment.segment
21
+ Rseg.instance.input = input
22
+ Rseg.instance.segment
23
+ end
24
+
25
+ def load
26
+ Rseg.instance
27
+ nil
28
+ end
29
+
30
+ def remote_segment(input)
31
+ begin
32
+ response = Net::HTTP.post_form(URI.parse('http://127.0.0.1:4100/seg'), :input => input)
33
+ response.code == '200' ? response.body.split(' ') :
34
+ ["Can't connect to http://localhost:4100\nUse rseg_server to start it"]
35
+ rescue
36
+ ["Can't connect to http://localhost:4100\nUse rseg_server to start it"]
37
+ end
22
38
  end
23
39
  end
24
-
25
- def initialize(input)
26
- @input = input
40
+
41
+ def initialize
42
+ @input = ''
27
43
  @words = []
28
44
  init_engines
29
45
  init_filters
30
46
  end
31
47
 
48
+ def input=(input)
49
+ @input = input
50
+ end
51
+
32
52
  def segment
33
53
  @words.clear
34
54
 
@@ -44,7 +64,7 @@ class Rseg
44
64
  private
45
65
  def filter(char)
46
66
  result = char
47
- @@filters.each do |klass|
67
+ @filters.each do |klass|
48
68
  result = klass.filter(result)
49
69
  end
50
70
  result
@@ -93,19 +113,19 @@ class Rseg
93
113
  end
94
114
 
95
115
  def engines=(engines)
96
- @@engines ||= engines
116
+ @engines ||= engines
97
117
  end
98
118
 
99
119
  def engines
100
- @@engines
120
+ @engines
101
121
  end
102
122
 
103
123
  def init_filters
104
- @@filters = [Fullwidth, Symbol]
124
+ @filters = [Fullwidth, Symbol]
105
125
  end
106
126
 
107
127
  def init_engines
108
- @@engines ||= [Dict, English, Number, Name].map do |engine_klass|
128
+ @engines ||= [Dict, English, Number, Name].map do |engine_klass|
109
129
  engine_klass.new
110
130
  end
111
131
  end
@@ -0,0 +1,123 @@
1
+ div.clear {clear: both;}
2
+ body {background: #EEEEEE; margin: 0; padding: 0;
3
+ font-family: 'Lucida Grande', 'Lucida Sans Unicode',
4
+ 'Garuda';}
5
+ code {font-family: 'Lucida Console', monospace;
6
+ font-size: 12px;}
7
+ li {height: 18px;}
8
+ ul {list-style: none; margin: 0; padding: 0;}
9
+ ol:hover {cursor: pointer;}
10
+ ol li {white-space: pre;}
11
+ #explanation {font-size: 12px; color: #666666;
12
+ margin: 20px 0 0 100px;}
13
+ /* WRAP */
14
+ #wrap {width: 860px; background: #FFFFFF; margin: 0 auto;
15
+ padding: 30px 50px 20px 50px;
16
+ border-left: 1px solid #DDDDDD;
17
+ border-right: 1px solid #DDDDDD;}
18
+ /* HEADER */
19
+ #header {margin: 0 auto 25px auto;}
20
+ h1 {margin: 0; font-size: 36px; color: #981919;}
21
+ h2 {margin: 0; font-size: 22px; color: #333333;}
22
+ #header ul {margin: 0; font-size: 12px; color: #666666;}
23
+ #header ul li strong{color: #444444;}
24
+ #header ul li {display: inline; padding: 0 10px;}
25
+ #header ul li.first {padding-left: 0;}
26
+ #header ul li.last {border: 0; padding-right: 0;}
27
+
28
+ #content {width: 860px; margin: 0 auto 10px auto;}
29
+
30
+ h3 {float: left; width: 100px; margin-bottom: 10px;
31
+ color: #981919; font-size: 14px; font-weight: bold;}
32
+
33
+ #footer {width: 860px; margin: 0 auto 10px auto; clear:both;
34
+ font-size: 18px; border-top:1px solid #000; padding-top: 10px;
35
+ text-align: right;}
36
+
37
+ textarea {font-size: 18px; padding:10px;}
38
+ #segform { width: 430px; float: left; font-size: 18px;}
39
+ #segresult { width: 408px; float: left; font-size: 18px;
40
+ padding: 10px; color: #D12F19;}
41
+ /* --------------------------------------------------------------
42
+
43
+ buttons.css
44
+ * Gives you some great CSS-only buttons.
45
+
46
+ Created by Kevin Hale [particletree.com]
47
+ * particletree.com/features/rediscovering-the-button-element
48
+
49
+ See Readme.txt in this folder for instructions.
50
+
51
+ -------------------------------------------------------------- */
52
+
53
+ button {
54
+ display:block;
55
+ float:left;
56
+ margin:0 0.583em 0.667em 0;
57
+ padding:5px 10px 5px 7px; /* Links */
58
+
59
+ border:1px solid #dedede;
60
+ border-top:1px solid #eee;
61
+ border-left:1px solid #eee;
62
+
63
+ background-color:#f5f5f5;
64
+ font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif;
65
+ font-size:100%;
66
+ line-height:130%;
67
+ text-decoration:none;
68
+ font-weight:bold;
69
+ color:#565656;
70
+ cursor:pointer;
71
+ }
72
+ button {
73
+ width:auto;
74
+ overflow:visible;
75
+ padding:4px 10px 3px 7px; /* IE6 */
76
+ }
77
+ button[type] {
78
+ padding:4px 10px 4px 7px; /* Firefox */
79
+ line-height:17px; /* Safari */
80
+ }
81
+ *:first-child+html button[type] {
82
+ padding:4px 10px 3px 7px; /* IE7 */
83
+ }
84
+ button img {
85
+ margin:0 3px -3px 0 !important;
86
+ padding:0;
87
+ border:none;
88
+ width:16px;
89
+ height:16px;
90
+ float:none;
91
+ }
92
+
93
+
94
+ /* Button colors
95
+ -------------------------------------------------------------- */
96
+
97
+ /* Standard */
98
+ button:hover {
99
+ background-color:#dff4ff;
100
+ border:1px solid #c2e1ef;
101
+ color:#336699;
102
+ }
103
+
104
+ /* Positive */
105
+ body .positive {
106
+ color:#529214;
107
+ }
108
+ button.positive:hover {
109
+ background-color:#E6EFC2;
110
+ border:1px solid #C6D880;
111
+ color:#529214;
112
+ }
113
+
114
+ /* Negative */
115
+ body .negative {
116
+ color:#d12f19;
117
+ }
118
+ button.negative:hover {
119
+ background:#fbe3e4;
120
+ border:1px solid #fbc2c4;
121
+ color:#d12f19;
122
+ }
123
+
@@ -0,0 +1,8 @@
1
+ #segform
2
+ %form{:action => '/segment', :method => 'post'}
3
+ %p
4
+ %textarea{:id => 'input', :rows => '15', :cols => '35', :name => 'input'}= @input || '输入要分词的文章'
5
+ %p
6
+ %button.negative{ :type => "submit" } 开始分词
7
+ #segresult
8
+ %p= @result
@@ -0,0 +1,16 @@
1
+ !!! Strict
2
+ %html{ :lang => "en", :"xml:lang" => "en", :xmlns => "http://www.w3.org/1999/xhtml" }
3
+ %head
4
+ %meta{ :content => "text/html; charset=utf-8", :"http-equiv" => "Content-Type" }
5
+ %meta{ :content => "zh_CN", :"http-equiv" => "Content-Language" }
6
+ %title= "Rseg中文分词"
7
+ %link{ :rel => 'stylesheet', :href => '/screen.css', :type => 'text/css', :media => "screen"}
8
+
9
+ %body
10
+ #wrap
11
+ #header
12
+ %h1= "Rseg 中文分词"
13
+ %address.watermark
14
+ #content.condensed= yield
15
+ #footer= "作者: 张元一 <br />EMail:zhangyuanyi#gmail.com"
16
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rseg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuanyi Zhang
@@ -9,14 +9,34 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-29 00:00:00 +08:00
13
- default_executable: rseg
14
- dependencies: []
15
-
12
+ date: 2009-12-01 00:00:00 +08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: haml
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: sinatra
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
16
35
  description: "A Chinese Word Segmentation(\xE4\xB8\xAD\xE6\x96\x87\xE5\x88\x86\xE8\xAF\x8D) routine in pure Ruby"
17
36
  email: zhangyuanyi@gmail.com
18
37
  executables:
19
38
  - rseg
39
+ - rseg_server
20
40
  extensions: []
21
41
 
22
42
  extra_rdoc_files:
@@ -29,7 +49,9 @@ files:
29
49
  - Rakefile
30
50
  - VERSION
31
51
  - bin/rseg
52
+ - bin/rseg_server
32
53
  - dict/dict.hash
54
+ - lib/app.rb
33
55
  - lib/builder/dict.rb
34
56
  - lib/engines/dict.rb
35
57
  - lib/engines/engine.rb
@@ -40,6 +62,9 @@ files:
40
62
  - lib/filters/fullwidth.rb
41
63
  - lib/filters/symbol.rb
42
64
  - lib/rseg.rb
65
+ - public/screen.css
66
+ - views/index.haml
67
+ - views/layout.haml
43
68
  has_rdoc: true
44
69
  homepage: http://github.com/yzhang/rseg
45
70
  licenses: []