glossa 1.0.5 → 1.1.0
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/glossa/import_export.rb +33 -0
- data/lib/glossa/language.rb +18 -17
- data/lib/glossa.rb +4 -3
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b47036eb93fd38c2ab9647f4cc24dece0ec6bfc
|
4
|
+
data.tar.gz: f8535e218e76b8adee01c132bad266ed7dbcf879
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: faf673d1bbf5f986d170d164b889edb64fedde2401b232da04ddb5866f54b98105677e9efad7f10a503675eb8a3ccd179df486ce33fe854c134191374ccb1043
|
7
|
+
data.tar.gz: 95f9e6c0f064c07e06e18d27dbb3431b3c3cfe1d414e19ac7b14607bc076f1403dbd54cbb19d2d9f04b68b59bbab89c308dbdca446fd5ce211df19b22d3a368f
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "json"
|
2
|
+
|
3
|
+
class Glossa::Language
|
4
|
+
def self.import(path = nil)
|
5
|
+
path = gets "File path:" if path.nil?
|
6
|
+
|
7
|
+
# Get file from path
|
8
|
+
json = '';
|
9
|
+
File.open(path).each do |line|
|
10
|
+
json << line
|
11
|
+
end
|
12
|
+
|
13
|
+
options = JSON.parse(json)
|
14
|
+
self.new(false, options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def export(path = nil)
|
18
|
+
if File.exist? path
|
19
|
+
raise "That file already exists!"
|
20
|
+
return
|
21
|
+
elsif path.nil?
|
22
|
+
raise "File path required"
|
23
|
+
return
|
24
|
+
end
|
25
|
+
|
26
|
+
lang_state = {}
|
27
|
+
self.instance_variables.each do |attribute|
|
28
|
+
a = attribute[1..attribute.length]
|
29
|
+
lang_state[a] = self.instance_variable_get(attribute)
|
30
|
+
end
|
31
|
+
File.open(path, "w") { |file| file.write(lang_state.to_json) }
|
32
|
+
end
|
33
|
+
end
|
data/lib/glossa/language.rb
CHANGED
@@ -39,22 +39,22 @@ class Glossa::Language
|
|
39
39
|
"F" => "mn",
|
40
40
|
"L" => "rl"
|
41
41
|
}
|
42
|
-
@structure = options[
|
43
|
-
@exponent = options[
|
44
|
-
@restricts = options[
|
45
|
-
@cortho = options[
|
46
|
-
@vortho = options[
|
47
|
-
@noortho = options[
|
48
|
-
@nomorph = options[
|
49
|
-
@nowordpool = options[
|
50
|
-
@minsyll = options[
|
51
|
-
@maxsyll = options[
|
52
|
-
@morphemes = options[
|
53
|
-
@words = options[
|
54
|
-
@names = options[
|
55
|
-
@joiner = options[
|
56
|
-
@maxchar = options[
|
57
|
-
@minchar = options[
|
42
|
+
@structure = options['structure'] || "CVC"
|
43
|
+
@exponent = options['exponent'] || 2
|
44
|
+
@restricts = options['restricts'] || []
|
45
|
+
@cortho = options['cortho'] || {}
|
46
|
+
@vortho = options['vortho'] || {}
|
47
|
+
@noortho = options['noortho'] || true
|
48
|
+
@nomorph = options['nomorph'] || true
|
49
|
+
@nowordpool = options['nowordpool'] || true
|
50
|
+
@minsyll = options['minsyll'] || 1
|
51
|
+
@maxsyll = options['maxsyll'] || 1
|
52
|
+
@morphemes = options['morphemes'] || {}
|
53
|
+
@words = options['words'] || {}
|
54
|
+
@names = options['names'] || []
|
55
|
+
@joiner = options['joiner'] || ' '
|
56
|
+
@maxchar = options['maxchar'] || 12
|
57
|
+
@minchar = options['minchar'] || 5
|
58
58
|
end
|
59
59
|
|
60
60
|
@genitive = get_morpheme('of')
|
@@ -135,6 +135,7 @@ class Glossa::Language
|
|
135
135
|
# phonetic word according to the language's orthography.
|
136
136
|
def make_syllable
|
137
137
|
structure = self.structure.chars
|
138
|
+
|
138
139
|
while true
|
139
140
|
syll = ''
|
140
141
|
structure.each do |ptype|
|
@@ -153,7 +154,7 @@ class Glossa::Language
|
|
153
154
|
# Make sure this syllable doesn't violate a restriction
|
154
155
|
bad = false
|
155
156
|
self.restricts.each do |regex|
|
156
|
-
if regex =~ syll
|
157
|
+
if /#{regex}/ =~ syll
|
157
158
|
bad = true
|
158
159
|
break
|
159
160
|
end
|
data/lib/glossa.rb
CHANGED
@@ -249,13 +249,14 @@ module Glossa
|
|
249
249
|
},
|
250
250
|
{
|
251
251
|
:name => "Double sounds",
|
252
|
-
:res => [
|
252
|
+
:res => ['(.)\1']
|
253
253
|
},
|
254
254
|
{
|
255
255
|
:name => "Doubles and hard clusters",
|
256
|
-
:res => [
|
256
|
+
:res => ['[sʃf][sʃ]', '(.)\1', '[rl][rl]']
|
257
257
|
}
|
258
258
|
]
|
259
259
|
end
|
260
260
|
|
261
|
-
require "glossa/language"
|
261
|
+
require "glossa/language"
|
262
|
+
require "glossa/import_export"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glossa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Franklin
|
@@ -20,6 +20,7 @@ extensions: []
|
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
22
|
- lib/glossa.rb
|
23
|
+
- lib/glossa/import_export.rb
|
23
24
|
- lib/glossa/language.rb
|
24
25
|
homepage: http://rubygems.org/gems/glossa
|
25
26
|
licenses:
|