wordtree 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -97,7 +97,10 @@ module WordTree
97
97
  s.unscan
98
98
  end
99
99
  # Move forward one word
100
- s.scan(onegram_re)
100
+ if !s.scan(onegram_re)
101
+ # if we can't find a word, let's try to recover by scanning one char at a time
102
+ s.scan(/./m)
103
+ end
101
104
  end
102
105
  end
103
106
  end
@@ -1,3 +1,3 @@
1
1
  module Wordtree
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'wordtree/text_utils'
3
+ require 'timeout'
3
4
 
4
5
  describe WordTree::TextUtils do
5
6
  context "#split_near" do
@@ -76,5 +77,13 @@ describe WordTree::TextUtils do
76
77
  expect{ |b| WordTree::TextUtils.each_ngram(sample_text, 3, &b) }.to \
77
78
  yield_successive_args("one word .", "word . two")
78
79
  end
80
+
81
+ it "doesn't hang on unexpected input" do
82
+ sample_text = "one word\n. two \n"
83
+ Timeout.timeout(3) do
84
+ expect{ |b| WordTree::TextUtils.each_ngram(sample_text, 1, &b) }.to \
85
+ yield_successive_args("one", "word", ".", "two")
86
+ end
87
+ end
79
88
  end
80
89
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordtree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-07 00:00:00.000000000 Z
12
+ date: 2014-09-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: virtus