ruby-sfst 0.2.0 → 0.3.0
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.
- data/CHANGELOG +1 -0
- data/README.rdoc +33 -8
- data/Rakefile +11 -18
- data/VERSION +1 -0
- data/ext/sfst_machine/.gitignore +3 -0
- data/ext/sfst_machine/sfst_machine.cc +15 -10
- data/lib/.gitignore +1 -0
- data/ruby-sfst.gemspec +58 -22
- data/test/.gitignore +1 -0
- metadata +55 -55
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -2,26 +2,51 @@
|
|
2
2
|
|
3
3
|
A wrapper for the Stuttgart Finite State Transducer Tools (SFST).
|
4
4
|
|
5
|
-
The wrapper is based on SFST 1.3.
|
5
|
+
The wrapper is based on SFST 1.3. See
|
6
|
+
http://www.ims.uni-stuttgart.de/projekte/gramotron/SOFTWARE/SFST.html for
|
7
|
+
details on how to obtain SFST and how to write SFST transducers.
|
6
8
|
|
7
9
|
== Installation
|
8
10
|
|
9
11
|
gem install ruby-sfst
|
10
12
|
|
11
|
-
==
|
13
|
+
== Usage
|
12
14
|
|
13
|
-
|
14
|
-
license of the SFST project.
|
15
|
+
If you have the following compiled as <tt>test.a</tt>
|
15
16
|
|
16
|
-
|
17
|
+
ALPHABET = [a-z]
|
18
|
+
$test$ = ({bar}:{foo} | {baz}:{foo})
|
19
|
+
$test$
|
20
|
+
|
21
|
+
it can be used like this:
|
22
|
+
|
23
|
+
fst = SFST::RegularTransducer.new("test.a")
|
24
|
+
fst.analyse('foo')
|
25
|
+
# => ['bar', 'baz']
|
26
|
+
fst.accepted_analysis?('foo')
|
27
|
+
# => true
|
28
|
+
fst.generate('bar')
|
29
|
+
# => ['foo']
|
30
|
+
fst.accepted_generating?('bar')
|
31
|
+
# => true
|
32
|
+
fst.generate_language { |f| p f }
|
33
|
+
# [["b", "f"], ["a", "o"], ["z", "o"]]
|
34
|
+
# [["b", "f"], ["a", "o"], ["r", "o"]]
|
17
35
|
|
18
|
-
|
19
|
-
|
36
|
+
You can also compile an SFST file. This requires the SFST tools to be
|
37
|
+
installed and available on the current search path.
|
38
|
+
|
39
|
+
SFST::compile("test.fst", "test.a", :compact => true)
|
20
40
|
|
21
41
|
Currently, <tt>ruby-sfst</tt> only supports simple compilation, analysis
|
22
|
-
and generation using regular and compact transducers. It also only
|
42
|
+
and generation using regular and compact transducers. It also only
|
23
43
|
supports UTF-8.
|
24
44
|
|
25
45
|
== Development
|
26
46
|
|
27
47
|
The project is hosted on github on http://github.com/mlj/ruby-sfst.
|
48
|
+
|
49
|
+
== License
|
50
|
+
|
51
|
+
As it includes the SFST code directly, the wrapper inherits the GPL2
|
52
|
+
license of the SFST project.
|
data/Rakefile
CHANGED
@@ -1,22 +1,15 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
1
|
begin
|
5
|
-
require '
|
6
|
-
|
7
|
-
|
8
|
-
p.
|
9
|
-
p.
|
2
|
+
require 'jeweler'
|
3
|
+
|
4
|
+
Jeweler::Tasks.new do |p|
|
5
|
+
p.name = "ruby-sfst"
|
6
|
+
p.summary = "Stuttgart Finite State Transducer Tools interface"
|
7
|
+
p.description = "A wrapper for the Stuttgart Finite State Transducer Tools (SFST)."
|
8
|
+
p.authors = ['Marius L. Jøhndal']
|
10
9
|
p.email = "mariuslj (at) ifi [dot] uio (dot) no"
|
11
|
-
p.
|
12
|
-
p.
|
13
|
-
p.rdoc_pattern = ["README.rdoc", "lib/*.rb"]
|
14
|
-
p.rubyforge_name = "sfst"
|
10
|
+
p.homepage = "http://github.com/mlj/ruby-sfst"
|
11
|
+
p.rubyforge_project = "sfst"
|
15
12
|
end
|
16
|
-
|
17
|
-
|
18
|
-
puts "You are missing a dependency required for meta-operations on this gem."
|
19
|
-
puts "#{boom.to_s.capitalize}."
|
13
|
+
rescue LoadError
|
14
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
20
15
|
end
|
21
|
-
|
22
|
-
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.3.0
|
@@ -5,6 +5,11 @@
|
|
5
5
|
#include "make-compact.h"
|
6
6
|
|
7
7
|
/*:enddoc:*/
|
8
|
+
|
9
|
+
#ifndef RSTRING_PTR /* Ruby 1.8 compatibility */
|
10
|
+
#define RSTRING_PTR(ptr) RSTRING(ptr)->ptr
|
11
|
+
#endif
|
12
|
+
|
8
13
|
extern Transducer *Result;
|
9
14
|
extern FILE *yyin;
|
10
15
|
int yyparse(void);
|
@@ -56,12 +61,12 @@ static VALUE compile(char *from_filename, char *to_filename, bool compact) // :n
|
|
56
61
|
|
57
62
|
static VALUE compile_regular(VALUE obj, VALUE from_filename, VALUE to_filename)
|
58
63
|
{
|
59
|
-
return compile(
|
64
|
+
return compile(RSTRING_PTR(from_filename), RSTRING_PTR(to_filename), false);
|
60
65
|
}
|
61
66
|
|
62
67
|
static VALUE compile_compact(VALUE obj, VALUE from_filename, VALUE to_filename)
|
63
68
|
{
|
64
|
-
return compile(
|
69
|
+
return compile(RSTRING_PTR(from_filename), RSTRING_PTR(to_filename), true);
|
65
70
|
}
|
66
71
|
|
67
72
|
static void compact_transducer_free(CompactTransducer *t)
|
@@ -86,10 +91,10 @@ static VALUE compact_transducer_init(VALUE obj, VALUE filename)
|
|
86
91
|
FILE *file;
|
87
92
|
CompactTransducer *t;
|
88
93
|
|
89
|
-
file = fopen(
|
94
|
+
file = fopen(RSTRING_PTR(filename), "rb");
|
90
95
|
|
91
96
|
if (!file) {
|
92
|
-
rb_raise(rb_eRuntimeError, "Unable to open SFST file %s",
|
97
|
+
rb_raise(rb_eRuntimeError, "Unable to open SFST file %s", RSTRING_PTR(filename));
|
93
98
|
}
|
94
99
|
|
95
100
|
try {
|
@@ -97,7 +102,7 @@ static VALUE compact_transducer_init(VALUE obj, VALUE filename)
|
|
97
102
|
fclose(file);
|
98
103
|
}
|
99
104
|
catch (const char *p) {
|
100
|
-
rb_raise(rb_eRuntimeError, "Unable to open SFST file %s: %s",
|
105
|
+
rb_raise(rb_eRuntimeError, "Unable to open SFST file %s: %s", RSTRING_PTR(filename), p);
|
101
106
|
}
|
102
107
|
|
103
108
|
DATA_PTR(obj) = t;
|
@@ -114,7 +119,7 @@ static VALUE compact_transducer_analyze(VALUE self, VALUE string)
|
|
114
119
|
Data_Get_Struct(self, CompactTransducer, t);
|
115
120
|
|
116
121
|
std::vector<CAnalysis> analyses;
|
117
|
-
t->analyze_string(
|
122
|
+
t->analyze_string(RSTRING_PTR(string), analyses);
|
118
123
|
|
119
124
|
for (size_t k = 0; k < analyses.size(); k++) {
|
120
125
|
accepted = Qtrue;
|
@@ -151,10 +156,10 @@ static VALUE regular_transducer_init(VALUE obj, VALUE filename)
|
|
151
156
|
FILE *file;
|
152
157
|
Transducer *t;
|
153
158
|
|
154
|
-
file = fopen(
|
159
|
+
file = fopen(RSTRING_PTR(filename), "rb");
|
155
160
|
|
156
161
|
if (!file) {
|
157
|
-
rb_raise(rb_eRuntimeError, "Unable to open SFST file %s",
|
162
|
+
rb_raise(rb_eRuntimeError, "Unable to open SFST file %s", RSTRING_PTR(filename));
|
158
163
|
}
|
159
164
|
|
160
165
|
try {
|
@@ -162,7 +167,7 @@ static VALUE regular_transducer_init(VALUE obj, VALUE filename)
|
|
162
167
|
fclose(file);
|
163
168
|
}
|
164
169
|
catch (const char *p) {
|
165
|
-
rb_raise(rb_eRuntimeError, "Unable to open SFST file %s: %s",
|
170
|
+
rb_raise(rb_eRuntimeError, "Unable to open SFST file %s: %s", RSTRING_PTR(filename), p);
|
166
171
|
}
|
167
172
|
|
168
173
|
DATA_PTR(obj) = t;
|
@@ -353,7 +358,7 @@ static bool _regular_transducer_yield(Transducer *t, Node *node, VALUE result_ar
|
|
353
358
|
static VALUE _regular_transducer_analyze_or_generate(Transducer *t, VALUE string, bool generate)
|
354
359
|
{
|
355
360
|
Transducer *a2, *a3;
|
356
|
-
Transducer a1(
|
361
|
+
Transducer a1(RSTRING_PTR(string), &(t->alphabet), false);
|
357
362
|
if (generate) {
|
358
363
|
a2 = &(a1 || *t);
|
359
364
|
a3 = &(a2->upper_level());
|
data/lib/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.so
|
data/ruby-sfst.gemspec
CHANGED
@@ -1,36 +1,72 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
1
4
|
# -*- encoding: utf-8 -*-
|
2
5
|
|
3
6
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
5
|
-
s.version = "0.
|
7
|
+
s.name = "ruby-sfst"
|
8
|
+
s.version = "0.3.0"
|
6
9
|
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">=
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
11
|
s.authors = ["Marius L. J\303\270hndal"]
|
9
|
-
s.date =
|
10
|
-
s.description =
|
11
|
-
s.email =
|
12
|
+
s.date = "2011-11-04"
|
13
|
+
s.description = "A wrapper for the Stuttgart Finite State Transducer Tools (SFST)."
|
14
|
+
s.email = "mariuslj (at) ifi [dot] uio (dot) no"
|
12
15
|
s.extensions = ["ext/sfst_machine/extconf.rb"]
|
13
|
-
s.extra_rdoc_files = [
|
14
|
-
|
15
|
-
|
16
|
-
s.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"CHANGELOG",
|
21
|
+
"Manifest",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"ext/sfst_machine/.gitignore",
|
26
|
+
"ext/sfst_machine/alphabet.C",
|
27
|
+
"ext/sfst_machine/alphabet.h",
|
28
|
+
"ext/sfst_machine/basic.C",
|
29
|
+
"ext/sfst_machine/basic.h",
|
30
|
+
"ext/sfst_machine/compact.C",
|
31
|
+
"ext/sfst_machine/compact.h",
|
32
|
+
"ext/sfst_machine/determinise.C",
|
33
|
+
"ext/sfst_machine/extconf.rb",
|
34
|
+
"ext/sfst_machine/fst-compiler.C",
|
35
|
+
"ext/sfst_machine/fst-compiler.h",
|
36
|
+
"ext/sfst_machine/fst-compiler.yy",
|
37
|
+
"ext/sfst_machine/fst.C",
|
38
|
+
"ext/sfst_machine/fst.h",
|
39
|
+
"ext/sfst_machine/interface.C",
|
40
|
+
"ext/sfst_machine/interface.h",
|
41
|
+
"ext/sfst_machine/make-compact.C",
|
42
|
+
"ext/sfst_machine/make-compact.h",
|
43
|
+
"ext/sfst_machine/mem.h",
|
44
|
+
"ext/sfst_machine/operators.C",
|
45
|
+
"ext/sfst_machine/sfst_machine.cc",
|
46
|
+
"ext/sfst_machine/sgi.h",
|
47
|
+
"ext/sfst_machine/utf8-scanner.C",
|
48
|
+
"ext/sfst_machine/utf8-scanner.ll",
|
49
|
+
"ext/sfst_machine/utf8.C",
|
50
|
+
"ext/sfst_machine/utf8.h",
|
51
|
+
"lib/.gitignore",
|
52
|
+
"lib/sfst.rb",
|
53
|
+
"test/.gitignore",
|
54
|
+
"test/test_sfst.fst",
|
55
|
+
"test/test_sfst.rb"
|
56
|
+
]
|
57
|
+
s.homepage = "http://github.com/mlj/ruby-sfst"
|
58
|
+
s.require_paths = ["lib"]
|
59
|
+
s.rubyforge_project = "sfst"
|
60
|
+
s.rubygems_version = "1.8.11"
|
61
|
+
s.summary = "Stuttgart Finite State Transducer Tools interface"
|
23
62
|
|
24
63
|
if s.respond_to? :specification_version then
|
25
|
-
|
26
|
-
s.specification_version = 2
|
64
|
+
s.specification_version = 3
|
27
65
|
|
28
|
-
if Gem::Version.new(Gem::
|
29
|
-
s.add_development_dependency(%q<echoe>, [">= 0"])
|
66
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
30
67
|
else
|
31
|
-
s.add_dependency(%q<echoe>, [">= 0"])
|
32
68
|
end
|
33
69
|
else
|
34
|
-
s.add_dependency(%q<echoe>, [">= 0"])
|
35
70
|
end
|
36
71
|
end
|
72
|
+
|
data/test/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.a
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-sfst
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- "Marius L. J\xC3\xB8hndal"
|
@@ -9,19 +15,9 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
name: echoe
|
17
|
-
type: :development
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: "0"
|
24
|
-
version:
|
18
|
+
date: 2011-11-04 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
25
21
|
description: A wrapper for the Stuttgart Finite State Transducer Tools (SFST).
|
26
22
|
email: mariuslj (at) ifi [dot] uio (dot) no
|
27
23
|
executables: []
|
@@ -30,72 +26,76 @@ extensions:
|
|
30
26
|
- ext/sfst_machine/extconf.rb
|
31
27
|
extra_rdoc_files:
|
32
28
|
- README.rdoc
|
33
|
-
- lib/sfst.rb
|
34
29
|
files:
|
30
|
+
- CHANGELOG
|
31
|
+
- Manifest
|
35
32
|
- README.rdoc
|
36
33
|
- Rakefile
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
40
|
-
-
|
41
|
-
- ext/sfst_machine/
|
42
|
-
- ext/sfst_machine/utf8.C
|
43
|
-
- ext/sfst_machine/operators.C
|
44
|
-
- ext/sfst_machine/utf8-scanner.ll
|
45
|
-
- ext/sfst_machine/determinise.C
|
46
|
-
- ext/sfst_machine/interface.C
|
47
|
-
- ext/sfst_machine/compact.h
|
48
|
-
- ext/sfst_machine/sgi.h
|
34
|
+
- VERSION
|
35
|
+
- ext/sfst_machine/.gitignore
|
36
|
+
- ext/sfst_machine/alphabet.C
|
37
|
+
- ext/sfst_machine/alphabet.h
|
38
|
+
- ext/sfst_machine/basic.C
|
49
39
|
- ext/sfst_machine/basic.h
|
50
|
-
- ext/sfst_machine/fst.h
|
51
|
-
- ext/sfst_machine/make-compact.h
|
52
|
-
- ext/sfst_machine/fst-compiler.yy
|
53
|
-
- ext/sfst_machine/mem.h
|
54
40
|
- ext/sfst_machine/compact.C
|
55
|
-
- ext/sfst_machine/
|
56
|
-
- ext/sfst_machine/
|
57
|
-
- ext/sfst_machine/sfst_machine.cc
|
41
|
+
- ext/sfst_machine/compact.h
|
42
|
+
- ext/sfst_machine/determinise.C
|
58
43
|
- ext/sfst_machine/extconf.rb
|
59
|
-
- ext/sfst_machine/
|
44
|
+
- ext/sfst_machine/fst-compiler.C
|
45
|
+
- ext/sfst_machine/fst-compiler.h
|
46
|
+
- ext/sfst_machine/fst-compiler.yy
|
60
47
|
- ext/sfst_machine/fst.C
|
61
|
-
- ext/sfst_machine/
|
48
|
+
- ext/sfst_machine/fst.h
|
49
|
+
- ext/sfst_machine/interface.C
|
50
|
+
- ext/sfst_machine/interface.h
|
62
51
|
- ext/sfst_machine/make-compact.C
|
63
|
-
- ext/sfst_machine/
|
64
|
-
- ext/sfst_machine/
|
52
|
+
- ext/sfst_machine/make-compact.h
|
53
|
+
- ext/sfst_machine/mem.h
|
54
|
+
- ext/sfst_machine/operators.C
|
55
|
+
- ext/sfst_machine/sfst_machine.cc
|
56
|
+
- ext/sfst_machine/sgi.h
|
65
57
|
- ext/sfst_machine/utf8-scanner.C
|
58
|
+
- ext/sfst_machine/utf8-scanner.ll
|
59
|
+
- ext/sfst_machine/utf8.C
|
60
|
+
- ext/sfst_machine/utf8.h
|
61
|
+
- lib/.gitignore
|
66
62
|
- lib/sfst.rb
|
67
63
|
- ruby-sfst.gemspec
|
68
|
-
|
64
|
+
- test/.gitignore
|
65
|
+
- test/test_sfst.fst
|
66
|
+
- test/test_sfst.rb
|
69
67
|
homepage: http://github.com/mlj/ruby-sfst
|
68
|
+
licenses: []
|
69
|
+
|
70
70
|
post_install_message:
|
71
|
-
rdoc_options:
|
72
|
-
|
73
|
-
- --inline-source
|
74
|
-
- --title
|
75
|
-
- Ruby-sfst
|
76
|
-
- --main
|
77
|
-
- README.rdoc
|
71
|
+
rdoc_options: []
|
72
|
+
|
78
73
|
require_paths:
|
79
74
|
- lib
|
80
|
-
- ext
|
81
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
82
77
|
requirements:
|
83
78
|
- - ">="
|
84
79
|
- !ruby/object:Gem::Version
|
80
|
+
hash: 3
|
81
|
+
segments:
|
82
|
+
- 0
|
85
83
|
version: "0"
|
86
|
-
version:
|
87
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
88
86
|
requirements:
|
89
87
|
- - ">="
|
90
88
|
- !ruby/object:Gem::Version
|
91
|
-
|
92
|
-
|
89
|
+
hash: 3
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
93
|
requirements: []
|
94
94
|
|
95
95
|
rubyforge_project: sfst
|
96
|
-
rubygems_version: 1.
|
96
|
+
rubygems_version: 1.8.11
|
97
97
|
signing_key:
|
98
|
-
specification_version:
|
99
|
-
summary:
|
100
|
-
test_files:
|
101
|
-
|
98
|
+
specification_version: 3
|
99
|
+
summary: Stuttgart Finite State Transducer Tools interface
|
100
|
+
test_files: []
|
101
|
+
|