fonemas 0.0.7 → 0.0.8

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzZmMDM2Y2FlNDhkMWJhOWJlNDM4ZTRiODViNzllZjMxODQ3ODQ5ZA==
4
+ YjBkMDMyOTc4OGQ2MDA1Yjk0ZWUxM2QxNjQ4NDUwOGI0ZWJkMTUyNw==
5
5
  data.tar.gz: !binary |-
6
- Zjg0MzZhYzFjOThhOGE4YmY0NzRmNmI1YmI4Y2YxNmY5MTlkOGQxNA==
6
+ NDdhZmMyMzU4OTNkY2ZjMzA1YTE4NTcxNzNjOGQ4NWNjYmEyYTRmNw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NGE5ODQzMzhjYWU0MWM5ZDcwNzI5NjBlNzJmYTFiMTllMDY3Y2I3YjEyMWIz
10
- ZGVlZTQ4NDdmZjRiZTBmN2Y3Mzc3ZTAyNDE4MzdkN2E2ZjlmNmFkM2U5NGRj
11
- NTUwYzc1MDE4YWI2NDZlNmI3YzBkYmRiZWYxYjA2ZjYwYjczMjk=
9
+ OWY0MTM0OTZkN2I0NDMzNWViNDc5MGRjMTU0OGI0ZWYxYzgyMDIzYjNlMGU3
10
+ NDdjMWJlODZmNTEyN2I4ODhlYjkwM2Q2ZDU0NmFiYzBlNTdmMDU0ODk1M2Fm
11
+ YzAwZWEwNjRjODI2ZjY1YTk1MzM3NzNiYTQ3MzlmNTA0ZWIzMTU=
12
12
  data.tar.gz: !binary |-
13
- ZDMzZDc4NmQ0YWRkNWQ3YTYwODM2YTYwMzg0NmUzNTU1MDc0YWFmMjc4NjVm
14
- OGEyOGZiNGNlYzc0YzQxNTk3ZmNlZjgzM2MzOGJmYzFlYzZhMWQ1NDRiYTlk
15
- ODgzNDQxYzIwYmY1YWU3MTAwMjdjOTAyZmRjODk5NzYwMGIzZTg=
13
+ YmQ1NzFhMjcxNzczYzdkMjdiMmQxNDMyMmM4YWIyNTIyMzExMjFjMDYzNTNi
14
+ NzAwOTk2YzRjMWE3YzBmZDk1MWNlNzYyMTQzYWFkMGI2NWE5Yjc5OWNhZTk0
15
+ ZDY1YjFiODhmZmUxNTA0NTI3OTI4YTFkODM0ZWNhZTFkYzZhNDc=
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in fonemas.gemspec
4
4
  gemspec
5
+
6
+ gem 'text-hyphen'
data/Rakefile CHANGED
@@ -1 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task default: :spec
data/fonemas.gemspec CHANGED
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
23
24
  end
data/lib/fonemas.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  require "fonemas/version"
3
3
 
4
4
  module Fonemas
5
+ require 'text/hyphen'
5
6
 
6
7
  def self.version
7
8
  VERSION
@@ -18,9 +19,48 @@ module Fonemas
18
19
  def self.isTonica(word,i)
19
20
  #falta considerar las palabras que poseen acento pero no tilde
20
21
  tildes = %w(á é í ó ú)
22
+ w = word.join
21
23
  if tildes.include? word[i]
22
24
  return true
23
25
  else
26
+ es = Text::Hyphen.new(:language => "es", :left => 0, :right => 1)
27
+ p = es.hyphenate(w)
28
+ hh = es.visualize(w).split("-")
29
+ if word =~ /áéíóú/
30
+ #acento ya existe en otra silaba
31
+ return false
32
+ else
33
+ if hh.size == 1
34
+ #monosilabos
35
+ return true
36
+ elsif hh.size == 2
37
+ #agudas, se acentuan en n,s o vocal
38
+ if w =~ /[nsaeiou]$/
39
+ #termina en n s y vocal y no tiene tilde
40
+ #por lo tanto es grave
41
+ if i < p[0]
42
+ return true
43
+ else
44
+ return false
45
+ end
46
+ end
47
+ elsif hh.size >= 3
48
+ if i > p[p.size-1]
49
+ if w =~ /[nsaeiou]$/
50
+ return false
51
+ else
52
+ return true
53
+ end
54
+ elsif i > p[p.size-2] and w =~ /[nsaeiou]$/
55
+ return true
56
+ else
57
+ return false
58
+ end
59
+ end
60
+ end
61
+
62
+
63
+
24
64
  return false
25
65
  end
26
66
  end
@@ -153,7 +193,7 @@ module Fonemas
153
193
  if word[i+1] == 'e' or word[i+1] == 'i'
154
194
  fonema << 'j'
155
195
  else
156
- if !entreVocales(word,i)
196
+ if !entreVocales(word,i) and word[i-1] != 'n'
157
197
  fonema << 'G'
158
198
  else
159
199
  fonema << 'g'
@@ -1,3 +1,3 @@
1
1
  module Fonemas
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ describe Fonemas do
4
+ it 'test acentos' do
5
+ Fonemas.fonemas('hasta')[0].should eql("aa s t a")
6
+ Fonemas.fonemas('torta')[0].should eql("t oo r t a")
7
+ Fonemas.fonemas('ungüento')[0].should eql("u n g u ee n t o")
8
+ for i in Fonemas.fonemas('adskribir')
9
+ i.should end_with('ii r')
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1 @@
1
+ require 'fonemas'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fonemas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Bahamondez Honores
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: Creación de fonemas para ser utilizadas en el reconocimiento de voz con
42
56
  cmu sphinx
43
57
  email:
@@ -60,6 +74,8 @@ files:
60
74
  - fonemas.gemspec
61
75
  - lib/fonemas.rb
62
76
  - lib/fonemas/version.rb
77
+ - spec/fonemas/fonema_spec.rb
78
+ - spec/spec_helper.rb
63
79
  homepage: http://www.b9.cl
64
80
  licenses:
65
81
  - MIT
@@ -84,4 +100,6 @@ rubygems_version: 2.0.3
84
100
  signing_key:
85
101
  specification_version: 4
86
102
  summary: Lista todas las pronunciaciones posibles para una palabra en Chileno
87
- test_files: []
103
+ test_files:
104
+ - spec/fonemas/fonema_spec.rb
105
+ - spec/spec_helper.rb