mk_semi_lattice 0.4.2 → 0.4.4

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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/lib/abbrev_checker/abbrev_check.rb +15 -2
  3. data/lib/abbrev_checker/abbrev_sample.tgz +0 -0
  4. data/lib/abbrev_checker/abbrev_yamls/.semi_lattice/icons/document.png +0 -0
  5. data/lib/abbrev_checker/abbrev_yamls/.semi_lattice/icons/folder.png +0 -0
  6. data/lib/abbrev_checker/abbrev_yamls/.semi_lattice/semi_lattice.yaml +304 -0
  7. data/lib/abbrev_checker/abbrev_yamls/command_tree.yaml +29 -18
  8. data/lib/abbrev_checker/abbrev_yamls/command_tree_node_edge.yaml +174 -0
  9. data/lib/abbrev_checker/docs/abbrev_checker/abbrev_checker.003.png +0 -0
  10. data/lib/abbrev_checker/docs/abbrev_checker/abbrev_checker.004.png +0 -0
  11. data/lib/abbrev_checker/docs/abbrev_checker.key +0 -0
  12. data/lib/abbrev_checker/docs/readme.org +13 -1
  13. data/lib/docs/short_intro/short_intro.001.png +0 -0
  14. data/lib/docs/short_intro/short_intro.002.png +0 -0
  15. data/lib/docs/short_intro/short_intro.003.png +0 -0
  16. data/lib/docs/short_intro/short_intro.004.png +0 -0
  17. data/lib/docs/short_intro.html +125 -0
  18. data/lib/docs/short_intro.key +0 -0
  19. data/lib/docs/short_intro.org +24 -0
  20. data/lib/hc.rb +17 -2
  21. data/lib/mk_semi_lattice/version.rb +1 -1
  22. data/lib/plot/plot.rb +166 -0
  23. data/lib/voca_buil/Rakefile_mk_sample_tgz.rake +162 -0
  24. data/lib/voca_buil/docs/readme.html +87 -36
  25. data/lib/voca_buil/docs/readme.org +13 -2
  26. data/lib/voca_buil/docs/voca_buil/voca_buil.001.png +0 -0
  27. data/lib/voca_buil/docs/voca_buil/voca_buil.002.png +0 -0
  28. data/lib/voca_buil/docs/voca_buil/voca_buil.003.png +0 -0
  29. data/lib/voca_buil/docs/voca_buil/voca_buil.004.png +0 -0
  30. data/lib/voca_buil/docs/voca_buil/voca_buil.005.png +0 -0
  31. data/lib/voca_buil/docs/voca_buil/voca_buil.006.png +0 -0
  32. data/lib/voca_buil/docs/voca_buil/voca_buil.007.png +0 -0
  33. data/lib/voca_buil/docs/voca_buil/voca_buil.008.png +0 -0
  34. data/lib/voca_buil/docs/voca_buil/voca_buil.009.png +0 -0
  35. data/lib/voca_buil/docs/voca_buil/voca_buil.010.png +0 -0
  36. data/lib/voca_buil/docs/voca_buil/voca_buil.011.png +0 -0
  37. data/lib/voca_buil/docs/voca_buil/voca_buil.012.png +0 -0
  38. data/lib/voca_buil/docs/voca_buil/voca_buil.013.png +0 -0
  39. data/lib/voca_buil/docs/voca_buil/voca_buil.014.png +0 -0
  40. data/lib/voca_buil/docs/voca_buil/voca_buil.015.png +0 -0
  41. data/lib/voca_buil/docs/voca_buil/voca_buil.016.png +0 -0
  42. data/lib/voca_buil/docs/voca_buil/voca_buil.017.png +0 -0
  43. data/lib/voca_buil/docs/voca_buil/voca_buil.018.png +0 -0
  44. data/lib/voca_buil/docs/voca_buil/voca_buil.019.png +0 -0
  45. data/lib/voca_buil/docs/voca_buil/voca_buil.020.png +0 -0
  46. data/lib/voca_buil/docs/voca_buil.key +0 -0
  47. data/lib/voca_buil/etymological_builder_check_sample.tgz +0 -0
  48. data/lib/voca_buil/multi_check.rb +53 -27
  49. data/readme.html +28 -36
  50. data/{README.org → readme.org} +3 -7
  51. metadata +60 -7
  52. data/.DS_Store +0 -0
  53. data/lib/abbrev_checker/check_log.yaml +0 -13
  54. data/lib/abbrev_checker/word_log.yaml +0 -18
  55. data/lib/voca_buil/docs/voca_buil.pdf +0 -0
  56. data/lib/voca_buil/docs/voca_buil.png +0 -0
@@ -0,0 +1,125 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="jp" xml:lang="jp">
5
+ <head>
6
+ <!-- 2026-01-15 Thu 23:10 -->
7
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
8
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
9
+ <title>Vocabulary Builderの簡単な説明</title>
10
+ <meta name="author" content="Shigeto R. Nishitani" />
11
+ <meta name="generator" content="Org Mode" />
12
+ <link rel="stylesheet" type="text/css" href="https://fniessen.github.io/org-html-themes/src/readtheorg_theme/css/htmlize.css"/>
13
+ <link rel="stylesheet" type="text/css" href="https://fniessen.github.io/org-html-themes/src/readtheorg_theme/css/readtheorg.css"/>
14
+ <link rel="stylesheet" type="text/css" href="https://fniessen.github.io/org-html-themes/src/readtheorg_theme/css/code-copy.css"/>
15
+ <link rel="stylesheet" type="text/css" href="src/readtheorg_theme/css/search.css"/>
16
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
17
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
18
+ <script type="text/javascript" src="https://fniessen.github.io/org-html-themes/src/lib/js/jquery.stickytableheaders.min.js"></script>
19
+ <script type="text/javascript" src="https://fniessen.github.io/org-html-themes/src/readtheorg_theme/js/search.js"></script>
20
+ <script type="text/javascript" src="https://fniessen.github.io/org-html-themes/src/readtheorg_theme/js/readtheorg.js"></script>
21
+ <script type="text/javascript" src="https://fniessen.github.io/org-html-themes/src/readtheorg_theme/js/code-copy.js"></script>
22
+ </head>
23
+ <body>
24
+ <div id="content" class="content">
25
+ <h1 class="title">Vocabulary Builderの簡単な説明</h1>
26
+ <div id="table-of-contents" role="doc-toc">
27
+ <h2>Table of Contents</h2>
28
+ <div id="text-table-of-contents" role="doc-toc">
29
+ <ul>
30
+ <li><a href="#org1b9702c">1. name</a></li>
31
+ <li><a href="#org7192e01">2. usage</a>
32
+ <ul>
33
+ <li><a href="#org8dbc59f">2.1. sample install</a></li>
34
+ <li><a href="#orga60bbfb">2.2. hc check</a></li>
35
+ <li><a href="#orgb1e433b">2.3. plot</a></li>
36
+ </ul>
37
+ </li>
38
+ </ul>
39
+ </div>
40
+ </div>
41
+ <div id="outline-container-org1b9702c" class="outline-2">
42
+ <h2 id="org1b9702c"><span class="section-number-2">1.</span> name</h2>
43
+ <div class="outline-text-2" id="text-1">
44
+ <ul class="org-ul">
45
+ <li>hc checkは英単語のetymological(語源に基づく) buildingを行うclaです.</li>
46
+ <li>簡単な始め方を紹介します.</li>
47
+ </ul>
48
+ </div>
49
+ </div>
50
+ <div id="outline-container-org7192e01" class="outline-2">
51
+ <h2 id="org7192e01"><span class="section-number-2">2.</span> usage</h2>
52
+ <div class="outline-text-2" id="text-2">
53
+ </div>
54
+ <div id="outline-container-org8dbc59f" class="outline-3">
55
+ <h3 id="org8dbc59f"><span class="section-number-3">2.1.</span> sample install</h3>
56
+ <div class="outline-text-3" id="text-2-1">
57
+ <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
58
+
59
+
60
+ <colgroup>
61
+ <col class="org-left" />
62
+ </colgroup>
63
+ <tbody>
64
+ <tr>
65
+ <td class="org-left"><img src="./short_intro/short_intro.002.png" alt="short_intro.002.png" /></td>
66
+ </tr>
67
+
68
+ <tr>
69
+ <td class="org-left">Fig.1 サンプルのインストール方法.</td>
70
+ </tr>
71
+ </tbody>
72
+ </table>
73
+ </div>
74
+ </div>
75
+ <div id="outline-container-orga60bbfb" class="outline-3">
76
+ <h3 id="orga60bbfb"><span class="section-number-3">2.2.</span> hc check</h3>
77
+ <div class="outline-text-3" id="text-2-2">
78
+ <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
79
+
80
+
81
+ <colgroup>
82
+ <col class="org-left" />
83
+ </colgroup>
84
+ <tbody>
85
+ <tr>
86
+ <td class="org-left"><img src="./short_intro/short_intro.003.png" alt="short_intro.003.png" /></td>
87
+ </tr>
88
+
89
+ <tr>
90
+ <td class="org-left">Fig.2 checkの仕方.</td>
91
+ </tr>
92
+ </tbody>
93
+ </table>
94
+ </div>
95
+ </div>
96
+ <div id="outline-container-orgb1e433b" class="outline-3">
97
+ <h3 id="orgb1e433b"><span class="section-number-3">2.3.</span> plot</h3>
98
+ <div class="outline-text-3" id="text-2-3">
99
+ <table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
100
+
101
+
102
+ <colgroup>
103
+ <col class="org-left" />
104
+ </colgroup>
105
+ <tbody>
106
+ <tr>
107
+ <td class="org-left"><img src="./short_intro/short_intro.004.png" alt="short_intro.004.png" /></td>
108
+ </tr>
109
+
110
+ <tr>
111
+ <td class="org-left">Fig.3 プロットの例.</td>
112
+ </tr>
113
+ </tbody>
114
+ </table>
115
+ </div>
116
+ </div>
117
+ </div>
118
+ </div>
119
+ <div id="postamble" class="status">
120
+ <p class="author">Author: Shigeto R. Nishitani</p>
121
+ <p class="date">Created: 2026-01-15 Thu 23:10</p>
122
+ <p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
123
+ </div>
124
+ </body>
125
+ </html>
Binary file
@@ -0,0 +1,24 @@
1
+ #+OPTIONS: ^:{}
2
+ #+STARTUP: indent nolineimages overview num
3
+ #+TITLE: Vocabulary Builderの簡単な説明
4
+ #+AUTHOR: Shigeto R. Nishitani
5
+ #+EMAIL: (concat "shigeto_nishitani@mac.com")
6
+ #+LANGUAGE: jp
7
+ #+OPTIONS: H:4 toc:t num:2
8
+ #+SETUPFILE: https://fniessen.github.io/org-html-themes/org/theme-readtheorg.setup
9
+
10
+ * name
11
+ - hc checkは英単語のetymological(語源に基づく) buildingを行うclaです.
12
+ - 簡単な始め方を紹介します.
13
+
14
+ * usage
15
+ ** sample install
16
+ | [[file:./short_intro/short_intro.002.png]]
17
+ | Fig.1 サンプルのインストール方法.
18
+ ** hc check
19
+ | [[file:./short_intro/short_intro.003.png]]
20
+ | Fig.2 checkの仕方.
21
+ ** plot
22
+ | [[file:./short_intro/short_intro.004.png]]
23
+ | Fig.3 プロットの例.
24
+
data/lib/hc.rb CHANGED
@@ -4,7 +4,7 @@ require_relative "mk_stack/mk_stack"
4
4
  require_relative "voca_buil/multi_check"
5
5
  require_relative "split_pdf/split_pdf"
6
6
  require_relative "abbrev_checker/abbrev_check"
7
-
7
+ require_relative "plot/plot" # 追加
8
8
 
9
9
  class CLI < Thor
10
10
  desc "view", "View Semi Lattice Graph"
@@ -21,6 +21,7 @@ class CLI < Thor
21
21
  def split_pdf(*argv)
22
22
  SplitPDF.new(argv).run
23
23
  end
24
+
24
25
  desc 'check', 'check word for vocabulary builder'
25
26
  def check(*argv)
26
27
  options = VocaBuil::OptionParserWrapper.parse
@@ -34,7 +35,7 @@ class CLI < Thor
34
35
  VocaBuil::BaseCheck.new(options).run
35
36
  end
36
37
  end
37
-
38
+
38
39
  desc 'abbrev', 'check abbreviations'
39
40
  def abbrev(*argv)
40
41
  options = AbbrevCheck::OptionParserWrapper.parse
@@ -48,6 +49,20 @@ class CLI < Thor
48
49
  AbbrevCheck::BaseCheck.new(options).run
49
50
  end
50
51
  end
52
+
53
+ desc 'plot', 'plot logs'
54
+ def plot(*argv)
55
+ options = Plot::OptionParserWrapper.parse
56
+ case options[:plot]
57
+ when :score
58
+ Plot::Plotter.plot_score_log
59
+ when :word_size
60
+ Plot::Plotter.plot_word_size_log
61
+ else
62
+ Plot::Plotter.plot_check_cumulative_per_minute
63
+ end
64
+ end
51
65
  end
