auto-correct 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -1
- data/lib/auto-correct/format.rb +4 -3
- data/lib/auto-correct/strategery.rb +2 -2
- 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: 12a8889fb7704f8233e1d83e029b0ae04565674396d549744e8c5a6d21156b4d
|
4
|
+
data.tar.gz: 042ab0e095196c62bc50f66bb9014fd71c93bcf48a815ca711e8c14e147b8a78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 167d2641cf2f49f7b562e96d1c6ac38c27c8d212f07af3a42fc210fab4297635f1e82a67bc0e56026a984c3d4ff15b358bf0efe0d004aecbd6071fb414a59868
|
7
|
+
data.tar.gz: 4a2c9591624888b1ae8d1c5ece57a85a06d38f4f533e265fb0ac011093dfff244d549406762a01a2d87f523cafa7fa56960551fec06d6ccb6398b335f0268cbe
|
data/README.md
CHANGED
@@ -57,7 +57,32 @@ AutoCorrect.format_html("<div><p>长桥LongBridge App下载</p><p>最新版本1.
|
|
57
57
|
|
58
58
|
## Benchmark
|
59
59
|
|
60
|
-
|
60
|
+
Run `rake bench` to test:
|
61
|
+
|
62
|
+
```
|
63
|
+
Warming up --------------------------------------
|
64
|
+
format 50 chars 1.886k i/100ms
|
65
|
+
format 100 chars 1.060k i/100ms
|
66
|
+
format 400 chars 342.000 i/100ms
|
67
|
+
format_html 85.000 i/100ms
|
68
|
+
Calculating -------------------------------------
|
69
|
+
format 50 chars 18.842k (± 1.5%) i/s - 94.300k in 5.005815s
|
70
|
+
format 100 chars 10.357k (± 1.8%) i/s - 51.940k in 5.016770s
|
71
|
+
format 400 chars 3.336k (± 2.2%) i/s - 16.758k in 5.026230s
|
72
|
+
format_html 839.761 (± 2.1%) i/s - 4.250k in 5.063225s
|
73
|
+
```
|
74
|
+
|
75
|
+
| Total chars | Duration |
|
76
|
+
| ----- | ------- |
|
77
|
+
| 50 | 0.33 ms |
|
78
|
+
| 100 | 0.60 ms |
|
79
|
+
| 400 | 2 ms |
|
80
|
+
|
81
|
+
### FormatHTML
|
82
|
+
|
83
|
+
| Total chars | Duration |
|
84
|
+
| ----- | ------- |
|
85
|
+
| 2K | 7 ms |
|
61
86
|
|
62
87
|
## Use cases
|
63
88
|
|
data/lib/auto-correct/format.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
class AutoCorrect
|
2
2
|
CJK = '\p{Han}|\p{Hangul}|\p{Hanunoo}|\p{Katakana}|\p{Hiragana}|\p{Bopomofo}'
|
3
|
+
SPACE = "[ ]"
|
3
4
|
|
4
5
|
# rubocop:disable Style/StringLiterals
|
5
6
|
# EnglishLetter
|
@@ -16,10 +17,10 @@ class AutoCorrect
|
|
16
17
|
rule '[‘“【「《]', %r([\w#{CJK}]), reverse: true
|
17
18
|
|
18
19
|
class << self
|
19
|
-
FULLDATE_RE =
|
20
|
+
FULLDATE_RE = /#{SPACE}{0,}\d+#{SPACE}{0,}年#{SPACE}{0,}\d+#{SPACE}{0,}月#{SPACE}{0,}\d+#{SPACE}{0,}[日号]#{SPACE}{0,}/u
|
20
21
|
DASH_HAN_RE = /([#{CJK})】」》”’])([\-]+)([#{CJK}(【「《“‘])/
|
21
|
-
LEFT_QUOTE_RE =
|
22
|
-
RIGHT_QUOTE_RE = /([)】」》])
|
22
|
+
LEFT_QUOTE_RE = /#{SPACE}([(【「《])/
|
23
|
+
RIGHT_QUOTE_RE = /([)】」》])#{SPACE}/
|
23
24
|
|
24
25
|
def format(str)
|
25
26
|
out = str
|
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.3.
|
4
|
+
version: 0.3.1
|
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-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|