igo 0.1.1 → 0.1.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2595639cb911ec5464d15186707a89ccb04d67699b62e819bba4ffcc06b70f0
4
- data.tar.gz: 49b7ed5a29ea28aa77db905d8997f7d0b671587717382cd8f4396bdab9a011b2
3
+ metadata.gz: e864f1dc86ce2b7164e50d13f42bc10d28b33fa4ae4f271ec912e410d461f697
4
+ data.tar.gz: 6e8ee3d9ac2e39306d2d02b79e9d86291bea4af1559cd7c4faf64bd009d947e3
5
5
  SHA512:
6
- metadata.gz: 2f397f7ff33c578ff04d787605c694bd8a01a831bd34d7007333b560db8b45aae7ae9ddb1bc9c53bff05f4b167709b0e7b7be998d34a9762922a4a0199391b40
7
- data.tar.gz: 231fd1296f291fda60291c72a26e4422b3ada2c29e024a67d572234d85fe352dc96abc28bda3b14f7a81f0a7667e620d290c21a507a8c6f0741bdf9c5feb9453
6
+ metadata.gz: ae7bee63027e8de27766e941f99e38b4775be1fc8bf8aaf5ca454d41bf7d0346ea9eb7e9f502f93ce5e0f1f347ab6e0eb9a2f01f8c6f1ce0e7362108a2813997
7
+ data.tar.gz: 97aa666160536500f5910a8d7c072e5652b435d1d9cecf6a5d5b98211ba45e1e4a76f6831d7cd90ed31fb394074f48962507a9475859a23fde355533a0a76330
data/README.en.md ADDED
@@ -0,0 +1,106 @@
1
+ # 言語 :: Igo
2
+
3
+ [🌏](README.md) | [中文](README.zh.md) | [English](README.en.md) | [日本語](README.ja.md)
4
+
5
+ Support `zh-CN`, `ja-JP`
6
+
7
+ ```ruby
8
+ ja.cut "あー、合成は結合法則を満たすんでしたね"
9
+ #=> ["では", "、", "圏論", "の", "話", "を", "しましょ", "う", "か", "N", "この", "前", "は", "、圏", "について", "紹介 しました"]
10
+
11
+ zh.tag "全世界的无产者,联合起来!", s: true
12
+ #=> "全世界_n 的_uj 无产者_n ,_x 联合_v 起来_v !_x"
13
+
14
+ ```
15
+
16
+ ## Install :: インストール
17
+
18
+ ```cmd
19
+ gem install igo
20
+ ```
21
+
22
+ for use `jisho-api`, `Thulac` in __Python__, you need to install:
23
+
24
+ ```cmd
25
+ pip install jisho-api
26
+
27
+ pip install thulac
28
+
29
+ ```
30
+
31
+ ## 使い方 :: Usage / Ja
32
+
33
+ ```ruby
34
+ require 'igo'
35
+ require 'igo/ja'
36
+
37
+ j = Igo::Ja
38
+
39
+ cutted = j.cut "あー、合成は結合法則を満たすんでしたね"
40
+ #=> ["では", "、", "圏論", "の", "話", "を", "しましょ", "う", "か", "N", "この", "前", "は", "、圏", "について", "紹介 しました"]
41
+
42
+ cutted = j.cut "あー、合成は結合法則を満たすんでしたね", s: true
43
+ #=> "では 、 圏論 の 話 を しましょ う か N この 前 は 、圏 について 紹介しました"
44
+
45
+ ```
46
+
47
+ 下ノ関数は、暫く未完成です、ごめんね:
48
+
49
+ `j.romaji`, `j.kana`, `j.tag`。
50
+
51
+ ## 用法 :: Usage / Zh
52
+
53
+ Lack __Trad-Zh__ :: 暂不支持「正體中文」
54
+
55
+ ```ruby
56
+ require 'igo'
57
+ require 'igo/zh'
58
+ z = Igo::Zh
59
+ ```
60
+
61
+ ### Pinyin :: 拼音
62
+
63
+ ```ruby
64
+ z.pinyin "全世界的无产者,联合起来!"
65
+ #=> ["quan2", "shi4", "jie4", "de", "wu2", "chan3", "zhe3", "lian2", "he2", "qi3", "lai2"]
66
+ z.pinyin "全世界的无产者,联合起来!", s: 1
67
+ #=> "quan2 shi4 jie4 de wu2 chan3 zhe3 lian2 he2 qi3 lai2"
68
+ ```
69
+
70
+ ### seperate word :: 分词
71
+
72
+ ```ruby
73
+ z.cut "全世界的无产者,联合起来!"
74
+ #=> ["全世界", "的", "無產階級", ",", "聯合", "起來", "!"]
75
+ z.cut "全世界的无产者,联合起来!", s: true
76
+ #=> "全世界 的 无产者 ! 联合 起来 !"
77
+ ```
78
+ ### Taging word :: 标注词类
79
+
80
+ 后续可能添加 `by` 关键词指定函数。
81
+
82
+ ```ruby
83
+ z.tag "全世界的无产者,联合起来!"
84
+ #=> [["全世界", "n"], ["的", "uj"], ["无产者", "n"], ["!", "x"], ["联合", "v"], ["起来", "v"], ["!", "x"]]
85
+ z.tag "全世界的无产者,联合起来!", s: true
86
+ #=> "全世界_n 的_uj 无产者_n ,_x 联合_v 起来_v !_x"
87
+ ```
88
+ ### 词频统计
89
+
90
+ ```ruby
91
+ z.freq "全世界的无产者,联合起来!", 5
92
+ #=> [["无产者", 9.96885201925], ["全世界", 6.80147590842], ["联合", 5.64979650728], ["起来", 3.96134044655]]
93
+
94
+ # alias 拼音, 分词, 标记, 词频
95
+
96
+ ```
97
+
98
+ ## LINCENCE :: 协议
99
+
100
+ __MPL 2.0__
101
+
102
+ ## Requires
103
+
104
+ - `jieba-rb`
105
+ - `nokogiri`
106
+ - `open-uri`
data/README.ja.md ADDED
@@ -0,0 +1,105 @@
1
+ # 言語 :: Igo
2
+
3
+ [🌏](README.md) | [中文](README.zh.md) | [English](README.en.md) | [日本語](README.ja.md)
4
+
5
+ Support `zh-CN`, `ja-JP`
6
+
7
+ ```ruby
8
+ ja.cut "あー、合成は結合法則を満たすんでしたね"
9
+ #=> ["では", "、", "圏論", "の", "話", "を", "しましょ", "う", "か", "N", "この", "前", "は", "、圏", "について", "紹介 しました"]
10
+
11
+ zh.tag "全世界的无产者,联合起来!", s: true
12
+ #=> "全世界_n 的_uj 无产者_n ,_x 联合_v 起来_v !_x"
13
+
14
+ ```
15
+
16
+ ## Install :: インストール
17
+
18
+ ```cmd
19
+ gem install igo
20
+ ```
21
+
22
+ __Python__ ノ `Jisho-api`・`Thulac` 使いたいなら、以下の pip がインストール必要です:
23
+
24
+ ```cmd
25
+ pip install jisho-api
26
+
27
+ pip install thulac
28
+ ```
29
+
30
+ ## 使い方 :: Usage / Ja
31
+
32
+ ```ruby
33
+ require 'igo'
34
+ require 'igo/ja'
35
+
36
+ j = Igo::Ja
37
+
38
+ cutted = j.cut "あー、合成は結合法則を満たすんでしたね"
39
+ #=> ["では", "、", "圏論", "の", "話", "を", "しましょ", "う", "か", "N", "この", "前", "は", "、圏", "について", "紹介 しました"]
40
+
41
+ cutted = j.cut "あー、合成は結合法則を満たすんでしたね", s: true
42
+ #=> "では 、 圏論 の 話 を しましょ う か N この 前 は 、圏 について 紹介しました"
43
+
44
+ ```
45
+
46
+ 下ノ関数は、暫く未完成です、ごめんね:
47
+
48
+ `j.romaji`, `j.kana`, `j.tag`。
49
+
50
+ ## 用法 :: Usage / Zh
51
+
52
+ Lack __Trad-Zh__ :: 暂不支持「正體中文」
53
+
54
+ ```ruby
55
+ require 'igo'
56
+ require 'igo/zh'
57
+ z = Igo::Zh
58
+ ```
59
+
60
+ ### Pinyin :: 拼音
61
+
62
+ ```ruby
63
+ z.pinyin "全世界的无产者,联合起来!"
64
+ #=> ["quan2", "shi4", "jie4", "de", "wu2", "chan3", "zhe3", "lian2", "he2", "qi3", "lai2"]
65
+ z.pinyin "全世界的无产者,联合起来!", s: 1
66
+ #=> "quan2 shi4 jie4 de wu2 chan3 zhe3 lian2 he2 qi3 lai2"
67
+ ```
68
+
69
+ ### seperate word :: 分词
70
+
71
+ ```ruby
72
+ z.cut "全世界的无产者,联合起来!"
73
+ #=> ["全世界", "的", "無產階級", ",", "聯合", "起來", "!"]
74
+ z.cut "全世界的无产者,联合起来!", s: true
75
+ #=> "全世界 的 无产者 ! 联合 起来 !"
76
+ ```
77
+ ### Taging word :: 标注词类
78
+
79
+ 后续可能添加 `by` 关键词指定函数。
80
+
81
+ ```ruby
82
+ z.tag "全世界的无产者,联合起来!"
83
+ #=> [["全世界", "n"], ["的", "uj"], ["无产者", "n"], ["!", "x"], ["联合", "v"], ["起来", "v"], ["!", "x"]]
84
+ z.tag "全世界的无产者,联合起来!", s: true
85
+ #=> "全世界_n 的_uj 无产者_n ,_x 联合_v 起来_v !_x"
86
+ ```
87
+ ### 词频统计
88
+
89
+ ```ruby
90
+ z.freq "全世界的无产者,联合起来!", 5
91
+ #=> [["无产者", 9.96885201925], ["全世界", 6.80147590842], ["联合", 5.64979650728], ["起来", 3.96134044655]]
92
+
93
+ # alias 拼音, 分词, 标记, 词频
94
+
95
+ ```
96
+
97
+ ## LINCENCE :: 协议
98
+
99
+ __MPL 2.0__
100
+
101
+ ## Requires
102
+
103
+ - `jieba-rb`
104
+ - `nokogiri`
105
+ - `open-uri`
data/README.md CHANGED
@@ -1,39 +1,106 @@
1
- # Igo
1
+ # 言語 :: Igo
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ [🌏](README.md) | [中文](README.zh.md) | [English](README.en.md) | [日本語](README.ja.md)
4
4
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/igo`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ Support `zh-CN`, `ja-JP`
6
6
 
7
- ## Installation
7
+ ```ruby
8
+ ja.cut "あー、合成は結合法則を満たすんでしたね"
9
+ #=> ["では", "、", "圏論", "の", "話", "を", "しましょ", "う", "か", "N", "この", "前", "は", "、圏", "について", "紹介 しました"]
8
10
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
11
+ zh.tag "全世界的无产者,联合起来!", s: true
12
+ #=> "全世界_n 的_uj 无产者_n ,_x 联合_v 起来_v !_x"
10
13
 
