auto-correct 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6cfd0f9b3b7e5735833941146fc8ffbc0188bf8efa6a1712057c52701f60a1ae
4
- data.tar.gz: 344f28dd964417548579d7674b7132f341d96767eb67f4bcc623fa405249bd04
3
+ metadata.gz: 7e03525856433cf951ebf9bb7efd7cf5c7edbfdad6029b447bdfca89f4b022d8
4
+ data.tar.gz: 0d3d42dc47afee961fd2e908a4b4ace1b83f97a4bc1df34b6310c987d2460ef8
5
5
  SHA512:
6
- metadata.gz: 11a98b651910622f594359372211e3d87fed949c0a099cc0d2f286bb009f0e719ddf6ffa920ed02cc6893a1f6d3827b57a4f030150a1f83e53cd5a48dbf8043f
7
- data.tar.gz: 3ab589612ae16edf4eb08ef9156c3b4025e3caf13b96e5497f739e11813d9011b37b2943f5b72a0afc7678d58173990f29c9eef8a7f181f08ec82749f40504c4
6
+ metadata.gz: 1136b9e2a14ef06badba7298a8ca602efc21f1a54b9b1898ecc11f91ef284ed537bd0304b008d7e09117f6018c59791bed41c6db18bc8e7a9948e851da2c50a5
7
+ data.tar.gz: fb893688c572ebce2233456ac31d7e05182381fa5159c1161f5cae1b2cc7f4d73cad8bda0f34449d3123f191b6719414da67eabe37103a6b4e80302de77f3093
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # auto-correct
2
2
 
3
- Automatically add spaces between Chinese and English words.
3
+ Automatically add whitespace between CJK (Chinese, Japanese, Korean) and half-width characters (alphabetical letters, numerical digits and symbols).
4
4
 
5
- 中文英文混排自动纠正补充空格,此方式已在 Ruby China 使用多年,支持 HTML 处理。
5
+ 中文、日语、韩语 + 英文混排自动纠正补充空格,此方式已在 Ruby China 使用多年,支持 HTML 处理。
6
6
 
7
7
  [![Gem Version](https://badge.fury.io/rb/auto-correct.svg)](https://rubygems.org/gems/auto-correct) [![Build
8
8
  Status](https://api.travis-ci.org/huacnlee/auto-correct.svg?branch=master&.svg)](http://travis-ci.org/huacnlee/auto-correct)
@@ -10,12 +10,13 @@ Status](https://api.travis-ci.org/huacnlee/auto-correct.svg?branch=master&.svg)]
10
10
 
11
11
  ## Other implements
12
12
 
13
- - [auto-correct](https://github.com/huacnlee/auto-correct) - Ruby
14
- - [go-auto-correct](https://github.com/huacnlee/go-auto-correct) - Go
13
+ - Ruby - [auto-correct](https://github.com/huacnlee/auto-correct).
14
+ - Go - [go-auto-correct](https://github.com/huacnlee/go-auto-correct).
15
+ - Rust - [auto-correct.rs](https://github.com/huacnlee/auto-correct.rs).
15
16
 
16
17
  ## Features
17
18
 
18
- - Auto add spacings between Chinese and English words.
19
+ - Auto add spacings between CJK (Chinese) and English words.
19
20
  - HTML content support.
20
21
 
21
22
  [Examples](https://github.com/huacnlee/auto-correct/blob/master/test/format_test.rb)
@@ -36,6 +37,15 @@ AutoCorrect.format("于3月10日开始")
36
37
 
37
38
  AutoCorrect.format("包装日期为2013年3月10日")
38
39
  # => "包装日期为2013年3月10日"
40
+
41
+ AutoCorrect.format("生产环境中使用Ruby")
42
+ # => "生产环境中使用 Ruby"
43
+
44
+ AutoCorrect.format("本番環境でRubyを使用する")
45
+ # => "本番環境で Ruby を使用する"
46
+
47
+ AutoCorrect.format("프로덕션환경에서Ruby사용")
48
+ # => "프로덕션환경에서 Ruby 사용"
39
49
  ```
40
50
 
41
51
  `AutoCorrect.format_html` method for HTML content.
@@ -8,4 +8,4 @@ require "auto-correct/version"
8
8
  class AutoCorrect
9
9
  end
10
10
 
11
- String.send :include, AutoCorrect::String
11
+ String.send :include, AutoCorrect::String
@@ -1,21 +1,23 @@
1
1
  class AutoCorrect
2
+ CJK = '\p{Han}|\p{Hangul}|\p{Hanunoo}|\p{Katakana}|\p{Hiragana}|\p{Bopomofo}'
3
+
2
4
  # rubocop:disable Style/StringLiterals
3
5
  # EnglishLetter
4
- rule '\p{Han}', '[0-9a-zA-Z]', space: true, reverse: true
6
+ rule "#{CJK}", '[0-9a-zA-Z]', space: true, reverse: true
5
7
 
6
8
  # SpecialSymbol
7
- rule '\p{Han}', '[\|+$@#*]', space: true, reverse: true
8
- rule '\p{Han}', '[\[\(‘“]', space: true
9
- rule '[’”\]\)!%]', '\p{Han}', space: true
9
+ rule "#{CJK}", '[\|+$@#*]', space: true, reverse: true
10
+ rule "#{CJK}", '[\[\(‘“]', space: true
11
+ rule '[’”\]\)!%]', "#{CJK}", space: true
10
12
  rule '[”\]\)!]', '[a-zA-Z0-9]+', space: true
11
13
 
12
14
  # FullwidthPunctuation
13
- rule '[\w\p{Han}]', '[,。!?:;」》】”’]', reverse: true
14
- rule '[‘“【「《]', '[\w\p{Han}]', reverse: true
15
+ rule %r([\w#{CJK}]), '[,。!?:;」》】”’]', reverse: true
16
+ rule '[‘“【「《]', %r([\w#{CJK}]), reverse: true
15
17
 
16
18
  class << self
17
19
  FULLDATE_RE = /[\s]{0,}\d+[\s]{0,}年[\s]{0,}\d+[\s]{0,}月[\s]{0,}\d+[\s]{0,}[日号][\s]{0,}/u
18
- DASH_HAN_RE = /([\p{Han})】」》”’])([\-]+)([\p{Han}(【「《“‘])/
20
+ DASH_HAN_RE = /([#{CJK})】」》”’])([\-]+)([#{CJK}(【「《“‘])/
19
21
  LEFT_QUOTE_RE = /\s([(【「《])/
20
22
  RIGHT_QUOTE_RE = /([)】」》])\s/
21
23
 
@@ -1,3 +1,3 @@
1
1
  class AutoCorrect
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto-correct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luikore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-03-06 00:00:00.000000000 Z
12
+ date: 2020-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri