wordnet_japan_diagram 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/wordnet_japan_diagram +80 -1
- data/lib/wordnet_japan_diagram/cli.rb +17 -78
- data/lib/wordnet_japan_diagram/version.rb +2 -1
- data/lib/wordnet_japan_diagram.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 832db3f091de521d66ad98b8c4f96dce13faac4f3382ea687655a050aa429f36
|
4
|
+
data.tar.gz: 05b0444573db1a97aba7822c5ca42b0d88134d063234820c4f5ed74fdf868f21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 740f37b8eb9a737f8df225e29dac04678dfc9041ba05b34caa8a0cf061abc8147d44c0a10c22da0f935a5fe844b9ef153d7d675ca980e9c77a2c7126f8ee6283
|
7
|
+
data.tar.gz: e41261374019aba180c148fc03b0df284fee68477394722a4676247fb73edae63e5e3be7fe41d68bf64c83f4adf88c77a965b65acea2ba89c974bc2a20d6a998
|
data/exe/wordnet_japan_diagram
CHANGED
@@ -1,5 +1,84 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'choice'
|
4
|
+
|
3
5
|
require 'wordnet_japan_diagram'
|
4
6
|
|
5
|
-
|
7
|
+
Choice.options do
|
8
|
+
header ''
|
9
|
+
header 'Specific options:'
|
10
|
+
|
11
|
+
option :wordnet_japan_db_file_path do
|
12
|
+
long '--wordnet_japan_db_file_path=text'
|
13
|
+
desc "Sets wordnet japan db file path\n" \
|
14
|
+
' default: ./wnjpn.db'
|
15
|
+
default 'wnjpn.db'
|
16
|
+
end
|
17
|
+
|
18
|
+
option :search_word, required: true do
|
19
|
+
long '--search_word=text'
|
20
|
+
desc '[Required] Sets japanese word to search'
|
21
|
+
validate /\p{Hiragana}+|\p{Katakana}+|\p{Han}+/
|
22
|
+
end
|
23
|
+
|
24
|
+
option :graph_rankdir do
|
25
|
+
long '--graph_rankdir=[TB|BT|LR|RL]'
|
26
|
+
desc "Sets direction of graph layout\n" \
|
27
|
+
" default: BT\n" \
|
28
|
+
" TB: Top to bottom\n" \
|
29
|
+
" BT: Bottom to top\n" \
|
30
|
+
" LR: Left to right\n" \
|
31
|
+
' RL: Right to left'
|
32
|
+
default 'BT'
|
33
|
+
valid %w(TB BT LR RL)
|
34
|
+
end
|
35
|
+
|
36
|
+
option :node_contents do
|
37
|
+
long '--node_contents=[synset|synset_and_words]'
|
38
|
+
desc "Sets node contents\n" \
|
39
|
+
' default: synset_and_words'
|
40
|
+
default 'synset_and_words'
|
41
|
+
valid %w(synset synset_and_words)
|
42
|
+
end
|
43
|
+
|
44
|
+
option :height_from_target do
|
45
|
+
long '--height_from_target=number'
|
46
|
+
desc 'Sets height from target node'
|
47
|
+
validate /\d+/
|
48
|
+
end
|
49
|
+
|
50
|
+
option :depth_from_target do
|
51
|
+
long '--depth_from_target=number'
|
52
|
+
desc 'Sets depth from target node'
|
53
|
+
validate /\d+/
|
54
|
+
end
|
55
|
+
|
56
|
+
option :output_diagram_path do
|
57
|
+
long '--output_diagram_path=text'
|
58
|
+
desc "Sets output diagram path (The file extension is either .pdf, .png, .jpg, or .svg)\n" \
|
59
|
+
' default: wordnet_japan_diagram_[%Y%m%d%H%M%S].png'
|
60
|
+
default "wordnet_japan_diagram_#{Time.current.strftime('%Y%m%d%H%M%S')}.png"
|
61
|
+
validate /[pdf|png|jpg|svg]$/
|
62
|
+
end
|
63
|
+
|
64
|
+
separator ''
|
65
|
+
separator 'Common options: '
|
66
|
+
|
67
|
+
option :help do
|
68
|
+
long '--help'
|
69
|
+
desc 'Show this options information'
|
70
|
+
end
|
71
|
+
|
72
|
+
option :version do
|
73
|
+
short '-v'
|
74
|
+
long '--version'
|
75
|
+
desc 'Show version and quit.'
|
76
|
+
action do
|
77
|
+
require 'wordnet_japan_diagram/version'
|
78
|
+
puts WordnetJapanDiagram::BANNER
|
79
|
+
exit
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
WordnetJapanDiagram::CLI.execute(options: Choice.choices)
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'choice'
|
4
|
-
|
5
3
|
require_relative 'command_options'
|
6
4
|
require_relative 'diagram_creater'
|
7
5
|
|
@@ -12,90 +10,31 @@ require_relative 'wordnet_japan/synset'
|
|
12
10
|
require_relative 'wordnet_japan/synset_def'
|
13
11
|
require_relative 'wordnet_japan/word'
|
14
12
|
|
15
|
-
Choice.options do
|
16
|
-
header ''
|
17
|
-
header 'Specific options:'
|
18
|
-
|
19
|
-
option :wordnet_japan_db_file_path do
|
20
|
-
long '--wordnet_japan_db_file_path=text'
|
21
|
-
desc "Sets wordnet japan db file path\n" \
|
22
|
-
' default: ./wnjpn.db'
|
23
|
-
default 'wnjpn.db'
|
24
|
-
end
|
25
|
-
|
26
|
-
option :search_word, required: true do
|
27
|
-
long '--search_word=text'
|
28
|
-
desc '[Required] Sets japanese word to search'
|
29
|
-
validate /\p{Hiragana}+|\p{Katakana}+|\p{Han}+/
|
30
|
-
end
|
31
|
-
|
32
|
-
option :graph_rankdir do
|
33
|
-
long '--graph_rankdir=[TB|BT|LR|RL]'
|
34
|
-
desc "Sets direction of graph layout\n" \
|
35
|
-
" default: BT\n" \
|
36
|
-
" TB: Top to bottom\n" \
|
37
|
-
" BT: Bottom to top\n" \
|
38
|
-
" LR: Left to right\n" \
|
39
|
-
' RL: Right to left'
|
40
|
-
default 'BT'
|
41
|
-
valid %w(TB BT LR RL)
|
42
|
-
end
|
43
|
-
|
44
|
-
option :node_contents do
|
45
|
-
long '--node_contents=[synset|synset_and_words]'
|
46
|
-
desc "Sets node contents\n" \
|
47
|
-
' default: synset_and_words'
|
48
|
-
default 'synset_and_words'
|
49
|
-
valid %w(synset synset_and_words)
|
50
|
-
end
|
51
|
-
|
52
|
-
option :height_from_target do
|
53
|
-
long '--height_from_target=number'
|
54
|
-
desc 'Sets height from target node'
|
55
|
-
validate /\d+/
|
56
|
-
end
|
57
|
-
|
58
|
-
option :depth_from_target do
|
59
|
-
long '--depth_from_target=number'
|
60
|
-
desc 'Sets depth from target node'
|
61
|
-
validate /\d+/
|
62
|
-
end
|
63
|
-
|
64
|
-
option :output_diagram_path do
|
65
|
-
long '--output_diagram_path=text'
|
66
|
-
desc "Sets output diagram path (The file extension is either .pdf, .png, .jpg, or .svg)\n" \
|
67
|
-
' default: wordnet_japan_diagram_[%Y%m%d%H%M%S].png'
|
68
|
-
default "wordnet_japan_diagram_#{Time.current.strftime('%Y%m%d%H%M%S')}.png"
|
69
|
-
validate /[pdf|png|jpg|svg]$/
|
70
|
-
end
|
71
|
-
|
72
|
-
option :help do
|
73
|
-
long '--help'
|
74
|
-
desc 'Show this options information'
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
13
|
module WordnetJapanDiagram
|
79
14
|
class CLI
|
80
15
|
class << self
|
81
|
-
def execute
|
82
|
-
|
83
|
-
create_diagram
|
16
|
+
def execute(options:)
|
17
|
+
new(options).execute
|
84
18
|
end
|
19
|
+
end
|
85
20
|
|
86
|
-
|
21
|
+
def initialize(options)
|
22
|
+
@command_options = CommandOptions.new(options: options)
|
23
|
+
end
|
87
24
|
|
88
|
-
|
89
|
-
|
90
|
-
|
25
|
+
def execute
|
26
|
+
connect_database
|
27
|
+
create_diagram
|
28
|
+
end
|
91
29
|
|
92
|
-
|
93
|
-
DiagramCreater.new(command_options).create
|
94
|
-
end
|
30
|
+
private
|
95
31
|
|
96
|
-
|
97
|
-
|
98
|
-
|
32
|
+
def connect_database
|
33
|
+
WordnetJapan::Database.connect(@command_options)
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_diagram
|
37
|
+
DiagramCreater.new(@command_options).create
|
99
38
|
end
|
100
39
|
end
|
101
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wordnet_japan_diagram
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tommy-012
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|