auto-correct 0.2.2 → 0.3.0
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 +4 -4
- data/README.md +15 -5
- data/lib/auto-correct.rb +1 -1
- data/lib/auto-correct/format.rb +9 -7
- data/lib/auto-correct/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e03525856433cf951ebf9bb7efd7cf5c7edbfdad6029b447bdfca89f4b022d8
|
4
|
+
data.tar.gz: 0d3d42dc47afee961fd2e908a4b4ace1b83f97a4bc1df34b6310c987d2460ef8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
3
|
+
Automatically add whitespace between CJK (Chinese, Japanese, Korean) and half-width characters (alphabetical letters, numerical digits and symbols).
|
4
4
|
|
5
|
-
|
5
|
+
中文、日语、韩语 + 英文混排自动纠正补充空格,此方式已在 Ruby China 使用多年,支持 HTML 处理。
|
6
6
|
|
7
7
|
[](https://rubygems.org/gems/auto-correct) [](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)
|
14
|
-
- [go-auto-correct](https://github.com/huacnlee/go-auto-correct)
|
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.
|
data/lib/auto-correct.rb
CHANGED
data/lib/auto-correct/format.rb
CHANGED
@@ -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
|
6
|
+
rule "#{CJK}", '[0-9a-zA-Z]', space: true, reverse: true
|
5
7
|
|
6
8
|
# SpecialSymbol
|
7
|
-
rule
|
8
|
-
rule
|
9
|
-
rule '[’”\]\)!%]',
|
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
|
14
|
-
rule '[‘“【「《]',
|
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 = /([
|
20
|
+
DASH_HAN_RE = /([#{CJK})】」》”’])([\-]+)([#{CJK}(【「《“‘])/
|
19
21
|
LEFT_QUOTE_RE = /\s([(【「《])/
|
20
22
|
RIGHT_QUOTE_RE = /([)】」》])\s/
|
21
23
|
|
data/lib/auto-correct/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2020-05-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|