itamae-plugin-recipe-yk_mecab 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d31544059ef4a5b611902d390fb7a7191bd30acb
4
+ data.tar.gz: 066a45730c45aed2bd219bafd6e9b04c9f5318ff
5
+ SHA512:
6
+ metadata.gz: e893d03fc6ce548253a3e3377dedf1ed9b9e6ad2420ac52ab884984be983e14fb61dd809c2454e04e8e246d745b320bd72ff32a22ba4083eb98c79ed8936ff28
7
+ data.tar.gz: b3ec58dfbe5fde12efa1549e764a4fc2e72623ddf5c10cc8d0d3997f9e949f793d0a5cee966f71411e2b9615c739ceedcfac43c82280280f767616e472dba9f3
@@ -0,0 +1,94 @@
1
+ # Created by https://www.gitignore.io/api/osx,ruby
2
+
3
+ ### OSX ###
4
+ .DS_Store
5
+ .AppleDouble
6
+ .LSOverride
7
+
8
+ # Icon must end with two \r
9
+ Icon
10
+
11
+
12
+ # Thumbnails
13
+ ._*
14
+
15
+ # Files that might appear in the root of a volume
16
+ .DocumentRevisions-V100
17
+ .fseventsd
18
+ .Spotlight-V100
19
+ .TemporaryItems
20
+ .Trashes
21
+ .VolumeIcon.icns
22
+
23
+ # Directories potentially created on remote AFP share
24
+ .AppleDB
25
+ .AppleDesktop
26
+ Network Trash Folder
27
+ Temporary Items
28
+ .apdisk
29
+
30
+
31
+ ### Ruby ###
32
+ *.gem
33
+ *.rbc
34
+ /.config
35
+ /coverage/
36
+ /InstalledFiles
37
+ /pkg/
38
+ /spec/reports/
39
+ /spec/examples.txt
40
+ /test/tmp/
41
+ /test/version_tmp/
42
+ /tmp/
43
+
44
+ ## Specific to RubyMotion:
45
+ .dat*
46
+ .repl_history
47
+ build/
48
+ *.bridgesupport
49
+ build-iPhoneOS/
50
+ build-iPhoneSimulator/
51
+
52
+ ## Specific to RubyMotion (use of CocoaPods):
53
+ #
54
+ # We recommend against adding the Pods directory to your .gitignore. However
55
+ # you should judge for yourself, the pros and cons are mentioned at:
56
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
57
+ #
58
+ # vendor/Pods/
59
+
60
+ ## Documentation cache and generated files:
61
+ /.yardoc/
62
+ /_yardoc/
63
+ /doc/
64
+ /rdoc/
65
+
66
+ ## Environment normalization:
67
+ /.bundle/
68
+ /vendor/bundle
69
+ /lib/bundler/man/
70
+
71
+ # for a library or gem, you might want to ignore these files since the code is
72
+ # intended to run in multiple environments; otherwise, check them in:
73
+ # Gemfile.lock
74
+ # .ruby-version
75
+ # .ruby-gemset
76
+
77
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
78
+ .rvmrc
79
+
80
+ # Created by https://www.gitignore.io/api/vagrant
81
+
82
+ ### Vagrant ###
83
+ .vagrant/
84
+
85
+ # created by bundler
86
+ /.bundle/
87
+ /.yardoc
88
+ /Gemfile.lock
89
+ /_yardoc/
90
+ /coverage/
91
+ /doc/
92
+ /pkg/
93
+ /spec/reports/
94
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at wonderfulworld0315@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in itamae-plugin-recipe-yk_mecab.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 yosuke0315
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,62 @@
1
+ # Itamae::Plugin::Recipe::YkMecab
2
+
3
+ Itamae plugin to install mecab
4
+
5
+ mecab version : 0.994
6
+
7
+ mecab dictionarys
8
+ - IPA
9
+ - hatena
10
+ - wikipedia
11
+
12
+ ## Installation
13
+
14
+ This gem is required Ruby.
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'itamae-plugin-recipe-yk_mecab'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install itamae-plugin-recipe-yk_mecab
29
+
30
+ ## Usage
31
+
32
+ ### install for system
33
+
34
+ ```rb
35
+ # recipe.rb
36
+
37
+ # Install Docker, start it and ensure it starts on boot.
38
+ include_recipe "yk_mecab::install"
39
+ ```
40
+
41
+ ### node.yml
42
+
43
+ ```yml
44
+ # for example
45
+
46
+ user: 'vagrant'
47
+ home_dir: '/home/ec2-user/'
48
+ mecab:
49
+ hatena: '1' # If you need hatena dictionary.
50
+ wikipedia: '' # If you don't need wikipedia dictionary.
51
+ ```
52
+
53
+ ### command
54
+
55
+ ```sh
56
+ $ mecab -u custom.dic
57
+ ```
58
+
59
+
60
+ ## License
61
+
62
+ [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,28 @@
1
+ require 'rake'
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ task :spec => 'spec:all'
6
+ task :default => :spec
7
+
8
+ namespace :spec do
9
+ targets = []
10
+ Dir.glob('./spec/*').each do |dir|
11
+ next unless File.directory?(dir)
12
+ target = File.basename(dir)
13
+ target = "_#{target}" if target == "default"
14
+ targets << target
15
+ end
16
+
17
+ task :all => targets
18
+ task :default => :all
19
+
20
+ targets.each do |target|
21
+ original_target = target == "_default" ? target[1..-1] : target
22
+ desc "Run serverspec tests to #{original_target}"
23
+ RSpec::Core::RakeTask.new(target.to_sym) do |t|
24
+ ENV['TARGET_HOST'] = original_target
25
+ t.pattern = "spec/#{original_target}/*_spec.rb"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,11 @@
1
+ Vagrant.configure(2) do |config|
2
+
3
+ config.vm.box = "centos64"
4
+ config.vm.hostname = "vagrant-centos64"
5
+
6
+ config.vm.network "forwarded_port", guest: 3000, host: 8080
7
+ config.vm.network "private_network", ip: "192.168.33.10"
8
+ config.vm.provider :virtualbox do |vb|
9
+ vb.memory = 2048
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "itamae/plugin/recipe/yk_mecab"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'itamae/plugin/recipe/yk_mecab/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "itamae-plugin-recipe-yk_mecab"
8
+ spec.version = Itamae::Plugin::Recipe::YkMecab::VERSION
9
+ spec.authors = ["yosuke0315"]
10
+ spec.email = ["wonderfulworld0315@gmail.com"]
11
+
12
+ spec.summary = %q{Itamae plugin to install mecab}
13
+ spec.description = %q{Itamae plugin to install mecab}
14
+ spec.homepage = "https://github.com/yosuke0315"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "itamae", "~> 1.9.0"
31
+
32
+ spec.add_development_dependency "bundler", "~> 1.11"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "serverspec", "~> 2.31.0"
35
+ end
@@ -0,0 +1,11 @@
1
+ require "itamae/plugin/recipe/yk_mecab/version"
2
+
3
+ module Itamae
4
+ module Plugin
5
+ module Recipe
6
+ module YkMecab
7
+ # Your code goes here...
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,31 @@
1
+ require 'csv'
2
+
3
+ original_data = {
4
+ wikipedia: 'jawiki-latest-all-titles-in-ns0',
5
+ hatena: 'keywordlist_furigana.csv'
6
+ }
7
+
8
+ CSV.open("custom.csv", 'w') do |csv|
9
+ original_data.each do |type, filename|
10
+ next unless File.file? filename
11
+ open(filename).each do |title|
12
+ title.force_encoding("UTF-8")
13
+ title.strip!
14
+
15
+ next if title =~ %r(^[+-.$()?*/&%!"'_,]+)
16
+ next if title =~ /^[-.0-9]+$/
17
+ next if title =~ /曖昧さ回避/
18
+ next if title =~ /_\(/
19
+ next if title =~ /^PJ:/
20
+ next if title =~ /の登場人物/
21
+ next if title =~ /一覧/
22
+
23
+ title_length = title.length
24
+
25
+ if title_length > 3
26
+ score = [-36000.0, -400 * (title_length ** 1.5)].max.to_i
27
+ csv << [title, nil, nil, score, '名詞', '一般', '*', '*', '*', '*', title, '*', '*', type]
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,76 @@
1
+ # install g++ and wget
2
+ case node[:platform]
3
+ when %r(redhat|fedora|amazon)
4
+ package 'gcc-c++'
5
+ when %r(debian|ubuntu)
6
+ package 'g++'
7
+ end
8
+ package 'wget'
9
+
10
+ # download and install mecab
11
+ execute "wget http://mecab.googlecode.com/files/mecab-0.994.tar.gz" do
12
+ not_if 'ls | grep mecab-0.994.tar.gz'
13
+ end
14
+
15
+ execute "tar zxvf mecab-0.994.tar.gz" do
16
+ not_if 'ls | grep mecab-0.994$'
17
+ end
18
+
19
+ execute "cd mecab-0.994; sudo ./configure --enable-utf8-only; make; sudo make install"
20
+
21
+ # install ipa dictionary
22
+ execute "wget http://mecab.googlecode.com/files/mecab-ipadic-2.7.0-20070801.tar.gz" do
23
+ not_if 'ls | grep mecab-ipadic-2.7.0-20070801.tar.gz'
24
+ end
25
+
26
+ execute "tar zxvf mecab-ipadic-2.7.0-20070801.tar.gz" do
27
+ not_if 'ls | grep mecab-ipadic-2.7.0-20070801$'
28
+ end
29
+
30
+ case node[:platform]
31
+ when %r(debian|ubuntu)
32
+ execute "echo /usr/local/lib >> /etc/ld.so.conf" do
33
+ not_if 'grep /usr/local/lib /etc/ld.so.conf'
34
+ end
35
+ execute "sudo ldconfig"
36
+ end
37
+
38
+ execute "cd mecab-ipadic-2.7.0-20070801; sudo ./configure --with-mecab-config=/usr/local/bin/mecab-config --with-charset=utf8"
39
+ execute "cd mecab-ipadic-2.7.0-20070801; make; sudo make install"
40
+
41
+ # install hatena dictionary
42
+ unless node[:mecab][:hatena].empty?
43
+ case node[:platform]
44
+ when %r(redhat|fedora|amazon)
45
+ execute "sudo yum localinstall -y http://mirror.centos.org/centos/6/os/x86_64/Packages/nkf-2.0.8b-6.2.el6.x86_64.rpm"
46
+ when %r(debian|ubuntu)
47
+ execute "sudo apt-get install nkf"
48
+ end
49
+ execute "wget http://d.hatena.ne.jp/images/keyword/keywordlist_furigana.csv" do
50
+ not_if 'ls | grep keywordlist_furigana.csv'
51
+ end
52
+ execute "nkf -w --overwrite keywordlist_furigana.csv"
53
+ end
54
+
55
+ # install wikipedia dictionary
56
+ unless node[:mecab][:wikipedia].empty?
57
+ execute "wget http://dumps.wikimedia.org/jawiki/latest/jawiki-latest-all-titles-in-ns0.gz" do
58
+ not_if 'ls | grep jawiki-latest-all-titles-in-ns0'
59
+ end
60
+ execute "gunzip jawiki-latest-all-titles-in-ns0.gz" do
61
+ not_if 'ls | grep jawiki-latest-all-titles-in-ns0$'
62
+ end
63
+ end
64
+
65
+ # compile hatena or wikipedia dictionary
66
+ unless node[:mecab][:wikipedia].empty? && node[:mecab][:hatena].empty?
67
+ remote_file "#{node[:home_dir]}/make_dict.rb" do
68
+ source './files/make_dict.rb'
69
+ mode '755'
70
+ user node[:user]
71
+ end
72
+ execute "/bin/bash -lc 'ruby make_dict.rb'" do
73
+ user node[:user]
74
+ end
75
+ execute "/usr/local/libexec/mecab/mecab-dict-index -d /usr/local/lib/mecab/dic/ipadic -u custom.dic -f utf-8 -t utf-8 custom.csv"
76
+ end
@@ -0,0 +1,9 @@
1
+ module Itamae
2
+ module Plugin
3
+ module Recipe
4
+ module YkMecab
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: itamae-plugin-recipe-yk_mecab
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - yosuke0315
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: itamae
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.9.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.9.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: serverspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.31.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.31.0
69
+ description: Itamae plugin to install mecab
70
+ email:
71
+ - wonderfulworld0315@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - CODE_OF_CONDUCT.md
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - Vagrantfile
84
+ - bin/console
85
+ - bin/setup
86
+ - itamae-plugin-recipe-yk_mecab.gemspec
87
+ - lib/itamae/plugin/recipe/yk_mecab.rb
88
+ - lib/itamae/plugin/recipe/yk_mecab/files/make_dict.rb
89
+ - lib/itamae/plugin/recipe/yk_mecab/install.rb
90
+ - lib/itamae/plugin/recipe/yk_mecab/version.rb
91
+ homepage: https://github.com/yosuke0315
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.4.5.1
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Itamae plugin to install mecab
115
+ test_files: []