11
- Install the gem and add to the application's Gemfile by executing:
14
+ ```
12
15
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
16
+ ## Install :: インストール
14
17
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
18
+ ```cmd
19
+ gem install igo
20
+ ```
16
21
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
22
+ for use `jisho-api`, `Thulac` in __Python__, you need to install:
18
23
 
19
- ## Usage
24
+ ```cmd
25
+ pip install jisho-api
20
26
 
21
- TODO: Write usage instructions here
27
+ pip install thulac
22
28
 
23
- ## Development
29
+ ```
24
30
 
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
+ ## 使い方 :: Usage / Ja
26
32
 
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
33
+ ```ruby
34
+ require 'igo'
35
+ require 'igo/ja'
28
36
 
29
- ## Contributing
37
+ j = Igo::Ja
30
38
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/igo. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/igo/blob/master/CODE_OF_CONDUCT.md).
39
+ cutted = j.cut "あー、合成は結合法則を満たすんでしたね"
40
+ #=> ["では", "、", "圏論", "の", "話", "を", "しましょ", "う", "か", "N", "この", "前", "は", "、圏", "について", "紹介 しました"]
32
41
 
33
- ## License
42
+ cutted = j.cut "あー、合成は結合法則を満たすんでしたね", s: true
43
+ #=> "では 、 圏論 の 話 を しましょ う か N この 前 は 、圏 について 紹介しました"
34
44
 
