rsyntaxtree 1.0.8 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +77 -0
- data/.solargraph.yml +22 -0
- data/.tags +211 -10
- data/Gemfile +10 -5
- data/README.md +3 -2
- data/Rakefile +3 -1
- data/bin/rsyntaxtree +42 -50
- data/docs/Gemfile +3 -1
- data/docs/_layouts/default.html +1 -1
- data/lib/rsyntaxtree/base_graph.rb +260 -264
- data/lib/rsyntaxtree/element.rb +167 -179
- data/lib/rsyntaxtree/elementlist.rb +105 -124
- data/lib/rsyntaxtree/markup_parser.rb +82 -93
- data/lib/rsyntaxtree/string_parser.rb +221 -237
- data/lib/rsyntaxtree/svg_graph.rb +158 -197
- data/lib/rsyntaxtree/utils.rb +59 -63
- data/lib/rsyntaxtree/version.rb +3 -2
- data/lib/rsyntaxtree.rb +174 -177
- data/rsyntaxtree.gemspec +10 -10
- data/test/markup_parser_test.rb +3 -2
- metadata +23 -21
data/Gemfile
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
gem
|
6
|
-
|
3
|
+
# source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in ruby-spacy.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "optimist"
|
9
|
+
gem "parslet"
|
10
|
+
gem "rmagick"
|
11
|
+
gem "rsvg2"
|
data/README.md
CHANGED
@@ -72,7 +72,8 @@ For the command-line interface, type `$rsyntaxtree -h` after installation. Here'
|
|
72
72
|
RSyntaxTree, (linguistic) syntax tree generator written in Ruby.
|
73
73
|
|
74
74
|
Usage:
|
75
|
-
rsyntaxtree [options] "[VP [VP [V set] [NP bracket notation]] [ADV here]]"
|
75
|
+
1) rsyntaxtree [options] "[VP [VP [V set] [NP bracket notation]] [ADV here]]"
|
76
|
+
2) rsyntaxtree [options] "/path/to/text/file"
|
76
77
|
where [options] are:
|
77
78
|
-o, --outdir=<s> Output directory (default: ./)
|
78
79
|
-f, --format=<s> Output format: png, gif, jpg, pdf, or svg (default: png)
|
@@ -87,7 +88,7 @@ where [options] are:
|
|
87
88
|
-r, --transparent=<s> Make background transparent: on or off (default: off)
|
88
89
|
-p, --polyline=<s> draw polyline connectors: on or off (default: off)
|
89
90
|
-e, --version Print version and exit
|
90
|
-
-h, --help Show this message
|
91
|
+
-h, --help Show this message
|
91
92
|
```
|
92
93
|
|
93
94
|
See the [documentation](https://yohasebe.github.io/rsyntaxtree/documentation) for more detailed info about the syntax.
|
data/Rakefile
CHANGED
data/bin/rsyntaxtree
CHANGED
@@ -1,66 +1,58 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
2
|
+
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
require 'rsyntaxtree'
|
4
|
+
require_relative '../lib/rsyntaxtree'
|
5
|
+
require_relative '../lib/rsyntaxtree/utils'
|
7
6
|
require 'optimist'
|
8
|
-
require 'utils'
|
9
7
|
|
10
|
-
opts = Optimist
|
11
|
-
version "RSyntaxTree #{RSyntaxTree::VERSION} (c)
|
12
|
-
banner
|
13
|
-
RSyntaxTree, (linguistic) syntax tree generator written in Ruby.
|
8
|
+
opts = Optimist.options do
|
9
|
+
version "RSyntaxTree #{RSyntaxTree::VERSION} (c) 2023 Yoichiro Hasebe"
|
10
|
+
banner <<~BANNER
|
11
|
+
RSyntaxTree, (linguistic) syntax tree generator written in Ruby.
|
14
12
|
|
15
|
-
Usage:
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
Usage:
|
14
|
+
1) rsyntaxtree [options] "[VP [VP [V set] [NP bracket notation]] [ADV here]]"
|
15
|
+
2) rsyntaxtree [options] "/path/to/text/file"
|
16
|
+
where [options] are:
|
17
|
+
BANNER
|
19
18
|
|
20
|
-
opt :outdir, "Output directory",
|
21
|
-
|
22
|
-
opt :
|
23
|
-
|
24
|
-
opt :
|
25
|
-
|
26
|
-
opt :
|
27
|
-
|
28
|
-
opt :
|
29
|
-
opt :
|
30
|
-
|
31
|
-
opt :
|
32
|
-
:default => 1
|
33
|
-
opt :vheight, "Connector Height: 0.5-5.0",
|
34
|
-
:default => 2.0
|
35
|
-
opt :color, "Color text and bars: on or off",
|
36
|
-
:default => "on"
|
37
|
-
opt :symmetrize, "Generate radically symmetrical, balanced tree: on or off",
|
38
|
-
:default => "off"
|
39
|
-
opt :transparent, "Make background transparent: on or off",
|
40
|
-
:default => "off"
|
41
|
-
opt :polyline, "draw polyline connectors: on or off",
|
42
|
-
:default => "off"
|
19
|
+
opt :outdir, "Output directory", default: "./"
|
20
|
+
opt :format, "Output format: png, gif, jpg, pdf, or svg", default: "png"
|
21
|
+
opt :leafstyle, "visual style of tree leaves: auto, triangle, bar, or nothing", default: "auto"
|
22
|
+
opt :fontstyle, "Font style (available when ttf font is specified): sans, serif, cjk", default: "sans"
|
23
|
+
opt :font, "Path to a ttf font used to generate tree (optional)", type: String
|
24
|
+
opt :fontsize, "Size: 8-26", default: 16
|
25
|
+
opt :margin, "Margin: 0-10", default: 1
|
26
|
+
opt :vheight, "Connector Height: 0.5-5.0", default: 2.0
|
27
|
+
opt :color, "Color text and bars: on or off", default: "on"
|
28
|
+
opt :symmetrize, "Generate radically symmetrical, balanced tree: on or off", default: "off"
|
29
|
+
opt :transparent, "Make background transparent: on or off", default: "off"
|
30
|
+
opt :polyline, "draw polyline connectors: on or off", default: "off"
|
43
31
|
end
|
44
32
|
|
45
|
-
Optimist
|
46
|
-
Optimist
|
47
|
-
Optimist
|
48
|
-
Optimist
|
49
|
-
Optimist
|
50
|
-
Optimist
|
51
|
-
Optimist
|
52
|
-
Optimist
|
53
|
-
Optimist
|
54
|
-
Optimist
|
55
|
-
Optimist
|
56
|
-
Optimist
|
33
|
+
Optimist.die :outdir, "must be an exsting directory path" unless FileTest.directory?(opts[:outdir])
|
34
|
+
Optimist.die :format, "must be png, jpg, gif, or svg" unless /\A(png|jpg|gif|pdf|svg)\z/ =~ opts[:format]
|
35
|
+
Optimist.die :leafstyle, "must be auto, triangle, bar, or nothing" unless /\A(auto|triangle|bar|nothing)\z/ =~ opts[:leafstyle]
|
36
|
+
Optimist.die :fontstyle, "must be sans, serif, cjk" unless /\A(sans|serif|cjk)\z/ =~ opts[:fontstyle]
|
37
|
+
Optimist.die :font, "must be path to an existing ttf font" if opts[:font] && !File.exist?(opts[:font])
|
38
|
+
Optimist.die :fontsize, "must be in the range of 8-26" unless opts[:fontsize] >= 8 && opts[:fontsize] <= 26
|
39
|
+
Optimist.die :color, "must be either on or off" unless /\A(on|off|true|false)\z/ =~ opts[:color]
|
40
|
+
Optimist.die :symmetrize, "must be either on or off" unless /\A(on|off|true|false)\z/ =~ opts[:symmetrize]
|
41
|
+
Optimist.die :margin, "must be in the range of 0-10" if opts[:margin].negative? || opts[:margin] > 10
|
42
|
+
Optimist.die :vheight, "must be in the range of 0.5-5.0" if opts[:vheight] < 0.5 || opts[:vheight] > 5.0
|
43
|
+
Optimist.die :transparent, "must be either on or off" unless /\A(on|off|true|false)\z/ =~ opts[:transparent]
|
44
|
+
Optimist.die :polyline, "must be either on or off" unless /\A(on|off|true|false)\z/ =~ opts[:polyline]
|
57
45
|
|
58
46
|
string_opts = {}
|
59
47
|
opts.each do |key, value|
|
60
48
|
string_opts[key.to_sym] = value unless key == :font && !value
|
61
49
|
end
|
62
50
|
|
63
|
-
data = ARGV[0]
|
51
|
+
data = if File.exist?(File.expand_path(ARGV[0]))
|
52
|
+
File.read ARGV[0]
|
53
|
+
else
|
54
|
+
ARGV[0]
|
55
|
+
end
|
64
56
|
|
65
57
|
begin
|
66
58
|
RSyntaxTree::RSGenerator.check_data(data)
|
@@ -89,7 +81,7 @@ begin
|
|
89
81
|
rescue RSTError => e
|
90
82
|
puts e
|
91
83
|
exit
|
92
|
-
rescue => e
|
84
|
+
rescue StandardError => e
|
93
85
|
p e
|
94
86
|
puts "Error: something unexpected occurred"
|
95
87
|
exit
|
data/docs/Gemfile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source "https://rubygems.org"
|
2
4
|
# Hello! This is where you manage which Jekyll version is used to run.
|
3
5
|
# When you want to use a different version, change it below, save the
|
@@ -27,5 +29,5 @@ platforms :mingw, :x64_mingw, :mswin, :jruby do
|
|
27
29
|
end
|
28
30
|
|
29
31
|
# Performance-booster for watching directories on Windows
|
30
|
-
gem "wdm", "~> 0.1.1", :
|
32
|
+
gem "wdm", "~> 0.1.1", platforms: [:mingw, :x64_mingw, :mswin]
|
31
33
|
gem "webrick"
|
data/docs/_layouts/default.html
CHANGED
@@ -35,7 +35,7 @@
|
|
35
35
|
{{ content }}
|
36
36
|
|
37
37
|
<footer class="site-footer" style='border-top-width: 0; text-align: center;'>
|
38
|
-
<div> <span class="site-footer-credits">© Yoichiro HASEBE 2009-
|
38
|
+
<div> <span class="site-footer-credits">© Yoichiro HASEBE 2009-2023</span></div>
|
39
39
|
{% include social_media_links.html %}
|
40
40
|
</footer>
|
41
41
|
</main>
|