amakanize 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/release.yml +23 -0
- data/.github/workflows/bump-request.yml +26 -0
- data/.github/workflows/github-label-sync.yml +18 -0
- data/.github/workflows/release.yml +12 -0
- data/.github/workflows/test.yml +27 -0
- data/.gitignore +0 -1
- data/.rubocop.yml +3 -73
- data/Gemfile +7 -1
- data/Gemfile.lock +58 -0
- data/README.md +2 -4
- data/Rakefile +10 -3
- data/amakanize.gemspec +13 -14
- data/lib/amakanize/author_name.rb +4 -2
- data/lib/amakanize/author_names.rb +5 -5
- data/lib/amakanize/book_position.rb +4 -2
- data/lib/amakanize/filterable.rb +3 -1
- data/lib/amakanize/filters/base_filter.rb +2 -0
- data/lib/amakanize/filters/book_position_at_end_detection_filter.rb +8 -8
- data/lib/amakanize/filters/book_position_clearing_filter.rb +5 -5
- data/lib/amakanize/filters/book_position_in_bracket_detection_filter.rb +8 -8
- data/lib/amakanize/filters/book_position_in_words_detection_filter.rb +8 -8
- data/lib/amakanize/filters/book_position_number_canonicalization_filter.rb +5 -5
- data/lib/amakanize/filters/brackets_normalization_filter.rb +4 -2
- data/lib/amakanize/filters/continuous_spaces_normalization_filter.rb +4 -2
- data/lib/amakanize/filters/dash_between_alphabets_normalization_filter.rb +4 -2
- data/lib/amakanize/filters/html_unescape_filter.rb +5 -3
- data/lib/amakanize/filters/hyphen_minus_normalization_filter.rb +4 -2
- data/lib/amakanize/filters/normalization_filter.rb +4 -2
- data/lib/amakanize/filters/obvious_volume_number_deletion_filter.rb +7 -5
- data/lib/amakanize/filters/parentheses_deletion_filter.rb +4 -2
- data/lib/amakanize/filters/role_name_deletion_filter.rb +9 -7
- data/lib/amakanize/filters/space_between_exclamation_and_bracket_deletion_filter.rb +4 -2
- data/lib/amakanize/filters/space_deletion_filter.rb +4 -2
- data/lib/amakanize/filters/spaces_between_exclamations_deletion_filter.rb +4 -2
- data/lib/amakanize/filters/strip_filter.rb +4 -2
- data/lib/amakanize/filters/trailing_author_name_payload_deletion_filter.rb +6 -4
- data/lib/amakanize/filters/trailing_dash_deletion_filter.rb +6 -4
- data/lib/amakanize/filters/trailing_double_parentheses_singlization_filter.rb +6 -4
- data/lib/amakanize/filters/trailing_parentheses_deletion_filter.rb +5 -5
- data/lib/amakanize/filters/trailing_series_name_payload_deletion_filter.rb +5 -3
- data/lib/amakanize/filters/trailing_symbol_deletion_filter.rb +6 -4
- data/lib/amakanize/filters/trailing_volume_number_deletion_filter.rb +5 -5
- data/lib/amakanize/filters/video_position_detection_filter.rb +10 -9
- data/lib/amakanize/filters/video_position_number_conversion_filter.rb +115 -113
- data/lib/amakanize/series_name.rb +4 -2
- data/lib/amakanize/version.rb +3 -1
- data/lib/amakanize/video_position.rb +4 -2
- data/lib/amakanize.rb +41 -39
- metadata +11 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16678421179e2e75b6b7d4f9789f4e33a9f458f3b4b9d96dc2fed4f642d5e907
|
4
|
+
data.tar.gz: 52989b7b4056e9943f6f0e45e5bbe1b44b949cc23b714799d2dc59fedd698fd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cd4c607e385326e3967d1397daf0b504d0832e41beb67048deee97d4cf6b8b392effdc083a87a86dee247ee6c71aa9e8c12308e62b9307142c3a78bdc4d2a01
|
7
|
+
data.tar.gz: 10a56038359bd17b023099449822dacea75a78f3a059c4a816c5babd0a3973246976ab5c179d286f455327495733f9c4e3db33afe9663c69d934e446bcbd915a
|
data/.github/release.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
changelog:
|
2
|
+
categories:
|
3
|
+
- title: Added
|
4
|
+
labels:
|
5
|
+
- add
|
6
|
+
- title: Changed
|
7
|
+
labels:
|
8
|
+
- change
|
9
|
+
- title: Deprecated
|
10
|
+
labels:
|
11
|
+
- deprecate
|
12
|
+
- title: Fixed
|
13
|
+
labels:
|
14
|
+
- fix
|
15
|
+
- title: Removed
|
16
|
+
labels:
|
17
|
+
- remove
|
18
|
+
- title: Security
|
19
|
+
labels:
|
20
|
+
- security
|
21
|
+
- title: Others
|
22
|
+
labels:
|
23
|
+
- "*"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: bump-request
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch:
|
5
|
+
inputs:
|
6
|
+
version:
|
7
|
+
description: Version to change to.
|
8
|
+
required: true
|
9
|
+
type: string
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
run:
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v3
|
16
|
+
- name: Set up Ruby
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: 3.1.2
|
20
|
+
bundler-cache: true
|
21
|
+
- uses: r7kamura/bump-request@v0
|
22
|
+
with:
|
23
|
+
command: |
|
24
|
+
sed -i -r 's/([0-9]+\.[0-9]+\.[0-9]+)/${{ inputs.version }}/' lib/*/version.rb
|
25
|
+
bundle install
|
26
|
+
version: ${{ inputs.version }}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: github-label-sync
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
paths:
|
8
|
+
- .github/workflows/github-label-sync.yml
|
9
|
+
workflow_dispatch:
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
build:
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
steps:
|
15
|
+
- uses: r7kamura/github-label-sync-action@v0
|
16
|
+
with:
|
17
|
+
source_path: labels-keepachangelog.yml
|
18
|
+
source_repository: r7kamura/github-label-presets
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: test
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
pull_request:
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
name: Ruby ${{ matrix.ruby }}
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
ruby:
|
16
|
+
- '2.7'
|
17
|
+
- '3.1'
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v2
|
21
|
+
- name: Set up Ruby
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
25
|
+
bundler-cache: true
|
26
|
+
- name: Run the default task
|
27
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,84 +1,14 @@
|
|
1
1
|
AllCops:
|
2
|
-
|
3
|
-
- db/**/*
|
4
|
-
- node_modules/**/*
|
5
|
-
- vendor/**/*
|
6
|
-
TargetRubyVersion: 2.2
|
2
|
+
TargetRubyVersion: 2.7
|
7
3
|
|
8
|
-
|
4
|
+
Layout/LineLength:
|
9
5
|
Enabled: false
|
10
6
|
|
11
|
-
|
12
|
-
Enabled: false
|
13
|
-
|
14
|
-
Lint/UnusedBlockArgument:
|
15
|
-
Enabled: false
|
16
|
-
|
17
|
-
Lint/UnusedMethodArgument:
|
18
|
-
Enabled: false
|
19
|
-
|
20
|
-
Metrics/AbcSize:
|
21
|
-
Enabled: false
|
22
|
-
|
23
|
-
Metrics/ClassLength:
|
24
|
-
Enabled: false
|
25
|
-
|
26
|
-
Metrics/CyclomaticComplexity:
|
27
|
-
Enabled: false
|
28
|
-
|
29
|
-
Metrics/LineLength:
|
30
|
-
Enabled: false
|
31
|
-
|
32
|
-
Metrics/MethodLength:
|
33
|
-
Enabled: false
|
34
|
-
|
35
|
-
Metrics/ParameterLists:
|
36
|
-
Enabled: false
|
37
|
-
|
38
|
-
Metrics/PerceivedComplexity:
|
39
|
-
Max: 10
|
40
|
-
|
41
|
-
Style/AccessModifierIndentation:
|
7
|
+
Metrics:
|
42
8
|
Enabled: false
|
43
9
|
|
44
10
|
Style/Documentation:
|
45
11
|
Enabled: false
|
46
12
|
|
47
|
-
Style/DoubleNegation:
|
48
|
-
Enabled: false
|
49
|
-
|
50
|
-
Style/GuardClause:
|
51
|
-
Enabled: false
|
52
|
-
|
53
|
-
Style/IfUnlessModifier:
|
54
|
-
Enabled: false
|
55
|
-
|
56
13
|
Style/MultilineBlockChain:
|
57
14
|
Enabled: false
|
58
|
-
|
59
|
-
Style/MultilineMethodCallIndentation:
|
60
|
-
Enabled: false
|
61
|
-
|
62
|
-
Style/MutableConstant:
|
63
|
-
Enabled: false
|
64
|
-
|
65
|
-
Style/Next:
|
66
|
-
Enabled: false
|
67
|
-
|
68
|
-
Style/PercentLiteralDelimiters:
|
69
|
-
Enabled: false
|
70
|
-
|
71
|
-
Style/PredicateName:
|
72
|
-
Enabled: false
|
73
|
-
|
74
|
-
Style/SpaceAroundOperators:
|
75
|
-
Enabled: false
|
76
|
-
|
77
|
-
Style/StringLiterals:
|
78
|
-
EnforcedStyle: double_quotes
|
79
|
-
|
80
|
-
Style/TrailingCommaInArguments:
|
81
|
-
Enabled: false
|
82
|
-
|
83
|
-
Style/TrailingCommaInLiteral:
|
84
|
-
Enabled: false
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
amakanize (0.8.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
diff-lcs (1.5.0)
|
11
|
+
json (2.6.2)
|
12
|
+
parallel (1.22.1)
|
13
|
+
parser (3.1.3.0)
|
14
|
+
ast (~> 2.4.1)
|
15
|
+
rainbow (3.1.1)
|
16
|
+
rake (13.0.6)
|
17
|
+
regexp_parser (2.6.1)
|
18
|
+
rexml (3.2.5)
|
19
|
+
rspec (3.12.0)
|
20
|
+
rspec-core (~> 3.12.0)
|
21
|
+
rspec-expectations (~> 3.12.0)
|
22
|
+
rspec-mocks (~> 3.12.0)
|
23
|
+
rspec-core (3.12.0)
|
24
|
+
rspec-support (~> 3.12.0)
|
25
|
+
rspec-expectations (3.12.0)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.12.0)
|
28
|
+
rspec-mocks (3.12.0)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.12.0)
|
31
|
+
rspec-support (3.12.0)
|
32
|
+
rubocop (1.39.0)
|
33
|
+
json (~> 2.3)
|
34
|
+
parallel (~> 1.10)
|
35
|
+
parser (>= 3.1.2.1)
|
36
|
+
rainbow (>= 2.2.2, < 4.0)
|
37
|
+
regexp_parser (>= 1.8, < 3.0)
|
38
|
+
rexml (>= 3.2.5, < 4.0)
|
39
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
40
|
+
ruby-progressbar (~> 1.7)
|
41
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
42
|
+
rubocop-ast (1.23.0)
|
43
|
+
parser (>= 3.1.1.0)
|
44
|
+
ruby-progressbar (1.11.0)
|
45
|
+
unicode-display_width (2.3.0)
|
46
|
+
|
47
|
+
PLATFORMS
|
48
|
+
x86_64-linux
|
49
|
+
|
50
|
+
DEPENDENCIES
|
51
|
+
amakanize!
|
52
|
+
bundler
|
53
|
+
rake
|
54
|
+
rspec
|
55
|
+
rubocop
|
56
|
+
|
57
|
+
BUNDLED WITH
|
58
|
+
2.3.26
|
data/README.md
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
# Amakanize
|
2
2
|
|
3
|
-
[![
|
4
|
-
[![Gem Version](https://badge.fury.io/rb/amakanize.svg)](https://rubygems.org/gems/amakanize)
|
5
|
-
[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/github/amakan/amakanize)
|
3
|
+
[![test](https://github.com/amakan/amakanize/actions/workflows/test.yml/badge.svg)](https://github.com/amakan/amakanize/actions/workflows/test.yml)
|
6
4
|
|
7
|
-
Utilities to canonicalize names
|
5
|
+
Utilities to canonicalize Japanese comic series names and author names.
|
8
6
|
|
9
7
|
## Installation
|
10
8
|
|
data/Rakefile
CHANGED
@@ -1,5 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
3
5
|
|
4
6
|
RSpec::Core::RakeTask.new(:spec)
|
5
|
-
|
7
|
+
|
8
|
+
require 'rubocop/rake_task'
|
9
|
+
|
10
|
+
RuboCop::RakeTask.new
|
11
|
+
|
12
|
+
task default: %i[spec rubocop]
|
data/amakanize.gemspec
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require
|
5
|
+
require 'amakanize/version'
|
4
6
|
|
5
7
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
8
|
+
spec.name = 'amakanize'
|
7
9
|
spec.version = Amakanize::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
10
|
-
spec.summary =
|
11
|
-
spec.homepage =
|
12
|
-
spec.license =
|
10
|
+
spec.authors = ['Ryo Nakamura']
|
11
|
+
spec.email = ['r7kamura@gmail.com']
|
12
|
+
spec.summary = 'Utilities to canonicalize Japanese comic series names and author names.'
|
13
|
+
spec.homepage = 'https://github.com/amakan/amakanize'
|
14
|
+
spec.license = 'MIT'
|
13
15
|
|
14
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
15
|
-
spec.require_paths = [
|
16
|
-
spec.required_ruby_version =
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
spec.required_ruby_version = '>= 2.7'
|
17
19
|
|
18
|
-
spec.add_development_dependency
|
19
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
20
|
-
spec.add_development_dependency "rspec", "3.5.0"
|
21
|
-
spec.add_development_dependency "rubocop", "0.44.1"
|
20
|
+
spec.add_development_dependency 'bundler'
|
22
21
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'amakanize/filterable'
|
2
4
|
|
3
5
|
module Amakanize
|
4
6
|
class AuthorName
|
@@ -14,7 +16,7 @@ module Amakanize
|
|
14
16
|
::Amakanize::Filters::ParenthesesDeletionFilter,
|
15
17
|
::Amakanize::Filters::RoleNameDeletionFilter,
|
16
18
|
::Amakanize::Filters::TrailingAuthorNamePayloadDeletionFilter,
|
17
|
-
::Amakanize::Filters::SpaceDeletionFilter
|
19
|
+
::Amakanize::Filters::SpaceDeletionFilter
|
18
20
|
]
|
19
21
|
end
|
20
22
|
end
|
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Amakanize
|
2
4
|
class AuthorNames
|
3
5
|
include ::Enumerable
|
4
6
|
|
5
|
-
AUTHOR_NAME_SEPARATORS = %w
|
7
|
+
AUTHOR_NAME_SEPARATORS = %w[
|
6
8
|
,
|
7
9
|
,
|
8
10
|
、
|
9
|
-
|
11
|
+
].freeze
|
10
12
|
|
11
13
|
AUTHOR_NAME_SEPARATORS_REGEXP = ::Regexp.union(AUTHOR_NAME_SEPARATORS)
|
12
14
|
|
@@ -34,9 +36,7 @@ module Amakanize
|
|
34
36
|
|
35
37
|
# @private
|
36
38
|
# @return [String]
|
37
|
-
|
38
|
-
@raw
|
39
|
-
end
|
39
|
+
attr_reader :raw
|
40
40
|
|
41
41
|
# @private
|
42
42
|
# @return [Array<String>]
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'amakanize/filterable'
|
2
4
|
|
3
5
|
module Amakanize
|
4
6
|
class BookPosition
|
@@ -25,7 +27,7 @@ module Amakanize
|
|
25
27
|
::Amakanize::Filters::BookPositionAtEndDetectionFilter,
|
26
28
|
::Amakanize::Filters::BookPositionClearingFilter,
|
27
29
|
::Amakanize::Filters::VideoPositionNumberConversionFilter,
|
28
|
-
::Amakanize::Filters::BookPositionNumberCanonicalizationFilter
|
30
|
+
::Amakanize::Filters::BookPositionNumberCanonicalizationFilter
|
29
31
|
]
|
30
32
|
end
|
31
33
|
end
|
data/lib/amakanize/filterable.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Amakanize
|
2
4
|
module Filterable
|
3
5
|
def self.included(base)
|
@@ -12,7 +14,7 @@ module Amakanize
|
|
12
14
|
# @note Override
|
13
15
|
def to_s
|
14
16
|
filters.inject(context: {}, output: raw) do |result, filter|
|
15
|
-
filter.call(result)
|
17
|
+
filter.call(**result)
|
16
18
|
end[:output]
|
17
19
|
end
|
18
20
|
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'amakanize/filters/base_filter'
|
2
4
|
|
3
5
|
module Amakanize
|
4
6
|
module Filters
|
@@ -9,19 +11,17 @@ module Amakanize
|
|
9
11
|
(?:#{::Amakanize::PATTERN_OF_SUFFIX_OF_BOOK_POSITION})?
|
10
12
|
\s*
|
11
13
|
\z
|
12
|
-
/x
|
14
|
+
/x.freeze
|
13
15
|
|
14
16
|
# @note Override
|
15
17
|
def call(context:, output:)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
output = position
|
20
|
-
end
|
18
|
+
if !context[:position_detected] && (position = output[PATTERN, 1])
|
19
|
+
context[:position_detected] = true
|
20
|
+
output = position
|
21
21
|
end
|
22
22
|
{
|
23
23
|
context: context,
|
24
|
-
output: output
|
24
|
+
output: output
|
25
25
|
}
|
26
26
|
end
|
27
27
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'amakanize/filters/base_filter'
|
2
4
|
|
3
5
|
module Amakanize
|
4
6
|
module Filters
|
5
7
|
class BookPositionClearingFilter < ::Amakanize::Filters::BaseFilter
|
6
8
|
# @note Override
|
7
9
|
def call(context:, output:)
|
8
|
-
unless context[:position_detected]
|
9
|
-
output = ""
|
10
|
-
end
|
10
|
+
output = '' unless context[:position_detected]
|
11
11
|
{
|
12
12
|
context: context,
|
13
|
-
output: output
|
13
|
+
output: output
|
14
14
|
}
|
15
15
|
end
|
16
16
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'amakanize/filters/base_filter'
|
2
4
|
|
3
5
|
module Amakanize
|
4
6
|
module Filters
|
@@ -9,19 +11,17 @@ module Amakanize
|
|
9
11
|
(#{::Amakanize::PATTERN_OF_NUMERIC_CHARACTERS})
|
10
12
|
(?:#{::Amakanize::PATTERN_OF_SUFFIX_OF_BOOK_POSITION})?
|
11
13
|
\)
|
12
|
-
/x
|
14
|
+
/x.freeze
|
13
15
|
|
14
16
|
# @note Override
|
15
17
|
def call(context:, output:)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
output = position
|
20
|
-
end
|
18
|
+
if !context[:position_detected] && (position = output[PATTERN, 1])
|
19
|
+
context[:position_detected] = true
|
20
|
+
output = position
|
21
21
|
end
|
22
22
|
{
|
23
23
|
context: context,
|
24
|
-
output: output
|
24
|
+
output: output
|
25
25
|
}
|
26
26
|
end
|
27
27
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'amakanize/filters/base_filter'
|
2
4
|
|
3
5
|
module Amakanize
|
4
6
|
module Filters
|
@@ -6,19 +8,17 @@ module Amakanize
|
|
6
8
|
PATTERN = /
|
7
9
|
(?:#{::Amakanize::PATTERN_OF_PREFIX_OF_BOOK_POSITION})(#{::Amakanize::PATTERN_OF_NUMERIC_CHARACTERS})
|
8
10
|
|(#{::Amakanize::PATTERN_OF_NUMERIC_CHARACTERS})(?:#{::Amakanize::PATTERN_OF_SUFFIX_OF_BOOK_POSITION})
|
9
|
-
/x
|
11
|
+
/x.freeze
|
10
12
|
|
11
13
|
# @note Override
|
12
14
|
def call(context:, output:)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
output = position
|
17
|
-
end
|
15
|
+
if !context[:position_detected] && (position = output[PATTERN, 1])
|
16
|
+
context[:position_detected] = true
|
17
|
+
output = position
|
18
18
|
end
|
19
19
|
{
|
20
20
|
context: context,
|
21
|
-
output: output
|
21
|
+
output: output
|
22
22
|
}
|
23
23
|
end
|
24
24
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'amakanize/filters/base_filter'
|
2
4
|
|
3
5
|
module Amakanize
|
4
6
|
module Filters
|
5
7
|
class BookPositionNumberCanonicalizationFilter < ::Amakanize::Filters::BaseFilter
|
6
8
|
# @note Override
|
7
9
|
def call(context:, output:)
|
8
|
-
if context[:position_detected]
|
9
|
-
output = output.gsub(/\A0+([1-9]+)/, '\1')
|
10
|
-
end
|
10
|
+
output = output.gsub(/\A0+([1-9]+)/, '\1') if context[:position_detected]
|
11
11
|
{
|
12
12
|
context: context,
|
13
|
-
output: output
|
13
|
+
output: output
|
14
14
|
}
|
15
15
|
end
|
16
16
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'amakanize/filters/base_filter'
|
2
4
|
|
3
5
|
module Amakanize
|
4
6
|
module Filters
|
@@ -33,7 +35,7 @@ module Amakanize
|
|
33
35
|
{
|
34
36
|
context: context,
|
35
37
|
output: PAIRS.each_with_object(output) do |(open, close), result|
|
36
|
-
result.gsub!(/#{open}([
|
38
|
+
result.gsub!(/#{open}([^( ]+?)#{close}/, '(\1)')
|
37
39
|
end.gsub(/\s*\((.+?)\)(?:\z|(\s*))/) do
|
38
40
|
" \(#{::Regexp.last_match(1)})#{' ' if Regexp.last_match(2)}"
|
39
41
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'amakanize/filters/base_filter'
|
2
4
|
|
3
5
|
module Amakanize
|
4
6
|
module Filters
|
@@ -9,7 +11,7 @@ module Amakanize
|
|
9
11
|
def call(context:, output:)
|
10
12
|
{
|
11
13
|
context: context,
|
12
|
-
output: output.gsub(/\s+/,
|
14
|
+
output: output.gsub(/\s+/, ' ')
|
13
15
|
}
|
14
16
|
end
|
15
17
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'amakanize/filters/base_filter'
|
2
4
|
|
3
5
|
module Amakanize
|
4
6
|
module Filters
|
@@ -9,7 +11,7 @@ module Amakanize
|
|
9
11
|
def call(context:, output:)
|
10
12
|
{
|
11
13
|
context: context,
|
12
|
-
output: output.gsub(/(\w)ー(\w)/, '\1-\2')
|
14
|
+
output: output.gsub(/(\w)ー(\w)/, '\1-\2')
|
13
15
|
}
|
14
16
|
end
|
15
17
|
end
|
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'amakanize/filters/base_filter'
|
4
|
+
require 'cgi'
|
3
5
|
|
4
6
|
module Amakanize
|
5
7
|
module Filters
|
@@ -10,7 +12,7 @@ module Amakanize
|
|
10
12
|
def call(context:, output:)
|
11
13
|
{
|
12
14
|
context: context,
|
13
|
-
output: ::CGI.unescapeHTML(output)
|
15
|
+
output: ::CGI.unescapeHTML(output)
|
14
16
|
}
|
15
17
|
end
|
16
18
|
end
|