35
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
45
+ ```
36
46
 
37
- ## Code of Conduct
47
+ 下ノ関数は、暫く未完成です、ごめんね:
38
48
 
39
- Everyone interacting in the Igo project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/igo/blob/master/CODE_OF_CONDUCT.md).
49
+ `j.romaji`, `j.kana`, `j.tag`。
50
+
51
+ ## 用法 :: Usage / Zh
52
+
53
+ Lack __Trad-Zh__ :: 暂不支持「正體中文」
54
+
55
+ ```ruby
56
+ require 'igo'
57
+ require 'igo/zh'
58
+ z = Igo::Zh
59
+ ```
60
+
61
+ ### Pinyin :: 拼音
62
+
63
+ ```ruby
64
+ z.pinyin "全世界的无产者,联合起来!"
65
+ #=> ["quan2", "shi4", "jie4", "de", "wu2", "chan3", "zhe3", "lian2", "he2", "qi3", "lai2"]
66
+ z.pinyin "全世界的无产者,联合起来!", s: 1
67
+ #=> "quan2 shi4 jie4 de wu2 chan3 zhe3 lian2 he2 qi3 lai2"
68
+ ```
69
+
70
+ ### seperate word :: 分词
71
+
72
+ ```ruby
73
+ z.cut "全世界的无产者,联合起来!"
74
+ #=> ["全世界", "的", "無產階級", ",", "聯合", "起來", "!"]
75
+ z.cut "全世界的无产者,联合起来!", s: true
76
+ #=> "全世界 的 无产者 ! 联合 起来 !"
77
+ ```
78
+ ### Taging word :: 标注词类
79
+
80
+ 后续可能添加 `by` 关键词指定函数。
81
+
82
+ ```ruby
83
+ z.tag "全世界的无产者,联合起来!"
84
+ #=> [["全世界", "n"], ["的", "uj"], ["无产者", "n"], ["!", "x"], ["联合", "v"], ["起来", "v"], ["!", "x"]]
85
+ z.tag "全世界的无产者,联合起来!", s: true
86
+ #=> "全世界_n 的_uj 无产者_n ,_x 联合_v 起来_v !_x"
87
+ ```
88
+ ### 词频统计
89
+
90
+ ```ruby
91
+ z.freq "全世界的无产者,联合起来!", 5
92
+ #=> [["无产者", 9.96885201925], ["全世界", 6.80147590842], ["联合", 5.64979650728], ["起来", 3.96134044655]]
93
+
94
+ # alias 拼音, 分词, 标记, 词频
95
+
96
+ ```
97
+
98
+ ## LINCENCE :: 协议
99
+
100
+ __MPL 2.0__
101
+
102
+ ## Requires
103
+
104
+ - `jieba-rb`
105
+ - `nokogiri`
106
+ - `open-uri`
data/README.zh.md ADDED
@@ -0,0 +1,106 @@
1
+ # 言語 :: Igo
2
+
3
+ [🌏](README.md) | [中文](README.zh.md) | [English](README.en.md) | [日本語](README.ja.md)
4
+
5
+ Support `zh-CN`, `ja-JP`
6
+
7
+ ```ruby
8
+ ja.cut "あー、合成は結合法則を満たすんでしたね"
9
+ #=> ["では", "、", "圏論", "の", "話", "を", "しましょ", "う", "か", "N", "この", "前", "は", "、圏", "について", "紹介 しました"]
10
+
11
+ zh.tag "全世界的无产者,联合起来!", s: true
12
+ #=> "全世界_n 的_uj 无产者_n ,_x 联合_v 起来_v !_x"
13
+
14
+ ```
15
+
16
+ ## Install :: 安装
17
+
18
+ ```cmd
19
+ gem install igo
20
+ ```
21
+
22
+ 要使用 __Python__ 库的 `jisho_api`, `Thulac`,你得先安装...:
23
+
24
+ ```cmd
25
+ pip install jisho-api
26
+
27
+ pip install thulac
28
+
29
+ ```
30
+
31
+ ## 使い方 :: Usage / Ja
32
+
33
+ ```ruby
34
+ require 'igo'
35
+ require 'igo/ja'
36
+
37
+ j = Igo::Ja
38
+
39
+ cutted = j.cut "あー、合成は結合法則を満たすんでしたね"
40
+ #=> ["では", "、", "圏論", "の", "話", "を", "しましょ", "う", "か", "N", "この", "前", "は", "、圏", "について", "紹介 しました"]
41
+
42
+ cutted = j.cut "あー、合成は結合法則を満たすんでしたね", s: true
43
+ #=> "では 、 圏論 の 話 を しましょ う か N この 前 は 、圏 について 紹介しました"
44
+
45
+ ```
46
+
47
+ 下ノ関数は、暫く未完成です、ごめんね:
48
+
49
+ `j.romaji`, `j.kana`, `j.tag`。
50
+
51
+ ## 用法 :: Usage / Zh
52
+
53
+ Lack __Trad-Zh__ :: 暂不支持「正體中文」
54
+
55
+ ```ruby
56
+ require 'igo'
57
+ require 'igo/zh'
58
+ z = Igo::Zh
59
+ ```
60
+
61
+ ### Pinyin :: 拼音
62
+
63
+ ```ruby
64
+ z.pinyin "全世界的无产者,联合起来!"
65
+ #=> ["quan2", "shi4", "jie4", "de", "wu2", "chan3", "zhe3", "lian2", "he2", "qi3", "lai2"]
66
+ z.pinyin "全世界的无产者,联合起来!", s: 1
67
+ #=> "quan2 shi4 jie4 de wu2 chan3 zhe3 lian2 he2 qi3 lai2"
68
+ ```
69
+
70
+ ### seperate word :: 分词
71
+
72
+ ```ruby
73
+ z.cut "全世界的无产者,联合起来!"
74
+ #=> ["全世界", "的", "無產階級", ",", "聯合", "起來", "!"]
75
+ z.cut "全世界的无产者,联合起来!", s: true
76
+ #=> "全世界 的 无产者 ! 联合 起来 !"
77
+ ```
78
+ ### Taging word :: 标注词类
79
+
80
+ 后续可能添加 `by` 关键词指定函数。
81
+
82
+ ```ruby
83
+ z.tag "全世界的无产者,联合起来!"
84
+ #=> [["全世界", "n"], ["的", "uj"], ["无产者", "n"], ["!", "x"], ["联合", "v"], ["起来", "v"], ["!", "x"]]
85
+ z.tag "全世界的无产者,联合起来!", s: true
86
+ #=> "全世界_n 的_uj 无产者_n ,_x 联合_v 起来_v !_x"
87
+ ```
88
+ ### 词频统计
89
+
90
+ ```ruby
91
+ z.freq "全世界的无产者,联合起来!", 5
92
+ #=> [["无产者", 9.96885201925], ["全世界", 6.80147590842], ["联合", 5.64979650728], ["起来", 3.96134044655]]
93
+
94
+ # alias 拼音, 分词, 标记, 词频
95
+
96
+ ```
97
+
98
+ ## LINCENCE :: 协议
99
+
100
+ __MPL 2.0__
101
+
102
+ ## Requires
103
+
104
+ - `jieba-rb`
105
+ - `nokogiri`
106
+ - `open-uri`
data/lib/igo/ja.rb CHANGED
@@ -1,15 +1,17 @@
1
1
  require 'jisho_api'
2
2
  require 'nokogiri'
3
3
  require 'open-uri'
4
-
4
+ require 'uri'
5
+ require 'nagisa'
5
6
 
6
7
  module Igo
7
- module Jisho
8
+ module Ja
8
9
 
9
10
  SEARCH_URL = "https://jisho.org/search/"
10
11
 
11
12
  class << self
12
13
  def cut str, s: false
14
+ str = URI.encode_www_form_component(str)
13
15
  doc = Nokogiri::HTML(URI.open(SEARCH_URL + str).read)
14
16
  cutted = doc.css(".japanese_word__text_wrapper").map{_1.text.strip}
15
17
  s ? cutted.join(" ") : cutted
@@ -20,9 +22,13 @@ module Igo
20
22
  # def kana str
21
23
  # end
22
24
  end
25
+
26
+ def tag str, s: false, ns: 0
27
+
28
+ end
29
+
23
30
  end
24
31
 
25
- Ja = Jisho
26
32
 
27
33
  class << self
28
34
  def 日本語
data/lib/igo/thulac.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'pycall/import'
2
+
3
+ module Thulac
4
+ PyCall.exec("import thulac")
5
+ PyCall.exec("thulac1 = thulac.thulac()")
6
+ end
7
+ class << Thulac
8
+ def cut str, text: false
9
+ text = text ? "True" : "False"
10
+ PyCall.eval(<<-EOF
11
+ thulac1.cut(#{str.inspect}, text=#{text})
12
+ EOF
13
+ )
14
+ end
15
+ end
data/lib/igo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Igo
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.4.1"
5
5
  end
data/lib/igo/zh.rb CHANGED
@@ -3,15 +3,17 @@ require 'ruby_pinyin'
3
3
  module Igo
4
4
  module Zh
5
5
 
6
- Tagging = JiebaRb::Tagging
6
+ Tagging = JiebaRb::Tagging.new
7
7
  Segment = JiebaRb::Segment.new mode: :mix, user_dict: "ext/cppjieba/dict/user.dict.utf8"
8
8
  Keyword = JiebaRb::Keyword.new
9
9
 
10
10
  # @params chinese: String
11
11
  # @returns pinyin_numeraltone: String
12
12
  class << self
13
- def pinyin str
14
- str.each_char.map{PinYin.of_string(_1, :ascii)}
13
+ def pinyin str, s: false
14
+ res = str.each_char.map{PinYin.of_string(_1, :ascii)}.flatten
15
+ s ? res.join(" ") : res
16
+
15
17
  end
16
18
  def pinyin_tonal_s str
17
19
  PinYin.sentence(token, :ascii)
@@ -20,16 +22,28 @@ module Igo
20
22
  PinYin.of_string(token, :ascii)
21
23
  end
22
24
 
23
- def cut str, s: false, tag: false
24
- if tag
25
- s ? Tagging.tag(str).map{_1.to_a.flatten.join("_")}.join(" ") : Tagging.tag(str).map{_1.to_a.flatten}
26
- else
27
- Segment.cut(str)
25
+ def cut str, s: false, tag: false, by: "jieba"
26
+ case by
27
+ when /jieba/
28
+ if tag
29
+ s ? Tagging.tag(str).map{_1.to_a.flatten.join("_")}.join(" ") : Tagging.tag(str).map{_1.to_a.flatten}
30
+ else
31
+ res = Segment.cut(str)
32
+ s ? res.join(" ") : res
33
+ end
34
+ when /thulac/
35
+ Thulac.cut(str, text: s)
28
36
  end
29
37
  end
30
38
 
31
- def tag str, s: false
32
- s ? Tagging.tag(str).map{_1.to_a.flatten.join("_")}.join(" ") : Tagging.tag(str).map{_1.to_a.flatten}
39
+ def tag str, s: false, by: 0
40
+ case by
41
+ when /thu/
42
+ require './thulac'
43
+ Thulac.cut str, text: s
44
+ else
45
+ s ? Tagging.tag(str).map{_1.to_a.flatten.join("_")}.join(" ") : Tagging.tag(str).map{_1.to_a.flatten}
46
+ end
33
47
  end
34
48
 
35
49
  def termfreq string, num
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: igo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - saisui
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-23 00:00:00.000000000 Z
11
+ date: 2023-12-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: It is easy.
14
14
  email:
@@ -22,11 +22,15 @@ files:
22
22
  - CHANGELOG.md
23
23
  - CODE_OF_CONDUCT.md
24
24
  - LICENSE.txt
25
+ - README.en.md
26
+ - README.ja.md
25
27
  - README.md
28
+ - README.zh.md
26
29
  - Rakefile
27
30
  - igo.rb
28
31
  - lib/igo.rb
29
32
  - lib/igo/ja.rb
33
+ - lib/igo/thulac.rb
30
34
  - lib/igo/version.rb
31
35
  - lib/igo/zh.rb
32
36
  - sig/igo.rbs