lingua-it-readability 1.1.0 → 1.1.5
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/CHANGELOG.md +5 -0
- data/README.md +10 -0
- data/lib/lingua/it/readability/version.rb +1 -1
- data/lib/lingua/it/readability.rb +39 -16
- data/lib/lingua/it/sentence.rb +2 -8
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b93556194cfe9537a625a11be8b2f973c0939622
|
|
4
|
+
data.tar.gz: 959ea95d40475e12c0e4f3e8c4b2a3ac8d4f595f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1fa57d62d3c1dbc8ee62f58094cc92551c5186b3dcf3218337c3558ad7e68f425f6d0b82d0e1bdeefe7c7493299c680624fd12df2a3ed08597be88175bed39a
|
|
7
|
+
data.tar.gz: 2eaaaf25d2e5dd2e0bb58cdeaf87e17b318c18d94458fe755ce3365067b5be218435a1b38884d014cafac31496a6fc5f358b3c1444b5cc5a0982e7b3f7f394de
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -39,6 +39,16 @@ report.num_sentences # 3
|
|
|
39
39
|
report.num_words # 3
|
|
40
40
|
report.num_syllables # 8
|
|
41
41
|
report.report # a formatted summary of statistics and measures
|
|
42
|
+
|
|
43
|
+
# It's also possible to not directly initialize the object..
|
|
44
|
+
text = "Lista:\n- Gennaio;\n- Febbraio;"
|
|
45
|
+
report = Lingua::IT::Readability.new
|
|
46
|
+
# ..using method analyze with optional delimiters
|
|
47
|
+
report.analyze(text, ':', ';')
|
|
48
|
+
report.num_sentences # 3
|
|
49
|
+
report.num_words # 3
|
|
50
|
+
report.num_syllables # 8
|
|
51
|
+
report.report # a formatted summary of statistics and measures
|
|
42
52
|
```
|
|
43
53
|
|
|
44
54
|
## Development
|
|
@@ -9,42 +9,65 @@ end
|
|
|
9
9
|
module Lingua
|
|
10
10
|
module IT
|
|
11
11
|
class Readability
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
attr_reader :
|
|
12
|
+
attr_accessor :text
|
|
13
|
+
attr_accessor :paragraphs
|
|
14
|
+
attr_accessor :sentences
|
|
15
|
+
attr_accessor :words
|
|
16
|
+
attr_accessor :frequencies
|
|
17
|
+
attr_reader :sentence
|
|
18
|
+
attr_reader :paragraph
|
|
19
|
+
attr_reader :syllable
|
|
18
20
|
|
|
19
21
|
# Initialize the sample with +text+
|
|
20
22
|
def initialize(text = '', *delimiters)
|
|
21
23
|
|
|
22
|
-
@
|
|
24
|
+
@paragraph = Lingua::IT::Paragraph
|
|
25
|
+
@sentence = Lingua::IT::Sentence
|
|
26
|
+
@syllable = Lingua::IT::Syllable
|
|
27
|
+
|
|
28
|
+
if(!delimiters.empty?)
|
|
29
|
+
@sentence.delimiter(delimiters)
|
|
30
|
+
else
|
|
31
|
+
@sentence.reset_delimiter!
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
@text = text.dup
|
|
35
|
+
@paragraphs = @paragraph.paragraphs(self.text)
|
|
36
|
+
@sentences = @sentence.sentences(self.text)
|
|
37
|
+
@words = []
|
|
38
|
+
@frequencies = {}
|
|
39
|
+
@frequencies.default = 0
|
|
40
|
+
@syllables = @syllable.syllables(self.text)
|
|
41
|
+
count_words
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Analyze a text sample with optional delimiters
|
|
45
|
+
def analyze(text, *delimiters)
|
|
23
46
|
if(!delimiters.empty?)
|
|
24
|
-
@
|
|
47
|
+
@sentence.delimiter(delimiters)
|
|
25
48
|
else
|
|
26
|
-
@
|
|
49
|
+
@sentence.reset_delimiter!
|
|
27
50
|
end
|
|
28
51
|
|
|
29
52
|
@text = text.dup
|
|
30
|
-
@paragraphs =
|
|
31
|
-
@sentences = @
|
|
53
|
+
@paragraphs = @paragraph.paragraphs(self.text)
|
|
54
|
+
@sentences = @sentence.sentences(self.text)
|
|
32
55
|
@words = []
|
|
33
56
|
@frequencies = {}
|
|
34
57
|
@frequencies.default = 0
|
|
35
|
-
@syllables =
|
|
58
|
+
@syllables = @syllable.syllables(self.text)
|
|
36
59
|
count_words
|
|
37
60
|
end
|
|
38
61
|
|
|
39
62
|
# Reset Lingua::IT::Sentence symbols delimiter cache
|
|
40
|
-
def reset_delimiter
|
|
41
|
-
@
|
|
63
|
+
def reset_delimiter!
|
|
64
|
+
@sentence.reset_delimiter!
|
|
42
65
|
end
|
|
43
66
|
|
|
44
67
|
# The number of paragraphs in the sample. A paragraph is defined as a
|
|
45
68
|
# newline followed by one or more empty or whitespace-only lines.
|
|
46
69
|
def num_paragraphs
|
|
47
|
-
paragraphs.length
|
|
70
|
+
@paragraphs.length
|
|
48
71
|
end
|
|
49
72
|
|
|
50
73
|
# The number of sentences in the sample. The meaning of a "sentence" is
|
|
@@ -64,7 +87,7 @@ module Lingua
|
|
|
64
87
|
# characters, not taking account of punctuation and spaces, see private
|
|
65
88
|
# method +count_words+ for additional info about a word definition
|
|
66
89
|
def num_words
|
|
67
|
-
words.length
|
|
90
|
+
@words.length
|
|
68
91
|
end
|
|
69
92
|
|
|
70
93
|
# The total number of syllables in the text sample. Syllables are defined
|
data/lib/lingua/it/sentence.rb
CHANGED
|
@@ -50,7 +50,7 @@ module Lingua
|
|
|
50
50
|
@delimiters
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
def self.reset_delimiter
|
|
53
|
+
def self.reset_delimiter!
|
|
54
54
|
@delimiters = STD
|
|
55
55
|
set_delim_regex!
|
|
56
56
|
@delimiters
|
|
@@ -69,12 +69,6 @@ module Lingua
|
|
|
69
69
|
@abbr_regex = "#{@abbreviations.join('|')}"
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
# Utility method, chain up all delimiters constants arrays
|
|
73
|
-
def self.initialize_delimiters!
|
|
74
|
-
@delimiters = STD
|
|
75
|
-
set_delim_regex!
|
|
76
|
-
end
|
|
77
|
-
|
|
78
72
|
# Utility method, join all elements of the delimiters arrays
|
|
79
73
|
# without a separator, making suitable for a regex.
|
|
80
74
|
def self.set_delim_regex!
|
|
@@ -82,7 +76,7 @@ module Lingua
|
|
|
82
76
|
end
|
|
83
77
|
|
|
84
78
|
initialize_abbreviations!
|
|
85
|
-
|
|
79
|
+
reset_delimiter!
|
|
86
80
|
end
|
|
87
81
|
end
|
|
88
82
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lingua-it-readability
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrea Giacomo Baldan
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-02-
|
|
11
|
+
date: 2016-02-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|