ots 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,16 @@
1
+ === 0.5.4 (2012-02-03)
2
+
3
+ * move extension into subdirectory.
4
+ * added OTS#set_dictionary_path to avoid compile time path resolution.
5
+
6
+ === 0.5.3 (2012-01-27)
7
+
8
+ * cleanup dependencies.
9
+
10
+ === 0.5.2 (2012-01-25)
11
+
12
+ * added OTS::Grader
13
+
1
14
  === 0.5.1 (2012-01-11)
2
15
 
3
16
  * GC bugfix: hang on to encoding index rather than rb_encoding pointer.
@@ -15,8 +15,7 @@ if glib_ldflags.empty?
15
15
  glib_ldflags = libs.split(/\s+/).map {|lib| "-l#{lib}"}.join(' ')
16
16
  end
17
17
 
18
- dir = File.expand_path(File.dirname(__FILE__) + '/../dictionaries')
19
- $CFLAGS = glib_cflags + %Q{ -Ilibots -I/usr/include/libxml2 -DDICTIONARY_DIR='"#{dir}/"'}
18
+ $CFLAGS = glib_cflags + %Q{ -Ilibots -I/usr/include/libxml2}
20
19
  $LDFLAGS = glib_ldflags + %Q{ -Llibots}
21
20
 
22
21
  find_library('glib-2.0', 'main') or raise "unable to find glib-2.0"
File without changes
@@ -28,6 +28,8 @@
28
28
  #include <libxml/xmlmemory.h>
29
29
  #include <libxml/parser.h>
30
30
 
31
+ extern char *DICTIONARY_DIR;
32
+
31
33
 
32
34
  /* loads the xml dictionary file to memory*/
33
35
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -4,6 +4,7 @@
4
4
  #include <errno.h>
5
5
 
6
6
  static VALUE mOTS, cArticle;
7
+ char *DICTIONARY_DIR;
7
8
 
