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 CHANGED
@@ -1,3 +1,4 @@
1
+ v0.3.0. fixes for Ruby 1.9
1
2
  v0.2.0. update to SFST 1.3
2
3
  v0.1.1. overflow and g++ 4.3 fixes
3
4
  v0.1.0. initial release
@@ -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
- == License
13
+ == Usage
12
14
 
13
- As it includes the SFST code directly, the wrapper inherits the GPL2
14
- license of the SFST project.
15
+ If you have the following compiled as <tt>test.a</tt>
15
16
 
16
- == Usage
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
- See http://www.ims.uni-stuttgart.de/projekte/gramotron/SOFTWARE/SFST.html
19
- for details on how to write SFST transducers.
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 'echoe'
6
-
7
- Echoe.new('ruby-sfst', '0.2.0') do |p|
8
- p.summary = "A wrapper for the Stuttgart Finite State Transducer Tools (SFST)."
9
- p.author = 'Marius L. Jøhndal'
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.url = "http://github.com/mlj/ruby-sfst"
12
- p.ignore_pattern = ["*.gemspec"]
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
- rescue LoadError => boom
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
@@ -0,0 +1,3 @@
1
+ *.so
2
+ *.o
3
+ Makefile
@@ -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(RSTRING(from_filename)->ptr, RSTRING(to_filename)->ptr, false);
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(RSTRING(from_filename)->ptr, RSTRING(to_filename)->ptr, true);
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(RSTRING(filename)->ptr, "rb");
94
+ file = fopen(RSTRING_PTR(filename), "rb");
90
95
 
91
96
  if (!file) {
92
- rb_raise(rb_eRuntimeError, "Unable to open SFST file %s", RSTRING(filename)->ptr);
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", RSTRING(filename)->ptr, p);
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(RSTRING(string)->ptr, analyses);
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(RSTRING(filename)->ptr, "rb");
159
+ file = fopen(RSTRING_PTR(filename), "rb");
155
160
 
156
161
  if (!file) {
157
- rb_raise(rb_eRuntimeError, "Unable to open SFST file %s", RSTRING(filename)->ptr);
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", RSTRING(filename)->ptr, p);
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(RSTRING(string)->ptr, &(t->alphabet), false);
361
+ Transducer a1(RSTRING_PTR(string), &(t->alphabet), false);
357
362
  if (generate) {
358
363
  a2 = &(a1 || *t);
359
364
  a3 = &(a2->upper_level());
@@ -0,0 +1 @@
1
+ *.so
@@ -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 = %q{ruby-sfst}
5
- s.version = "0.2.0"
7
+ s.name = "ruby-sfst"
8
+ s.version = "0.3.0"
6
9
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
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 = %q{2009-02-09}
10
- s.description = %q{A wrapper for the Stuttgart Finite State Transducer Tools (SFST).}
11
- s.email = %q{mariuslj (at) ifi [dot] uio (dot) no}
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 = ["README.rdoc", "lib/sfst.rb"]
14
- s.files = ["README.rdoc", "Rakefile", "Manifest", "test/test_sfst.rb", "test/test_sfst.fst", "CHANGELOG", "ext/sfst_machine/fst-compiler.h", "ext/sfst_machine/utf8.C", "ext/sfst_machine/operators.C", "ext/sfst_machine/utf8-scanner.ll", "ext/sfst_machine/determinise.C", "ext/sfst_machine/interface.C", "ext/sfst_machine/compact.h", "ext/sfst_machine/sgi.h", "ext/sfst_machine/basic.h", "ext/sfst_machine/fst.h", "ext/sfst_machine/make-compact.h", "ext/sfst_machine/fst-compiler.yy", "ext/sfst_machine/mem.h", "ext/sfst_machine/compact.C", "ext/sfst_machine/basic.C", "ext/sfst_machine/interface.h", "ext/sfst_machine/sfst_machine.cc", "ext/sfst_machine/extconf.rb", "ext/sfst_machine/alphabet.C", "ext/sfst_machine/fst.C", "ext/sfst_machine/alphabet.h", "ext/sfst_machine/make-compact.C", "ext/sfst_machine/fst-compiler.C", "ext/sfst_machine/utf8.h", "ext/sfst_machine/utf8-scanner.C", "lib/sfst.rb", "ruby-sfst.gemspec"]
15
- s.has_rdoc = true
16
- s.homepage = %q{http://github.com/mlj/ruby-sfst}
17
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ruby-sfst", "--main", "README.rdoc"]
18
- s.require_paths = ["lib", "ext"]
19
- s.rubyforge_project = %q{sfst}
20
- s.rubygems_version = %q{1.3.1}
21
- s.summary = %q{A wrapper for the Stuttgart Finite State Transducer Tools (SFST).}
22
- s.test_files = ["test/test_sfst.rb"]
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
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
26
- s.specification_version = 2
64
+ s.specification_version = 3
27
65
 
28
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
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
+
@@ -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
- version: 0.2.0
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: 2009-02-09 00:00:00 +00:00
13
- default_executable:
14
- dependencies:
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
- - Manifest
38
- - test/test_sfst.rb
39
- - test/test_sfst.fst
40
- - CHANGELOG
41
- - ext/sfst_machine/fst-compiler.h
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/basic.C
56
- - ext/sfst_machine/interface.h
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/alphabet.C
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/alphabet.h
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/fst-compiler.C
64
- - ext/sfst_machine/utf8.h
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
- has_rdoc: true
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
- - --line-numbers
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
- version: "1.2"
92
- version:
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
93
  requirements: []
94
94
 
95
95
  rubyforge_project: sfst
96
- rubygems_version: 1.3.1
96
+ rubygems_version: 1.8.11
97
97
  signing_key:
98
- specification_version: 2
99
- summary: A wrapper for the Stuttgart Finite State Transducer Tools (SFST).
100
- test_files:
101
- - test/test_sfst.rb
98
+ specification_version: 3
99
+ summary: Stuttgart Finite State Transducer Tools interface
100
+ test_files: []
101
+