amakanize 0.0.4 → 0.1.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/CHANGELOG.md +5 -0
- data/README.md +17 -1
- data/amakanize.gemspec +1 -1
- data/lib/amakanize.rb +4 -1
- data/lib/amakanize/author_name.rb +1 -1
- data/lib/amakanize/filters/{trailing_payload_deletion_filter.rb → trailing_author_name_payload_deletion_filter.rb} +1 -1
- data/lib/amakanize/filters/trailing_parentheses_deletion_filter.rb +12 -0
- data/lib/amakanize/filters/trailing_series_name_payload_deletion_filter.rb +16 -0
- data/lib/amakanize/filters/trailing_volume_number_deletion_filter.rb +12 -0
- data/lib/amakanize/series_name.rb +27 -7
- data/lib/amakanize/version.rb +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 168c6f60c07b79637b2dc63f389815d49d4d1f40
|
4
|
+
data.tar.gz: ecc71f57558362d25cd29d8928e1f67ab1a05c7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c25bf5d69fa00d62d7664cebbde9fffb1142f3d009cc9a54876d9fc308be255acad8b8a9ada50039446c2f41ca6260c7da6e926b50a778fe9565bd98f32c549e
|
7
|
+
data.tar.gz: f3c1198712ca786d8ac57d5f6e5c25efbcb3e04aa2e752c05d3da11b8182ef080db6c68a2cc4828aa1e6af9fccccd68b5040c07654df8e3743f296bc4e857b76
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
# Amakanize [](https://travis-ci.org/amakan/amakanize)
|
2
2
|
|
3
|
-
Utilities to canonicalize
|
3
|
+
Utilities to canonicalize series names and author names for [amakan.net](https://amakan.net/).
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
```rb
|
8
|
+
require "amakanize"
|
9
|
+
|
10
|
+
Amakanize::AuthorName.new("ぽんかん(8)").to_s #=> "ぽんかん8"
|
11
|
+
Amakanize::AuthorName.new("ぽんかん8").to_s #=> "ぽんかん8"
|
12
|
+
Amakanize::AuthorName.new("ぽんかん⑧").to_s #=> "ぽんかん8"
|
13
|
+
|
14
|
+
Amaakanize::SeriesName.new("やはり俺の青春ラブコメはまちがっている。4").to_s #=> "やはり俺の青春ラブコメはまちがっている。"
|
15
|
+
Amaakanize::SeriesName.new("ラブライブ! School idol diary ~星空凛~".to_s #=> "ラブライブ! School idol diary"
|
16
|
+
Amaakanize::SeriesName.new("僕だけがいない街 (1) (カドカワコミックス・エース)").to_s #=> "僕だけがいない街"
|
17
|
+
```
|
4
18
|
|
5
19
|
## Installation
|
6
20
|
|
@@ -16,6 +30,8 @@ And then execute:
|
|
16
30
|
bundle
|
17
31
|
```
|
18
32
|
|
33
|
+
Or manually install:
|
34
|
+
|
19
35
|
```sh
|
20
36
|
gem install amakanize
|
21
37
|
```
|
data/amakanize.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.version = Amakanize::VERSION
|
8
8
|
spec.authors = ["r7kamura"]
|
9
9
|
spec.email = ["r7kamura@gmail.com"]
|
10
|
-
spec.summary = "Utilities to canonicalize
|
10
|
+
spec.summary = "Utilities to canonicalize series names and author names."
|
11
11
|
spec.homepage = "https://github.com/amakan/amakanize"
|
12
12
|
spec.license = "MIT"
|
13
13
|
|
data/lib/amakanize.rb
CHANGED
@@ -6,6 +6,9 @@ require "amakanize/filters/parentheses_deletion_filter"
|
|
6
6
|
require "amakanize/filters/role_name_deletion_filter"
|
7
7
|
require "amakanize/filters/space_deletion_filter"
|
8
8
|
require "amakanize/filters/strip_filter"
|
9
|
-
require "amakanize/filters/
|
9
|
+
require "amakanize/filters/trailing_author_name_payload_deletion_filter"
|
10
|
+
require "amakanize/filters/trailing_volume_number_deletion_filter"
|
11
|
+
require "amakanize/filters/trailing_parentheses_deletion_filter"
|
12
|
+
require "amakanize/filters/trailing_series_name_payload_deletion_filter"
|
10
13
|
require "amakanize/series_name"
|
11
14
|
require "amakanize/version"
|
@@ -8,7 +8,7 @@ module Amakanize
|
|
8
8
|
::Amakanize::Filters::NormalizationFilter.new,
|
9
9
|
::Amakanize::Filters::ParenthesesDeletionFilter.new,
|
10
10
|
::Amakanize::Filters::RoleNameDeletionFilter.new,
|
11
|
-
::Amakanize::Filters::
|
11
|
+
::Amakanize::Filters::TrailingAuthorNamePayloadDeletionFilter.new,
|
12
12
|
::Amakanize::Filters::SpaceDeletionFilter.new,
|
13
13
|
]
|
14
14
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Amakanize
|
2
|
+
module Filters
|
3
|
+
class TrailingParenthesesDeletionFilter < BaseFilter
|
4
|
+
# @note Override
|
5
|
+
# @param string [String] e.g. `"魔法使いの嫁 通常版 4 (BLADE COMICS)"`
|
6
|
+
# @return [String] e.g. `"魔法使いの嫁 通常版 4"`
|
7
|
+
def call(string)
|
8
|
+
string.gsub(/\s*[\((〈《【「『【[\[〔{\{«‹〘〚].*/, "").gsub(/\s*~.+~\z/, "")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Amakanize
|
2
|
+
module Filters
|
3
|
+
class TrailingSeriesNamePayloadDeletionFilter < BaseFilter
|
4
|
+
PAYLOADS = %w(
|
5
|
+
通常版
|
6
|
+
)
|
7
|
+
|
8
|
+
# @note Override
|
9
|
+
# @param string [String] e.g. `"魔法使いの嫁 通常版"`
|
10
|
+
# @return [String] e.g. `"魔法使いの嫁"`
|
11
|
+
def call(string)
|
12
|
+
string.gsub(/\s+#{::Regexp.union(PAYLOADS)}\z/, "")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Amakanize
|
2
|
+
module Filters
|
3
|
+
class TrailingVolumeNumberDeletionFilter < BaseFilter
|
4
|
+
# @note Override
|
5
|
+
# @param string [String] e.g. `"やはり俺の青春ラブコメはまちがっている。4"`
|
6
|
+
# @return [String] e.g. `"やはり俺の青春ラブコメはまちがっている。"`
|
7
|
+
def call(string)
|
8
|
+
string.gsub(/\s*第?[\dviVI1-9①②③④⑤⑥⑦⑧⑨⑩]+巻?\z/, "")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,19 +1,39 @@
|
|
1
1
|
module Amakanize
|
2
2
|
class SeriesName
|
3
|
+
class << self
|
4
|
+
# @return [Array<Amakan::Filters::BaseFilter>]
|
5
|
+
def filters
|
6
|
+
@filters ||= [
|
7
|
+
::Amakanize::Filters::HtmlUnescapeFilter.new,
|
8
|
+
::Amakanize::Filters::NormalizationFilter.new,
|
9
|
+
::Amakanize::Filters::TrailingParenthesesDeletionFilter.new,
|
10
|
+
::Amakanize::Filters::TrailingVolumeNumberDeletionFilter.new,
|
11
|
+
::Amakanize::Filters::TrailingSeriesNamePayloadDeletionFilter.new,
|
12
|
+
]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
3
16
|
# @param raw [String]
|
4
17
|
def initialize(raw)
|
5
18
|
@raw = raw
|
6
19
|
end
|
7
20
|
|
21
|
+
# @note Override
|
22
|
+
# def to_s
|
23
|
+
# @raw
|
24
|
+
# .gsub(/[[:space:]]*[\((〈《【「『【[\[〔{\{«‹〘〚].*/, "")
|
25
|
+
# .gsub(/[[:space:]]*通常版/, "")
|
26
|
+
# .gsub(/[[:space:]]+[1-9\d①②③④⑤⑥⑦⑧⑨⑩].*/, "")
|
27
|
+
# .gsub(/[[:space:]]*[1-9\d①②③④⑤⑥⑦⑧⑨⑩]+巻?\z/, "")
|
28
|
+
# .gsub(/[[:space:]]*~.+~/, "")
|
29
|
+
# .gsub(/\A[[:space:]]+|[[:space:]]+\z/, "")
|
30
|
+
# end
|
31
|
+
|
8
32
|
# @note Override
|
9
33
|
def to_s
|
10
|
-
@raw
|
11
|
-
.
|
12
|
-
|
13
|
-
.gsub(/[[:space:]]+[1-9\d①②③④⑤⑥⑦⑧⑨⑩].*/, "")
|
14
|
-
.gsub(/[[:space:]]*[1-9\d①②③④⑤⑥⑦⑧⑨⑩]+巻?\z/, "")
|
15
|
-
.gsub(/[[:space:]]*~.+~/, "")
|
16
|
-
.gsub(/\A[[:space:]]+|[[:space:]]+\z/, "")
|
34
|
+
self.class.filters.inject(@raw) do |result, filter|
|
35
|
+
filter.call(result)
|
36
|
+
end
|
17
37
|
end
|
18
38
|
end
|
19
39
|
end
|
data/lib/amakanize/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amakanize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- r7kamura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -93,7 +93,10 @@ files:
|
|
93
93
|
- lib/amakanize/filters/role_name_deletion_filter.rb
|
94
94
|
- lib/amakanize/filters/space_deletion_filter.rb
|
95
95
|
- lib/amakanize/filters/strip_filter.rb
|
96
|
-
- lib/amakanize/filters/
|
96
|
+
- lib/amakanize/filters/trailing_author_name_payload_deletion_filter.rb
|
97
|
+
- lib/amakanize/filters/trailing_parentheses_deletion_filter.rb
|
98
|
+
- lib/amakanize/filters/trailing_series_name_payload_deletion_filter.rb
|
99
|
+
- lib/amakanize/filters/trailing_volume_number_deletion_filter.rb
|
97
100
|
- lib/amakanize/series_name.rb
|
98
101
|
- lib/amakanize/version.rb
|
99
102
|
homepage: https://github.com/amakan/amakanize
|
@@ -119,6 +122,6 @@ rubyforge_project:
|
|
119
122
|
rubygems_version: 2.4.5
|
120
123
|
signing_key:
|
121
124
|
specification_version: 4
|
122
|
-
summary: Utilities to canonicalize
|
125
|
+
summary: Utilities to canonicalize series names and author names.
|
123
126
|
test_files: []
|
124
127
|
has_rdoc:
|