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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e03525856433cf951ebf9bb7efd7cf5c7edbfdad6029b447bdfca89f4b022d8
4
- data.tar.gz: 0d3d42dc47afee961fd2e908a4b4ace1b83f97a4bc1df34b6310c987d2460ef8
3
+ metadata.gz: 12a8889fb7704f8233e1d83e029b0ae04565674396d549744e8c5a6d21156b4d
4
+ data.tar.gz: 042ab0e095196c62bc50f66bb9014fd71c93bcf48a815ca711e8c14e147b8a78
5
5
  SHA512:
6
- metadata.gz: 1136b9e2a14ef06badba7298a8ca602efc21f1a54b9b1898ecc11f91ef284ed537bd0304b008d7e09117f6018c59791bed41c6db18bc8e7a9948e851da2c50a5
7
- data.tar.gz: fb893688c572ebce2233456ac31d7e05182381fa5159c1161f5cae1b2cc7f4d73cad8bda0f34449d3123f191b6719414da67eabe37103a6b4e80302de77f3093
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
- TODO
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
 
@@ -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 = /[\s]{0,}\d+[\s]{0,}年[\s]{0,}\d+[\s]{0,}月[\s]{0,}\d+[\s]{0,}[日号][\s]{0,}/u
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 = /\s([(【「《])/
22
- RIGHT_QUOTE_RE = /([)】」》])\s/
22
+ LEFT_QUOTE_RE = /#{SPACE}([(【「《])/
23
+ RIGHT_QUOTE_RE = /([)】」》])#{SPACE}/
23
24
 
24
25
  def format(str)
25
26
  out = str
@@ -13,8 +13,8 @@ class AutoCorrect
13
13
  ]
14
14
 
15
15
  @remove_space_rules = [
16
- /(#{one})\s+(#{other})/u,
17
- /(#{other})\s+(#{one})/u
16
+ /(#{one})#{SPACE}+(#{other})/u,
17
+ /(#{other})#{SPACE}+(#{one})/u
18
18
  ]
19
19
  end
20
20
 
@@ -1,3 +1,3 @@
1
1
  class AutoCorrect
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
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.3.0
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-05-27 00:00:00.000000000 Z
12
+ date: 2020-08-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri