textstat 0.1.8 → 0.1.9
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.
- checksums.yaml +4 -4
- data/lib/textstat/version.rb +1 -1
- data/lib/textstat.rb +6 -2
- data/spec/textstat_spec.rb +7 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88480347f6e6a1c232dc30a7ee14e4cf98154936e28a9fb2d1aaa6fe0f176aed
|
4
|
+
data.tar.gz: bce6f0fc8222542dba6a8e0961d20fd3b68313571769f1cd7c7dd13c5fc28926
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3490d4920b60d1a6defa19eb80a2918bd92fafcf265b8f55aae50f617da88becaeba562a73fe20b91020f0ed21a2e912556c6cbb8314bc5f8210a8debcbe82c
|
7
|
+
data.tar.gz: f4a7c7aba924df2005da79cf48a675e6d1f2655d56debe90590e748b56fdc1bccffa80ce245ba644d5fe0e5119d5b66159946569a05f715579bfaaa8185edb61
|
data/lib/textstat/version.rb
CHANGED
data/lib/textstat.rb
CHANGED
@@ -145,7 +145,7 @@ class TextStat
|
|
145
145
|
number / 2
|
146
146
|
end
|
147
147
|
|
148
|
-
def self.difficult_words(text, language = 'en_us')
|
148
|
+
def self.difficult_words(text, language = 'en_us', return_words = false)
|
149
149
|
require 'set'
|
150
150
|
easy_words = Set.new
|
151
151
|
File.read(File.join(dictionary_path, "#{language}.txt")).each_line do |line|
|
@@ -159,7 +159,11 @@ class TextStat
|
|
159
159
|
|
160
160
|
diff_words_set.add(value) if syllable_count(value, language) > 1
|
161
161
|
end
|
162
|
-
|
162
|
+
if return_words
|
163
|
+
diff_words_set
|
164
|
+
else
|
165
|
+
diff_words_set.length
|
166
|
+
end
|
163
167
|
end
|
164
168
|
|
165
169
|
def self.dale_chall_readability_score(text, language = 'en_us')
|
data/spec/textstat_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'rspec'
|
2
|
-
require_relative '../lib/textstat
|
2
|
+
require_relative '../lib/textstat'
|
3
3
|
|
4
4
|
describe TextStat do
|
5
5
|
before do
|
@@ -139,6 +139,11 @@ describe TextStat do
|
|
139
139
|
expect(result).to eql 58
|
140
140
|
end
|
141
141
|
|
142
|
+
it 'should return the correct difficult words list result' do
|
143
|
+
result = TextStat.difficult_words(@long_test, 'en_us', true)
|
144
|
+
expect(result).to be_a Set
|
145
|
+
end
|
146
|
+
|
142
147
|
it 'should return the correct Dale–Chall readability score' do
|
143
148
|
score = TextStat.dale_chall_readability_score(@long_test)
|
144
149
|
expect(score).to eql 7.25
|
@@ -189,4 +194,4 @@ describe TextStat do
|
|
189
194
|
end
|
190
195
|
end
|
191
196
|
end
|
192
|
-
end
|
197
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: textstat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Polak
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: text-hyphen
|
@@ -72,7 +72,7 @@ dependencies:
|
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '3.0'
|
75
|
-
description:
|
75
|
+
description:
|
76
76
|
email:
|
77
77
|
- jakub.polak.vz@gmail.com
|
78
78
|
executables: []
|
@@ -93,7 +93,7 @@ licenses:
|
|
93
93
|
metadata:
|
94
94
|
homepage_uri: https://github.com/kupolak/textstat
|
95
95
|
source_code_uri: https://github.com/kupolak/textstat
|
96
|
-
post_install_message:
|
96
|
+
post_install_message:
|
97
97
|
rdoc_options: []
|
98
98
|
require_paths:
|
99
99
|
- lib
|
@@ -108,8 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
|
-
rubygems_version: 3.
|
112
|
-
signing_key:
|
111
|
+
rubygems_version: 3.4.16
|
112
|
+
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: Ruby gem to calculate readability statistics of a text object - paragraphs,
|
115
115
|
sentences, articles
|