52
66
 
53
67
  CLI.start(ARGV)
68
+
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MkSemiLattice
4
- VERSION = "0.4.2"
4
+ VERSION = "0.4.4"
5
5
  end
data/lib/plot/plot.rb ADDED
@@ -0,0 +1,166 @@
1
+ # !/usr/bin/env ruby
2
+ require 'thor'
3
+ require 'optparse'
4
+ require 'colorize'
5
+ require 'yaml'
6
+ require 'date'
7
+
8
+ module Plot
9
+ class OptionParserWrapper
10
+ OPTIONS_DEFAULT = { file: 'check_log.yaml', plot: :cumulative }
11
+
12
+ def self.parse(args = ARGV)
13
+ options = OPTIONS_DEFAULT.dup
14
+
15
+ options[:cmd_line] = args.join(' ')
16
+ opt = ::OptionParser.new
17
+ opt.banner = "Usage: hc plot [options]"
18
+ opt.on('-f FILE', '--file FILE', 'YAML file to use') do |v|
19
+ options[:file] = v
20
+ end
21
+ opt.on('-s', '--score', 'Plot score_log.yaml') do
22
+ options[:plot] = :score
23
+ end
24
+ opt.on('-w', '--word_size', 'Plot size from score_log.yaml') do
25
+ options[:plot] = :word_size
26
+ end
27
+ opt.parse!(args)
28
+ p options
29
+ options
30
+ end
31
+ end
32
+
33
+ class Plotter
34
+ def self.run_python_plot(py_code)
35
+ File.write('tmp_plot.py', py_code)
36
+ system('python3 tmp_plot.py')
37
+ File.delete('tmp_plot.py')
38
+ end
39
+
40
+ # 共通のpy_code生成メソッド
41
+ def self.generate_py_code(x_label:, y_label:, title:, x_data:, y_data:, x_fmt:, y_lim: nil, x_date_fmt: nil)
42
+ y_lim_code = y_lim ? "plt.ylim(#{y_lim[0]}, #{y_lim[1]})" : ""
43
+ date_fmt_import = x_date_fmt ? "from matplotlib.dates import DateFormatter" : ""
44
+ date_fmt_setter = x_date_fmt ? "plt.gca().xaxis.set_major_formatter(DateFormatter('#{x_date_fmt}'))" : ""
45
+ <<~PYTHON
46
+ import matplotlib.pyplot as plt
47
+ from datetime import datetime
48
+ #{date_fmt_import}
49
+
50
+ x_data = #{x_data}
51
+ y_data = #{y_data}
52
+
53
+ x = [datetime.strptime(val, "#{x_fmt}") for val in x_data]
54
+ y = y_data
55
+
56
+ plt.figure(figsize=(12,5))
57
+ plt.plot(x, y, marker='o')
58
+ #{date_fmt_setter}
59
+ plt.title('#{title}')
60
+ plt.xlabel('#{x_label}')
61
+ plt.ylabel('#{y_label}')
62
+ #{y_lim_code}
63
+ plt.grid(True)
64
+ plt.tight_layout()
65
+ plt.show()
66
+ PYTHON
67
+ end
68
+
69
+ def self.plot_word_size_log
70
+ log = YAML.load(File.read('score_log.yaml'))
71
+ times = []
72
+ sizes = []
73
+
74
+ log.each do |entry|
75
+ timestamp = entry[:date]
76
+ size = entry[:size]
77
+ next if timestamp.nil? || size.nil?
78
+ times << timestamp
79
+ sizes << size.to_i
80
+ end
81
+
82
+ py_code = generate_py_code(
83
+ x_label: 'Time',
84
+ y_label: 'Word Size',
85
+ title: 'Word Size Over Time',
86
+ x_data: times,
87
+ y_data: sizes,
88
+ x_fmt: "%Y-%m-%d %H:%M:%S"
89
+ )
90
+
91
+ run_python_plot(py_code)
92
+ end
93
+
94
+ def self.plot_score_log
95
+ log = YAML.load(File.read('score_log.yaml'))
96
+ times = []
97
+ scores = []
98
+
99
+ log.each do |entry|
100
+ timestamp = entry[:date]
101
+ score_str = entry[:score].to_s # "4/5" の形式
102
+ num, denom = score_str.split('/').map(&:to_f)
103
+ percent = (num / denom * 100).round(1)
104
+ times << timestamp
105
+ scores << percent
106
+ end
107
+
108
+ py_code = generate_py_code(
109
+ x_label: 'Time',
110
+ y_label: 'Score (%)',
111
+ title: 'Score Percentage Over Time',
112
+ x_data: times,
113
+ y_data: scores,
114
+ x_fmt: "%Y-%m-%d %H:%M:%S",
115
+ y_lim: [0, 100]
116
+ )
117
+
118
+ run_python_plot(py_code)
119
+ end
120
+
121
+ # 例えば cumulative の場合
122
+ def self.plot_check_cumulative_per_minute
123
+ log = YAML.load(File.read('check_log.yaml'))
124
+ counts = Hash.new(0)
125
+ log.each do |entry|
126
+ timestamp = entry.is_a?(Array) ? entry[0] : entry.to_s
127
+ minute_str = timestamp[0,16] # "YYYY-MM-DD HH:MM"
128
+ counts[minute_str] += 1
129
+ end
130
+
131
+ sorted_minutes = counts.keys.sort
132
+ sorted_counts = sorted_minutes.map { |m| counts[m] }
133
+
134
+ cumulative_counts = []
135
+ sum = 0
136
+ sorted_counts.each do |c|
137
+ sum += c
138
+ cumulative_counts << sum
139
+ end
140
+
141
+ py_code = generate_py_code(
142
+ x_label: 'Time (minute)',
143
+ y_label: 'Cumulative Practice Count',
144
+ title: 'Dependence of Cumulative Practice Time',
145
+ x_data: sorted_minutes,
146
+ y_data: cumulative_counts,
147
+ x_fmt: "%Y-%m-%d %H:%M",
148
+ x_date_fmt: "%m-%d"
149
+ )
150
+
151
+ run_python_plot(py_code)
152
+ end
153
+ end
154
+ end
155
+
156
+ if __FILE__ == $0
157
+ options = Plot::OptionParserWrapper.parse
158
+ case options[:plot]
159
+ when :score
160
+ Plot::Plotter.plot_score_log
161
+ when :word_size
162
+ Plot::Plotter.plot_word_size_log
163
+ else
164
+ Plot::Plotter.plot_check_cumulative_per_minute
165
+ end
166
+ end
@@ -0,0 +1,162 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "colorize"
3
+ require 'command_line/global'
4
+ require 'fileutils'
5
+
6
+ task :default do
7
+ puts "Name: Rakefile for making sample_check.tgz"
8
+ puts "> cd etymological_builder/p1_main_root #, and"
9
+ puts "> rake deploy:mk_check_tgz"
10
+ puts "\nIn order to see tasks, it is necessary to do:"
11
+ puts "> rake -f ./Rakefile_mk_sample_tgz.rake -T"
12
+ end
13
+
14
+ namespace :learn do
15
+ desc "whole vocabulary check"
16
+ task :check do
17
+ puts "hc check -i 5 -q 5 -a 8 #on top dir"
18
+ puts "hc check #at each dir"
19
+ end
20
+
21
+ desc "rm word_log and check_log"
22
+ task :clean do
23
+ ['**/check_log.yaml',
24
+ './check_log.yaml',
25
+ '**/word_log.yaml',
26
+ './word_log.yaml'].each do |file|
27
+ p comm="rm -f #{file}"
28
+ system comm
29
+ end
30
+ end
31
+
32
+ desc "new stack"
33
+ task :stack do
34
+ puts "cd r18_mit"
35
+ puts "hc stack"
36
+ puts "cp _stack_.../dir_tree.yaml ."
37
+ puts "mv _stack_.../r18....pdf ."
38
+ end
39
+
40
+ desc "plot training history and score"
41
+ task :plot do
42
+ puts "hc plot # for training history"
43
+ puts "hc plot -s # for plot score"
44
+ end
45
+ end
46
+
47
+ namespace :deploy do
48
+ def collect_dir_trees(dir, glob_pattern, target_dir_proc)
49
+ FileUtils.mkdir(dir) unless File.exist?(dir)
50
+ FileUtils.cp('Rakefile', dir, verbose: true)
51
+
52
+ Dir.glob(glob_pattern).each do |file|
53
+ t_dir = target_dir_proc.call(dir, file)
54
+ FileUtils.mkdir_p(t_dir, verbose: true)
55
+ p [file, t_dir]
56
+ p t_file = File.join(t_dir, "dir_tree.yaml")
57
+ unless File.exist?(t_file)
58
+ FileUtils.cp(file, t_dir, verbose: true)
59
+ else
60
+ File.write(t_file, File.read(file), mode: "a")
61
+ end
62
+ end
63
+ # exit
64
+ end
65
+
66
+ desc "collect init dir_tree.yamls"
67
+ task :init_dirs do
68
+ dir = ARGV[1] || '_stack_init_dirs'
69
+ collect_dir_trees(
70
+ dir,
71
+ "**/_stack_1st_*/dir_tree.yaml",
72
+ ->(dir, file) { File.join(dir, file.split('/')[0], "_stack_init") }
73
+ )
74
+
75
+ Dir.glob('*/*.pdf').each do |file|
76
+ t_dir = File.join(dir, file.split('/')[0])
77
+ FileUtils.cp(file, t_dir, verbose: true)
78
+ end
79
+ exit
80
+ end
81
+
82
+ desc "collect init check dir_tree.yamls"
83
+ task :init_check do
84
+ dir = ARGV[1] || '_stack_init_check_dirs'
85
+ collect_dir_trees(
86
+ dir,
87
+ "**/_stack_1st_*/dir_tree.yaml",
88
+ ->(dir, file) { File.join(dir, file.split('/')[0]) }
89
+ )
90
+ end
91
+
92
+ desc "collect final check dir_tree.yamls"
93
+ task :final_check do
94
+ dir = ARGV[1] || '_stack_final_check_dirs'
95
+ collect_dir_trees(
96
+ dir,
97
+ "*/dir_tree.yaml",
98
+ ->(dir, file) { File.join(dir, file.split('/')[0]) }
99
+ )
100
+ end
101
+
102
+ def change_equal_to_slash(lines)
103
+ # 'key=v1=v2' -> 'key=v1/v2'
104
+ lines.map do |line|
105
+ if line =~ /^\s*([^=]+=[^=]+)=(.+)/
106
+ # 最初の = で2分割し、残りの = を / に
107
+ key, rest = line.split('=', 2)
108
+ rest = rest.gsub('=', '/')
109
+ "#{key}=#{rest}"
110
+ else
111
+ line
112
+ end
113
+ end
114
+ end
115
+ require 'date'
116
+ desc "strip # from dir_tree.yaml"
117
+ task :strip_sharp_from_final do
118
+ dir = ARGV[1] || '_stack_final_check_dirs'
119
+ Dir.glob("#{dir}/**/dir_tree.yaml").each do |file|
120
+ lines = File.readlines(file).map { |line| line.gsub(/^# /, '') }
121
+ lines = change_equal_to_slash(lines)
122
+ File.write(file, lines.join)
123
+ end
124
+ end
125
+
126
+ desc "strip # from dir_tree.yaml"
127
+ task :strip_separator_from_init do
128
+ # strip '---' except first one from init dir_tree.yamls
129
+ dir = ARGV[1] || '_stack_init_check_dirs'
130
+ Dir.glob("#{dir}/**/dir_tree.yaml").each do |file|
131
+ lines = File.readlines(file)
132
+ found = false
133
+ new_lines = lines.reject do |line|
134
+ if line.strip == "---"
135
+ if found
136
+ true # 2つ目以降の '---' を削除
137
+ else
138
+ found = true
139
+ false # 最初の '---' は残す
140
+ end
141
+ else
142
+ false
143
+ end
144
+ end
145
+ File.write(file, new_lines.join)
146
+ end
147
+ end
148
+
149
+ desc "collect check.tgz"
150
+ task :mk_check_tgz => [:init_check,
151
+ :final_check,
152
+ :strip_sharp_from_final,
153
+ :strip_separator_from_init
154
+ ] do
155
+ date = Date.today.strftime('%y%m%d')
156
+ t_name= "etymological_builder_check_#{date}.tgz"
157
+ dirs = "_stack_final_check_dirs _stack_init_check_dirs"
158
+ system "tar -cvf #{t_name} #{dirs}"
159
+ system "rm -rf #{dirs}"
160
+ exit
161
+ end
162
+ end