phonetics 3.0.5 → 3.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/VERSION +1 -1
- data/lib/phonetics/transcriptions.rb +11 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc5a5d7ba152639d347414b6639eb8298db4708217e61d3c4f4d7d240d45953f
|
4
|
+
data.tar.gz: e0d1d6625c34bf97aba3331340d924334555032cf776af467be94878d3b66e9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b88d3ebedb705b401908f4173db614ea3c869a88401542ef0e5f91c7a6973d80bb0f400708244eeed8c81028c5156a08990947dfc1e6f1581c2fed47d5c45ea
|
7
|
+
data.tar.gz: 9365e7ae84117bd0a470711279976019326f92de670a3990255aa8bd183568c50874aa7d5c52683e481abc6467b7dc7d8f07886e3ac6149ec08a18669fb22e10
|
data/.gitignore
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.
|
1
|
+
3.0.6
|
@@ -10,7 +10,8 @@ module Phonetics
|
|
10
10
|
|
11
11
|
module Transcriptions
|
12
12
|
extend self
|
13
|
-
|
13
|
+
|
14
|
+
TranscriptionFile = File.join(__dir__, '..', 'common_ipa_transcriptions.json')
|
14
15
|
TranscriptionsURL = 'https://jackdanger.com/common_ipa_transcriptions.json'
|
15
16
|
|
16
17
|
SourcesByPreference = [/wiktionary/, /cmu/, /phonemicchart.com/].freeze
|
@@ -30,21 +31,21 @@ module Phonetics
|
|
30
31
|
|
31
32
|
def transcriptions
|
32
33
|
@transcriptions ||= begin
|
33
|
-
download! unless File.exist?(
|
34
|
+
download! unless File.exist?(TranscriptionFile)
|
34
35
|
load_from_disk!
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
39
|
# Lazily loaded from JSON file on disk
|
39
40
|
def load_from_disk!
|
40
|
-
@transcriptions = JSON.parse(File.read(
|
41
|
+
@transcriptions = JSON.parse(File.read(TranscriptionFile))
|
41
42
|
end
|
42
43
|
|
43
44
|
def download!
|
44
45
|
File.open(Transcriptions, 'w') { |f| f.write(URI.open(TranscriptionsURL).read) }
|
45
46
|
end
|
46
47
|
|
47
|
-
def trie
|
48
|
+
def trie(max_rarity = nil)
|
48
49
|
# Let's turn this:
|
49
50
|
#
|
50
51
|
# "century": {
|
@@ -109,9 +110,14 @@ module Phonetics
|
|
109
110
|
# },
|
110
111
|
# },
|
111
112
|
#
|
112
|
-
@
|
113
|
+
@tries ||= {}
|
114
|
+
@tries[max_rarity] ||= begin
|
113
115
|
base_trie = {}
|
114
116
|
transcriptions.each do |key, entry|
|
117
|
+
if max_rarity
|
118
|
+
next if entry['rarity'].nil? || entry['rarity'] > max_rarity
|
119
|
+
end
|
120
|
+
|
115
121
|
entry_data = {
|
116
122
|
word: key,
|
117
123
|
rarity: entry['rarity'],
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phonetics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Danger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|