lingua-it-readability 1.0.0 → 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca7c5b85336a54accf315881255133c101aef7cd
4
- data.tar.gz: d1ffbc35b45fa73951cddad360cfc1b696ce8ea2
3
+ metadata.gz: f5542c77a0a6c46b3332c8fe544ab9841cbef55c
4
+ data.tar.gz: 6c243df9b4f38517e2a6f5cd733c51ebd767a29d
5
5
  SHA512:
6
- metadata.gz: ccc18e702fd8487276d79542117377c436cdd5b7b4d46f108e583290430051f1750808d424f40d9217ba6173d3bf0f0d08f31d6ce47833d15435c1e77176d763
7
- data.tar.gz: 59d73c1511929d8bb9ce5a9fe38017e717025612e868e8415d0d6ab9c49e0fcae0d5f35d4a61444d034208b03cf045f274b744af978d7b53808024688b8c4444
6
+ metadata.gz: af902cab383c81c39ae7d714b1e64f1e11b5f9024d39337f3efb64aaba6c9f9b4b9a64adf8cfb80a206b13fc8052c3f8f68b92db6125cf32468ad3aec657aca3
7
+ data.tar.gz: 33a0f97d97d8bb042cfec017d3f288c4d9968a2ccef1351325441336eaf19bcab7d84fce6ddffbd815c4f753af6464b661df16ca84e4cd4156785426a662d19f
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/codepr/lingua.svg?branch=master)](https://travis-ci.org/codepr/lingua)
1
+ [![Build Status](https://travis-ci.org/codepr/lingua-it-readability.svg?branch=master)](https://travis-ci.org/codepr/lingua-it-readability)
2
2
 
3
3
  # Lingua::It::Readability
4
4
 
@@ -1,7 +1,7 @@
1
1
  module Lingua
2
2
  module It
3
3
  module Readability
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
6
6
  end
7
7
  end
@@ -9,12 +9,15 @@ module Lingua
9
9
  # irregular orthography. A number of extra patterns (particularly for
10
10
  # derived word forms) means that this module is somewhat more accurate
11
11
  # than the Perl original.
12
+ # It's not perfect, some extreme special cases could not be handled
13
+ # correctly, trough it's well realiable 90% of times, at least in the
14
+ # number of syllables, that really matters for the Flesch index.
12
15
 
13
16
  V = "[aeiouàèéìòù]"
14
17
  C = "[b-df-hj-np-tv-z]"
18
+ Y = "[b-df-hj-mp-tv-z]"
15
19
  S = "iut"
16
20
  X = "fi|aci"
17
- Y = "#{C}e"
18
21
  Z = "i[aeo]"
19
22
 
20
23
  def self.syllables(text)
@@ -24,7 +27,7 @@ module Lingua
24
27
  word.gsub!(/(#{V})(#{S})/i, '\1=iu=t')
25
28
  word.gsub!(/(#{V})(#{Z})/i, '\1=\2')
26
29
  word.gsub!(/(#{X})(#{V})/i, '\1=\2')
27
- word.gsub!(/(#{Y})(#{V})/i, '\1=\2')
30
+ word.gsub!(/(#{C})(#{V})(#{V})(#{Y})/, '\1\2=\3=\4')
28
31
  word.gsub!(/(#{V})([bcfgptv][lr])/i, '\1=\2')
29
32
  word.gsub!(/(#{V})([cg]h)/i, '\1=\2')
30
33
  word.gsub!(/(#{V})(gn)/i, '\1=\2')
@@ -37,6 +40,13 @@ module Lingua
37
40
  word.sub!(/^=/, '')
38
41
  word.sub!(/=$/, '')
39
42
  word.gsub!(/=+/,'=');
43
+ # special cases
44
+ word.gsub!(/(le)([oa]n)/i, '\1=\2')
45
+ word.gsub!(/(le)([oa])(an)/i, '\1=\2=\3')
46
+ word.gsub!(/(spe)=(le)=(o)/i, '\1=\2\3')
47
+ word.gsub!(/([gd]i)=(#{V})/i, '\1\2')
48
+ word.gsub!(/(ni)=(#{V})/i, '\1\2')
49
+ word.gsub!(/=(e)=(l)/i, '\1\2')
40
50
  hyphenation += "#{word}="
41
51
  end
42
52
  hyphenation.split('=')
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.0.0
4
+ version: 1.0.1
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-08 00:00:00.000000000 Z
11
+ date: 2016-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler