rsyntaxtree 0.6.7 → 0.6.91
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile +7 -2
- data/lib/rsyntaxtree.rb +23 -2
- data/lib/rsyntaxtree/imgutils.rb +1 -1
- data/lib/rsyntaxtree/string_parser.rb +1 -1
- data/lib/rsyntaxtree/tree_graph.rb +1 -1
- data/lib/rsyntaxtree/version.rb +1 -1
- data/public/js/rsyntaxtree.js +7 -2
- data/views/footer.haml +1 -1
- data/views/index.haml +3 -2
- data/views/layout.haml +7 -5
- data/views/navbar.haml +1 -1
- metadata +3 -5
- data/bin/linktree.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4da741645d3844ce99a54efe3df6e8554eeb2b21
|
4
|
+
data.tar.gz: 727dcfd111c5ec58240ee5caf4f417c4b195072f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b862ff816bd3a129b40b4708aa19d587cd1f8e7f92b9a1a480609b3b5cd99bec120cdb46bd84a1a7e442eed25b297c379c235d73fa6765b24ef1072ea61414fc
|
7
|
+
data.tar.gz: a3e621ffc45cb6a17e0d0318c7a43039856964ca771f2c717a42001d8823eea0def499cee932a8d946b6917fbbf988466004e2747110f6c13f3e1f9be5f405b6
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/lib/rsyntaxtree.rb
CHANGED
@@ -43,6 +43,20 @@ require 'version'
|
|
43
43
|
|
44
44
|
FONT_DIR = File.expand_path(File.dirname(__FILE__) + "/../fonts")
|
45
45
|
|
46
|
+
##################################################
|
47
|
+
if !development?
|
48
|
+
# load and store Google Analytics code, if any, to a variable
|
49
|
+
ga_path = File.dirname(__FILE__) + "/../google_analytics_tracking_code"
|
50
|
+
if File.exists?(ga_path)
|
51
|
+
gfile = File.open(ga_path, "r:UTF-8:UTF-8")
|
52
|
+
$GOOGLE_CODE = gfile.read
|
53
|
+
gfile.close
|
54
|
+
else
|
55
|
+
$GOOGLE_CODE = ""
|
56
|
+
end
|
57
|
+
end
|
58
|
+
##################################################
|
59
|
+
|
46
60
|
class RSGenerator
|
47
61
|
include Helpers
|
48
62
|
def initialize(params = {})
|
@@ -51,7 +65,12 @@ class RSGenerator
|
|
51
65
|
case key
|
52
66
|
when "data"
|
53
67
|
data = URI.unescape(value)
|
54
|
-
data = data.gsub('-AMP-', '&')
|
68
|
+
data = data.gsub('-AMP-', '&')
|
69
|
+
.gsub('-PERCENT-', "%")
|
70
|
+
.gsub('-PRIME-', "'")
|
71
|
+
.gsub('-SCOLON-', ';')
|
72
|
+
.gsub('-OABRACKET-', '<')
|
73
|
+
.gsub('-CABRACKET-', '>')
|
55
74
|
new_params[key] = data
|
56
75
|
when "symmetrize", "color", "autosub"
|
57
76
|
new_params[key] = value == "on"? true : false
|
@@ -72,6 +91,8 @@ class RSGenerator
|
|
72
91
|
new_params["font"] = FONT_DIR + "/ArialUnicode.ttf"
|
73
92
|
elsif value == "tnr"
|
74
93
|
new_params["font"] = FONT_DIR + "/TimesNewRoman.ttf"
|
94
|
+
elsif value == "noto"
|
95
|
+
new_params["font"] = FONT_DIR + "/NotoSansCJK.ttc"
|
75
96
|
end
|
76
97
|
else
|
77
98
|
new_params[key] = value
|
@@ -122,7 +143,7 @@ class RSGenerator
|
|
122
143
|
|
123
144
|
def draw_svg
|
124
145
|
@params["format"] = "svg"
|
125
|
-
sp = StringParser.new(@params["data"].gsub('&', '&'))
|
146
|
+
sp = StringParser.new(@params["data"].gsub('&', '&').gsub('%', '%'))
|
126
147
|
sp.parse
|
127
148
|
sp.auto_subscript if @params["autosub"]
|
128
149
|
elist = sp.get_elementlist
|
data/lib/rsyntaxtree/imgutils.rb
CHANGED
@@ -49,7 +49,7 @@ class StringParser
|
|
49
49
|
attr_accessor :data, :elist, :pos, :id, :level, :tncnt
|
50
50
|
def initialize(str)
|
51
51
|
# Clean up the data a little to make processing easier
|
52
|
-
string = str.gsub(/\t/, "")
|
52
|
+
string = str.gsub(/\t/, "") rescue ""
|
53
53
|
string.gsub!(/\s+/, " ")
|
54
54
|
string.gsub!(/\] \[/, "][")
|
55
55
|
string.gsub!(/ \[/, "[")
|
data/lib/rsyntaxtree/version.rb
CHANGED
data/public/js/rsyntaxtree.js
CHANGED
@@ -33,7 +33,12 @@ $(function(){
|
|
33
33
|
}
|
34
34
|
|
35
35
|
function escape_chrs(data){
|
36
|
-
data = data.replace(/\&/g, "-AMP-")
|
36
|
+
data = data.replace(/\&/g, "-AMP-")
|
37
|
+
.replace(/\%/g, '-PERCENT-')
|
38
|
+
.replace(/\'/g, "-PRIME-")
|
39
|
+
.replace(/\;/g, "-SCOLON-")
|
40
|
+
.replace(/\</g, "-OABRACKET-")
|
41
|
+
.replace(/\>/g, "-CABRACKET-");
|
37
42
|
data = $('<div/>').text(data).html();
|
38
43
|
return data;
|
39
44
|
}
|
@@ -129,4 +134,4 @@ $(function(){
|
|
129
134
|
});
|
130
135
|
|
131
136
|
|
132
|
-
});
|
137
|
+
});
|
data/views/footer.haml
CHANGED
data/views/index.haml
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#alert{:style => "height:20px;"}
|
12
12
|
.span12
|
13
13
|
%textarea.span12{:id => "data", :cols => 100, :style => "font-size: 11pt; height: 4em;line-height: 140%;"}
|
14
|
-
[S [NP RSyntaxTree^][VP [V generates][NP multilingual syntax trees]]]
|
14
|
+
[S [NP RSyntaxTree^][VP [V generates][NP \[multilingual\] syntax trees]]]
|
15
15
|
.row
|
16
16
|
.span2
|
17
17
|
%h4 Leaf-style
|
@@ -23,13 +23,14 @@
|
|
23
23
|
.span2
|
24
24
|
%h4 Font-style
|
25
25
|
%select{:name => "fontstyle", :style => "width:110px;"}
|
26
|
-
%option{:value => "cjk"}CJK
|
27
26
|
%option{:value => "sans-serif"}San-Serif
|
28
27
|
%option{:value => "serif"}Serif
|
29
28
|
%option{:value => "jp-gothic"}JP-Gothic
|
30
29
|
%option{:value => "jp-mincho"}JP-Mincho
|
30
|
+
%option{:value => "cjk"}CJK
|
31
31
|
%option{:value => "aru"}ARU
|
32
32
|
%option{:value => "tnr"}TNR
|
33
|
+
%option{:value => "noto"}NOTO
|
33
34
|
.span2
|
34
35
|
%h4 Font-size
|
35
36
|
%select{:name => "fontsize", :style => "width:60px;"}
|
data/views/layout.haml
CHANGED
@@ -18,18 +18,20 @@
|
|
18
18
|
|
19
19
|
%link{ :href => $SUB_DIRECTORY + "/bootstrap/css/bootstrap-responsive.css", :type => "text/css", :rel => "stylesheet" }
|
20
20
|
%link{ :href => $SUB_DIRECTORY + "/css/rsyntaxtree.css", :type => "text/css", :rel => "stylesheet" }
|
21
|
+
|
21
22
|
|
22
23
|
:plain
|
24
|
+
#{ $GOOGLE_CODE }
|
23
25
|
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
24
26
|
<!--[if lt IE 9]>
|
25
27
|
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
26
28
|
<![endif]-->
|
27
29
|
|
28
|
-
/ Le fav and touch icons
|
29
|
-
%link{ rel
|
30
|
-
%link{ rel
|
31
|
-
%link{ rel
|
32
|
-
%link{ rel
|
30
|
+
-# / Le fav and touch icons
|
31
|
+
-# %link{ :rel => "apple-touch-icon", :href => $SUB_DIRECTORY + "/bootstrap/images/apple-touch-icon.png"}
|
32
|
+
-# %link{ :rel => "shortcut icon", :href => $SUB_DIRECTORY + "/bootstrap/images/favicon.ico"}
|
33
|
+
-# %link{ :rel => "apple-touch-icon", :sizes => "72x72", :href => $SUB_DIRECTORY + "/bootstrap/images/apple-touch-icon-72x72.png"}
|
34
|
+
-# %link{ :rel => "apple-touch-icon", :sizes => "114x114", :href => $SUB_DIRECTORY + "/bootstrap/images/apple-touch-icon-114x114.png"}
|
33
35
|
|
34
36
|
%body
|
35
37
|
%div#top{:data => {:subdir => $SUB_DIRECTORY}}
|
data/views/navbar.haml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsyntaxtree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.91
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoichiro Hasebe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rmagick
|
@@ -70,7 +70,6 @@ description: Yet another syntax tree generator made with Ruby and RMagick
|
|
70
70
|
email:
|
71
71
|
- yohasebe@gmail.com
|
72
72
|
executables:
|
73
|
-
- linktree.rb
|
74
73
|
- rsyntaxtree
|
75
74
|
extensions: []
|
76
75
|
extra_rdoc_files: []
|
@@ -80,7 +79,6 @@ files:
|
|
80
79
|
- README.md
|
81
80
|
- Rakefile
|
82
81
|
- app.rb
|
83
|
-
- bin/linktree.rb
|
84
82
|
- bin/rsyntaxtree
|
85
83
|
- config.ru
|
86
84
|
- fonts/DroidSans.ttf
|
@@ -133,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
131
|
version: '0'
|
134
132
|
requirements: []
|
135
133
|
rubyforge_project: rsyntaxtree
|
136
|
-
rubygems_version: 2.
|
134
|
+
rubygems_version: 2.6.8
|
137
135
|
signing_key:
|
138
136
|
specification_version: 4
|
139
137
|
summary: RSyntaxTree is a graphical syntax tree generator written in Ruby
|
data/bin/linktree.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'linkparser'
|
2
|
-
require 'rsyntaxtree'
|
3
|
-
|
4
|
-
dict = LinkParser::Dictionary.new
|
5
|
-
sent = dict.parse( "I wonder if Tom knows Jill sneezed her handkerchief off the table" )
|
6
|
-
sent.subject # => "people"
|
7
|
-
sent.verb # => "use"
|
8
|
-
sent.object # => "Ruby"
|
9
|
-
bracketed = sent.constituent_tree_string(2)
|
10
|
-
bracketed = bracketed.chomp.gsub(/ [A-Z]+\]/){"]"}
|
11
|
-
bracketed = bracketed.gsub(/VP (.+?) \[NP/) do |text|
|
12
|
-
"VP [V #{$1}] [NP"
|
13
|
-
end
|
14
|
-
|
15
|
-
p bracketed
|
16
|
-
opts = {}
|
17
|
-
opts["data"] = bracketed
|
18
|
-
rsg = RSGenerator.new(opts)
|
19
|
-
outfile = File.new(File.expand_path("~/Desktop/test.png"), "wb")
|
20
|
-
outfile.write rsg.draw_png
|