8
9
  static void article_free(OtsArticle *article) {
9
10
  if (article)
@@ -174,6 +175,16 @@ VALUE ots_languages(VALUE self) {
174
175
  return languages;
175
176
  }
176
177
 
178
+ VALUE ots_set_dictionary_path(VALUE self, VALUE path) {
179
+ char *string = CSTRING(path);
180
+ if (DICTIONARY_DIR)
181
+ free(DICTIONARY_DIR);
182
+
183
+ DICTIONARY_DIR = (char *)malloc(strlen(string) + 2);
184
+ sprintf(DICTIONARY_DIR, "%s/", string);
185
+ return Qnil;
186
+ }
187
+
177
188
  /* init */
178
189
 
179
190
  void Init_ots(void) {
@@ -185,10 +196,12 @@ void Init_ots(void) {
185
196
  rb_define_method(cArticle, "topics", RUBY_METHOD_FUNC(article_topics), 0);
186
197
  rb_define_method(cArticle, "keywords", RUBY_METHOD_FUNC(article_keywords), 0);
187
198
 
188
- rb_define_module_function(mOTS, "parse", RUBY_METHOD_FUNC(ots_parse), -1);
189
- rb_define_module_function(mOTS, "languages", RUBY_METHOD_FUNC(ots_languages), 0);
199
+ rb_define_module_function(mOTS, "parse", RUBY_METHOD_FUNC(ots_parse), -1);
200
+ rb_define_module_function(mOTS, "languages", RUBY_METHOD_FUNC(ots_languages), 0);
201
+ rb_define_module_function(mOTS, "set_dictionary_path", RUBY_METHOD_FUNC(ots_set_dictionary_path), 1);
190
202
 
191
203
  rb_define_alloc_func(cArticle, article_allocate);
192
204
 
193
205
  rb_define_const(mOTS, "VERSION", rb_str_new2(RUBY_OTS_VERSION));
206
+ DICTIONARY_DIR = 0;
194
207
  }
File without changes
@@ -0,0 +1,2 @@
1
+ #pragma once
2
+ #define RUBY_OTS_VERSION "0.5.4"
@@ -0,0 +1,8 @@
1
+ require 'ots/ots'
2
+
3
+ module OTS
4
+ DICTIONARY_PATH = File.absolute_path(File.dirname(__FILE__) + '/../dictionaries')
5
+ # set the dictionary path, so the c extension can read files.
6
+ # we can set this at compile time but bundler sometimes compiles the extension inside a temp directory.
7
+ set_dictionary_path DICTIONARY_PATH
8
+ end
@@ -1,7 +1,6 @@
1
1
  require 'nokogiri'
2
2
 
3
3
  module OTS
4
- DICTIONARY_PATH = File.absolute_path(File.dirname(__FILE__) + '/../../dictionaries')
5
4
  class Grader
6
5
  def initialize options = {}
7
6
  path = options[:path] || File.join(DICTIONARY_PATH, options.fetch(:language, 'en').to_s + '.xml')
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+ require 'helper'
3
+ require 'ots/grader'
4
+
5
+ describe 'OTS::Grader' do
6
+ it 'should load the dictionary & return stop words' do
7
+ assert OTS::Grader.new(language: 'en').stop_words
8
+ end
9
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 3
9
- version: 0.5.3
8
+ - 4
9
+ version: 0.5.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bharanee Rathna
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-01-27 00:00:00 +11:00
17
+ date: 2012-02-03 00:00:00 +11:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -49,31 +49,33 @@ email:
49
49
  executables: []
50
50
 
51
51
  extensions:
52
- - ext/extconf.rb
52
+ - ext/ots/extconf.rb
53
53
  extra_rdoc_files: []
54
54
 
55
55
  files:
56
- - ext/ots.c
57
- - ext/libots/text.c
58
- - ext/libots/grader-tf.c
59
- - ext/libots/stemmer.c
60
- - ext/libots/article.c
61
- - ext/libots/grader-tc.c
62
- - ext/libots/html.c
63
- - ext/libots/grader.c
64
- - ext/libots/relations.c
65
- - ext/libots/parser.c
66
- - ext/libots/dictionary.c
67
- - ext/libots/highlighter.c
68
- - ext/libots/wordlist.c
69
- - ext/ots.h
70
- - ext/version.h
71
- - ext/libots/grader-tc.h
72
- - ext/libots/libots.h
73
- - ext/extconf.rb
56
+ - ext/ots/ots.c
57
+ - ext/ots/libots/text.c
58
+ - ext/ots/libots/grader-tf.c
59
+ - ext/ots/libots/stemmer.c
60
+ - ext/ots/libots/article.c
61
+ - ext/ots/libots/grader-tc.c
62
+ - ext/ots/libots/html.c
63
+ - ext/ots/libots/grader.c
64
+ - ext/ots/libots/relations.c
65
+ - ext/ots/libots/parser.c
66
+ - ext/ots/libots/dictionary.c
67
+ - ext/ots/libots/highlighter.c
68
+ - ext/ots/libots/wordlist.c
69
+ - ext/ots/ots.h
70
+ - ext/ots/version.h
71
+ - ext/ots/libots/grader-tc.h
72
+ - ext/ots/libots/libots.h
73
+ - ext/ots/extconf.rb
74
74
  - test/test_article.rb
75
75
  - test/test_ots.rb
76
76
  - test/helper.rb
77
+ - test/test_grader.rb
78
+ - lib/ots.rb
77
79
  - lib/ots/grader.rb
78
80
  - README.md
79
81
  - CHANGELOG
@@ -123,6 +125,7 @@ rdoc_options: []
123
125
 
124
126
  require_paths:
125
127
  - lib
128
+ - ext
126
129
  required_ruby_version: !ruby/object:Gem::Requirement
127
130
  none: false
128
131
  requirements:
@@ -1,2 +0,0 @@
1
- #pragma once
2
- #define RUBY_OTS_VERSION "0.5.3"