aggressive_normalization_jp 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 50f594057470afdff7662412be61e3537b667a7f74e0975eb51784afb3ac281d
4
+ data.tar.gz: 4215f864b1c9bda3a68687da6cb235137a8b07d93e0d7ef482c801e8f56df2cc
5
+ SHA512:
6
+ metadata.gz: 70408610472d0302f507a3fe34754836d430f4a21c2395bead03f6f06714d2236387f86892075dfad5cd732bb673fcfb253fc1275091f59e07cc1336ac507a6c
7
+ data.tar.gz: 034d25192ab434a3a5b58b6679973cefb8ac2d0717eff204d9ca5fdc59c5cb74548719c72393eeddc0a7ef9f54d38e5fb73687c3395dfa7855a3151f09e182f4
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at coro.365@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in aggressive_normalization_jp.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "test-unit", "~> 3.0"
11
+
12
+ gem "unicode", "~> 0.4"
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # aggressive_normalization_jp
2
+ Converts uncommon characters to common characters or replaces them with empty characters.
3
+ I made it to study ruby gems.
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ gem install aggressive_normalization_jp
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```
14
+ require 'aggressive_normalization_jp'
15
+
16
+ puts "【重要】資料1 -❻- (令和最新版)".normalization
17
+ # => "[重要]資料1 -6- (令和最新版)"
18
+
19
+ puts "【重要】資料1 -❻- (令和最新版)".feature
20
+ # => "重要資料16令和最新版"
21
+
22
+ ```
23
+
24
+ ## Test
25
+
26
+ ```
27
+ ruby test/aggressive_normalization_jp_test.rb
28
+ ```
29
+
30
+ ## Credit
31
+ Copyright (C) 2023 Coro365
32
+ Licensed under the [MIT](LICENSE) license.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ task default: :test
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/aggressive_normalization_jp/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "aggressive_normalization_jp"
7
+ spec.version = AggressiveNormalizationJp::VERSION
8
+ spec.authors = ["Coro365"]
9
+ spec.email = ["coro.365@gmail.com"]
10
+
11
+ spec.summary = "Aggressive normalization for japanese."
12
+ spec.description = "Converts uncommon characters to common characters or replaces them with empty characters."
13
+ spec.homepage = "https://github.com/Coro365/aggressive_normalization_jp"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/Coro365/aggressive_normalization_jp"
19
+ spec.metadata["changelog_uri"] = "https://github.com/Coro365/aggressive_normalization_jp"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (File.expand_path(f) == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
26
+ end
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ # Uncomment to register a new dependency of your gem
33
+ # spec.add_dependency "example-gem", "~> 1.0"
34
+
35
+ # For more information and examples about making a new gem, check out our
36
+ # guide at: https://bundler.io/guides/creating_gem.html
37
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AggressiveNormalizationJp
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'unicode'
4
+ require_relative "aggressive_normalization_jp/version"
5
+
6
+ module AggressiveNormalizationJp
7
+ class Error < StandardError; end
8
+ def normalization
9
+ str = self
10
+ # replace full-width to half-width
11
+ str = str.tr("【】()〔〕[]", "[]()[][]")
12
+ str = str.tr("!?~〜\/・||", "!?~~ ")
13
+ str = str.tr(" ", " ")
14
+
15
+ # number
16
+ str = str.tr("⓿❶❷❸❹❺❻❼❽❾", "0123456789")
17
+
18
+ # for file path
19
+ str = str.tr("::", " ")
20
+
21
+ str = Unicode::nfkc(str)
22
+
23
+ str = str.gsub(/\s+/, "\s")
24
+ str.strip
25
+ end
26
+
27
+ def normalization!
28
+ replace(self.normalization)
29
+ end
30
+
31
+ def feature
32
+ downcase.normalization.delete("[]()~\s'._").delete("-")
33
+ end
34
+
35
+ def feature!
36
+ replace(self.feature)
37
+ end
38
+
39
+ def text_escape
40
+ gsub( %r'[\&\(\)\{\}\[\]\*\?\\\ \':]' ) { |c| '\\'+c }
41
+ end
42
+
43
+ def text_escape!
44
+ replace(self.text_escape)
45
+ end
46
+ end
47
+
48
+ include AggressiveNormalizationJp
@@ -0,0 +1,4 @@
1
+ module AggressiveNormalizationJp
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aggressive_normalization_jp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Coro365
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-02-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Converts uncommon characters to common characters or replaces them with
14
+ empty characters.
15
+ email:
16
+ - coro.365@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - CODE_OF_CONDUCT.md
22
+ - Gemfile
23
+ - README.md
24
+ - Rakefile
25
+ - aggressive_normalization_jp.gemspec
26
+ - lib/aggressive_normalization_jp.rb
27
+ - lib/aggressive_normalization_jp/version.rb
28
+ - sig/aggressive_normalization_jp.rbs
29
+ homepage: https://github.com/Coro365/aggressive_normalization_jp
30
+ licenses:
31
+ - MIT
32
+ metadata:
33
+ homepage_uri: https://github.com/Coro365/aggressive_normalization_jp
34
+ source_code_uri: https://github.com/Coro365/aggressive_normalization_jp
35
+ changelog_uri: https://github.com/Coro365/aggressive_normalization_jp
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 2.6.0
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubygems_version: 3.3.25
52
+ signing_key:
53
+ specification_version: 4
54
+ summary: Aggressive normalization for japanese.
55
+ test_files: []