rsyntaxtree 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +19 -3
- data/app.rb +2 -0
- data/bin/rsyntaxtree +3 -3
- data/lib/rsyntaxtree/version.rb +1 -1
- data/public/js/rsyntaxtree.js +6 -15
- data/rsyntaxtree.gemspec +1 -1
- data/views/index.haml +6 -7
- data/views/layout.haml +10 -11
- metadata +13 -13
data/README.md
CHANGED
@@ -4,7 +4,7 @@ RSyntaxTree is a graphical syntax tree generator written in the Ruby programming
|
|
4
4
|
|
5
5
|
While phpSyntaxTree does not accept **multi-byte characters** as those in Chinese, Japanese, and Korean, RSyntaxTree handles text of any language as long as encoded in UTF-8 and fonts have been installed. Additionally, RSyntaxTree can output **symmetrized** tree diagrams, a functionality that is not implemented in phpSyntaxTree.
|
6
6
|
|
7
|
-
RSyntaxTree consists of an easy-to-use command-line app and a web-based
|
7
|
+
RSyntaxTree consists of an easy-to-use command-line app and a web-based interface made with [Sinatra](http://www.sinatrarb.com) web framework.
|
8
8
|
|
9
9
|
### Web Interface
|
10
10
|
|
@@ -23,10 +23,10 @@ For the command-line interface, type `$rsyntaxtree -h` after installation. Here'
|
|
23
23
|
RSyntaxTree, (linguistic) syntax tree generator written in Ruby.
|
24
24
|
|
25
25
|
Usage:
|
26
|
-
rsyntaxtree [options] "[
|
26
|
+
rsyntaxtree [options] "[VP [VP [V set] [NP bracket notation]] [ADV here]]"
|
27
27
|
where [options] are:
|
28
28
|
--outdir, -o <s>: Output directory (default: present working directory) (default: ./)
|
29
|
-
--format, -f <s>: Output format: png or svg (default: png)
|
29
|
+
--format, -f <s>: Output format: png, pdf, or svg (default: png)
|
30
30
|
--leafstyle, -l <s>: visual style of tree leaves: triangle, bar, or nothing (default: triangle)
|
31
31
|
--fontstyle, -n <s>: Font style: sans-serif, serif, jp-gothic, jp-mincho, cjk (default: cjk)
|
32
32
|
--font, -t <s>: Path to a ttf font used to generate tree
|
@@ -37,6 +37,22 @@ For the command-line interface, type `$rsyntaxtree -h` after installation. Here'
|
|
37
37
|
--version, -v: Print version and exit
|
38
38
|
--help, -h: Show this message
|
39
39
|
|
40
|
+
### Tips
|
41
|
+
|
42
|
+
Every branch or leaf of a tree must belong to a node. To create a node, place a label right next to the opening bracket. Arbitrary number of branches can follow with a preceding space. When a node has one and only one leaf and the leaf contains more than one space characters, the node is treated as a phrase and a triangle (not just a vertical bar) will be between the node label and the leaf).
|
43
|
+
|
44
|
+
You can put a subscript to any node by putting the _ character between the main label and the subscript. For example, NP_TOP will be rendered as NP<sub>TOP</sub>. Or you can select the “Auto subscript” option so that nodes of the same label will be automatically numbered. (e.g. NP<sub>1</sub>, NP<sub>2</sub>)</p>
|
45
|
+
|
46
|
+
### Example
|
47
|
+
|
48
|
+
Bracket notation (auto-subscript-on):
|
49
|
+
|
50
|
+
[NP [NP [ART a] [N table]] [PP [P near] [NP [ART the] [N door]]]]
|
51
|
+
|
52
|
+
Resulting PNG
|
53
|
+
|
54
|
+
![a table near the door](http://yohasebe.com/img/rsyntaxtree_example.png)
|
55
|
+
|
40
56
|
### Development
|
41
57
|
|
42
58
|
For the latest updates and downloads please visit http://github.com/yohasebe/rsyntaxtree
|
data/app.rb
CHANGED
data/bin/rsyntaxtree
CHANGED
@@ -16,15 +16,15 @@ Usage:
|
|
16
16
|
where [options] are:
|
17
17
|
EOS
|
18
18
|
|
19
|
-
opt :outdir, "Output directory
|
19
|
+
opt :outdir, "Output directory",
|
20
20
|
:default => "./"
|
21
21
|
opt :format, "Output format: png, pdf, or svg",
|
22
22
|
:default => "png"
|
23
23
|
opt :leafstyle, "visual style of tree leaves: triangle, bar, or nothing",
|
24
24
|
:default => "triangle"
|
25
|
-
opt :fontstyle, "Font style: sans-serif, serif, jp-gothic, jp-mincho, cjk",
|
25
|
+
opt :fontstyle, "Font style (available when ttf font is specified): sans-serif, serif, jp-gothic, jp-mincho, cjk",
|
26
26
|
:default => "cjk"
|
27
|
-
opt :font, "Path to a ttf font used to generate tree", :type => String
|
27
|
+
opt :font, "Path to a ttf font used to generate tree (optional)", :type => String
|
28
28
|
opt :fontsize, "Font size: 8-20",
|
29
29
|
:default => 16
|
30
30
|
opt :color, "Color text and bars: on or off",
|
data/lib/rsyntaxtree/version.rb
CHANGED
data/public/js/rsyntaxtree.js
CHANGED
@@ -19,7 +19,7 @@ $(function(){
|
|
19
19
|
function draw_graph(data){
|
20
20
|
$("#result").html("<img id='tree_image'>");
|
21
21
|
$.ajax({
|
22
|
-
url: '
|
22
|
+
url: 'draw_png',
|
23
23
|
type: 'POST',
|
24
24
|
data: make_params(data),
|
25
25
|
success: function (png) {
|
@@ -28,15 +28,6 @@ $(function(){
|
|
28
28
|
});
|
29
29
|
}
|
30
30
|
|
31
|
-
// function draw_graph(data){
|
32
|
-
// $("#result").html("<img id='tree_image' src='/draw_png?" + make_params(data) + "'>");
|
33
|
-
// }
|
34
|
-
|
35
|
-
function download_svg(data){
|
36
|
-
var params = make_params(data)
|
37
|
-
$.post('/svg', params);
|
38
|
-
}
|
39
|
-
|
40
31
|
function escape_chrs(data){
|
41
32
|
data = data.replace(/\&/g, "-AMP-").replace(/\'/g, "-PRIME-").replace(/\;/g, "-SCOLON");
|
42
33
|
data = $('<div/>').text(data).html();
|
@@ -44,7 +35,7 @@ $(function(){
|
|
44
35
|
}
|
45
36
|
|
46
37
|
function postForm(data, format){
|
47
|
-
$('<form/>', {action: '
|
38
|
+
$('<form/>', {action: 'download_' + format, method: 'POST'})
|
48
39
|
.append($('<input/>', {type: 'hidden', name: 'data', value: data}))
|
49
40
|
.append($('<input/>', {type: 'hidden', name: 'format', value: $("select[name=format]").val()}))
|
50
41
|
.append($('<input/>', {type: 'hidden', name: 'leafstyle', value: $("select[name=leafstyle]").val()}))
|
@@ -63,7 +54,7 @@ $(function(){
|
|
63
54
|
data = escape_chrs(data);
|
64
55
|
$.ajax({
|
65
56
|
type: "POST",
|
66
|
-
url:"
|
57
|
+
url:"check",
|
67
58
|
data:"data=" + data,
|
68
59
|
success: function(msg){
|
69
60
|
if(msg != "true"){
|
@@ -81,7 +72,7 @@ $(function(){
|
|
81
72
|
data = escape_chrs(data);
|
82
73
|
$.ajax({
|
83
74
|
type: "POST",
|
84
|
-
url:"
|
75
|
+
url:"check",
|
85
76
|
data:"data=" + data,
|
86
77
|
success: function(msg){
|
87
78
|
if(msg != "true"){
|
@@ -100,7 +91,7 @@ $(function(){
|
|
100
91
|
data = escape_chrs(data);
|
101
92
|
$.ajax({
|
102
93
|
type: "POST",
|
103
|
-
url:"
|
94
|
+
url:"check",
|
104
95
|
data:"data=" + data,
|
105
96
|
success: function(msg){
|
106
97
|
if(msg != "true"){
|
@@ -116,7 +107,7 @@ $(function(){
|
|
116
107
|
$("#check").click(function(){
|
117
108
|
$.ajax({
|
118
109
|
type: "POST",
|
119
|
-
url:"
|
110
|
+
url:"check",
|
120
111
|
data:"data=" + escape_chrs($("#data").val()),
|
121
112
|
success: function(msg){
|
122
113
|
if(msg == "true"){
|
data/rsyntaxtree.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.version = RSyntaxTree::VERSION
|
9
9
|
s.authors = ["Yoichiro Hasebe"]
|
10
10
|
s.email = ["yohasebe@gmail.com"]
|
11
|
-
s.homepage = ""
|
11
|
+
s.homepage = "http://github.com/yohasebe/rsyntaxtree"
|
12
12
|
s.summary = %q{RSyntaxTree is a graphical syntax tree generator written in Ruby}
|
13
13
|
s.description = %q{Yet another syntax tree generator made with Ruby and RMagick}
|
14
14
|
|
data/views/index.haml
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
%option{:value => "bar"}Bar
|
21
21
|
%option{:value => "nothing"}Nothing
|
22
22
|
.span2
|
23
|
-
%h4
|
23
|
+
%h4 Font-style
|
24
24
|
%select{:name => "fontstyle", :style => "width:110px;"}
|
25
25
|
%option{:value => "sans-serif"}San-Serif
|
26
26
|
%option{:value => "serif"}Serif
|
@@ -28,7 +28,7 @@
|
|
28
28
|
%option{:value => "jp-mincho"}JP-Mincho
|
29
29
|
%option{:value => "cjk"}CJK
|
30
30
|
.span2
|
31
|
-
%h4
|
31
|
+
%h4 Font-size
|
32
32
|
%select{:name => "fontsize", :style => "width:60px;"}
|
33
33
|
%option{:value => "8"}8
|
34
34
|
%option{:value => "10"}10
|
@@ -93,7 +93,7 @@
|
|
93
93
|
%a{:href =>'http://github.com/yohasebe/rsyntaxtree'}http://github.com/yohasebe/rsyntaxtree .
|
94
94
|
%p
|
95
95
|
RSyntaxTree is distributed under
|
96
|
-
%a{:href => 'http://www.
|
96
|
+
%a{:href => 'http://www.opensource.org/licenses/mit-license.php'}the MIT License.
|
97
97
|
|
98
98
|
.span6
|
99
99
|
%h2
|
@@ -117,13 +117,12 @@
|
|
117
117
|
label will be automatically numbered. (e.g. NP<sub>1</sub>, NP<sub>2</sub>)</p>
|
118
118
|
|
119
119
|
%p
|
120
|
-
RSyntaxTree is capable of generating PNG and SVG files.
|
120
|
+
RSyntaxTree is not capable of generating PNG, PDF and SVG files. SVG is very convenient
|
121
121
|
for those who want to modify output images on third party vector graphic software
|
122
|
-
(such as Adobe Illustrator and Microsoft Visio).
|
123
|
-
below the (non SVG) syntax tree image.
|
122
|
+
(such as Adobe Illustrator and Microsoft Visio).
|
124
123
|
|
125
124
|
%p
|
126
|
-
Options “Font”, “
|
125
|
+
Options “Font-style”, “Font-size”, and “Color” would be
|
127
126
|
self-explanatory. You can change the appearance of the resulting image to suit your purpose.
|
128
127
|
|
129
128
|
%hr
|
data/views/layout.haml
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
%meta{:name => "description", :content => ""}
|
7
7
|
%meta{:name => "author", :content => ""}
|
8
8
|
|
9
|
-
%link{ :href => "
|
9
|
+
%link{ :href => "bootstrap/css/bootstrap.css", :type => "text/css", :rel => "stylesheet" }
|
10
10
|
|
11
11
|
:plain
|
12
12
|
<style type="text/css">
|
@@ -16,8 +16,8 @@
|
|
16
16
|
}
|
17
17
|
</style>
|
18
18
|
|
19
|
-
%link{ :href => "
|
20
|
-
%link{ :href => "
|
19
|
+
%link{ :href => "bootstrap/css/bootstrap-responsive.css", :type => "text/css", :rel => "stylesheet" }
|
20
|
+
%link{ :href => "css/rsyntaxtree.css", :type => "text/css", :rel => "stylesheet" }
|
21
21
|
|
22
22
|
:plain
|
23
23
|
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
@@ -26,17 +26,16 @@
|
|
26
26
|
<![endif]-->
|
27
27
|
|
28
28
|
/ Le fav and touch icons
|
29
|
-
%link{ rel: "apple-touch-icon", href: "
|
30
|
-
%link{ rel: "shortcut icon", href: "
|
31
|
-
%link{ rel: "apple-touch-icon", sizes: "72x72", href: "
|
32
|
-
%link{ rel: "apple-touch-icon", sizes: "114x114", href: "
|
29
|
+
%link{ rel: "apple-touch-icon", href: "bootstrap/images/apple-touch-icon.png"}
|
30
|
+
%link{ rel: "shortcut icon", href: "bootstrap/images/favicon.ico"}
|
31
|
+
%link{ rel: "apple-touch-icon", sizes: "72x72", href: "bootstrap/images/apple-touch-icon-72x72.png"}
|
32
|
+
%link{ rel: "apple-touch-icon", sizes: "114x114", href: "bootstrap/images/apple-touch-icon-114x114.png"}
|
33
33
|
|
34
34
|
%body
|
35
35
|
%div= haml :navbar
|
36
36
|
%div= yield
|
37
37
|
|
38
38
|
/ Placed at the end of the document so the pages load faster
|
39
|
-
%script{ :type => "text/javascript", :src =>"
|
40
|
-
%script{ :type => "text/javascript", :src =>"
|
41
|
-
%script{ :type => "text/javascript", :src =>"
|
42
|
-
|
39
|
+
%script{ :type => "text/javascript", :src =>"bootstrap/js/jquery.js"}
|
40
|
+
%script{ :type => "text/javascript", :src =>"bootstrap/js/bootstrap.js"}
|
41
|
+
%script{ :type => "text/javascript", :src =>"js/rsyntaxtree.js"}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsyntaxtree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rmagick
|
16
|
-
requirement: &
|
16
|
+
requirement: &70171855522580 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70171855522580
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sinatra
|
27
|
-
requirement: &
|
27
|
+
requirement: &70171855521840 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70171855521840
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: haml
|
38
|
-
requirement: &
|
38
|
+
requirement: &70171855521120 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70171855521120
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: shotgun
|
49
|
-
requirement: &
|
49
|
+
requirement: &70171855520620 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70171855520620
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: trollop
|
60
|
-
requirement: &
|
60
|
+
requirement: &70171855520160 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70171855520160
|
69
69
|
description: Yet another syntax tree generator made with Ruby and RMagick
|
70
70
|
email:
|
71
71
|
- yohasebe@gmail.com
|
@@ -112,7 +112,7 @@ files:
|
|
112
112
|
- views/index.haml
|
113
113
|
- views/layout.haml
|
114
114
|
- views/navbar.haml
|
115
|
-
homepage:
|
115
|
+
homepage: http://github.com/yohasebe/rsyntaxtree
|
116
116
|
licenses: []
|
117
117
|
post_install_message:
|
118
118
|
rdoc_options: []
|