transcribe 0.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.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile ~/.gitignore_global
6
+
7
+ # Ignore OS X garbage
8
+ .DS_Store
9
+
10
+ # Ignore bundler config
11
+ /.bundle
12
+
13
+ # Ignore the default SQLite database.
14
+ /db/*.sqlite3
15
+
16
+ # Ignore all logfiles and tempfiles.
17
+ /log/*.log
18
+ /tmp
19
+ /pkg
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in transcribe.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Bryan McKelvey
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Transcribe
2
+
3
+ Transcribes a language into IPA
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'transcribe'
10
+
11
+ And then execute:
12
+
13
+ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ gem install transcribe
18
+
19
+ ## Usage
20
+
21
+ Transcribe a phrase:
22
+
23
+ transcribe dutch "hallo mensen"
24
+ # => ɦɑlɔ mɛnsɛn
25
+
26
+ Transcribe a file:
27
+
28
+ transcribe dutch hello_world.txt
29
+
30
+ Write transcription to a file
31
+
32
+ transcribe dutch "hallo mensen" > hello_world.txt
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/transcribe ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby -wKU
2
+ require "transcribe"
3
+
4
+ language_name, file = ARGV
5
+
6
+ # Grab text from file if it exists, using text otherwise. We need to duplicate that text if we're
7
+ # using it because it's immutable.
8
+ text = File.exist?(file) ? File.read(file).downcase : file.dup
9
+
10
+ language = Transcribe::Language.new(language_name)
11
+ puts language.transcribe(text)
@@ -0,0 +1,65 @@
1
+ ---
2
+ # VOWELS
3
+ # Diphthongs
4
+ - auw: ʌu
5
+ - aa: aː
6
+ - ei: ɛi
7
+ - ee: eː
8
+ - eu: øː
9
+ - ie: i
10
+ - ij: ɛi
11
+ - oe: u
12
+ - oo: oː
13
+ - ui: œy
14
+ - uu: yː
15
+
16
+ # Monophthongs
17
+ - a: ɑ
18
+ - e: ɛ
19
+ - i: ɪ
20
+ - o: ɔ
21
+ - u: ʏ
22
+
23
+ # CONSONANTS
24
+ # Diphthongs
25
+ - sch: sx
26
+ - ch: x
27
+ - ck: k
28
+ - ng: ŋ
29
+ - nj: nj
30
+ - sj: ʃ
31
+ - tj: tj
32
+
33
+ # Special
34
+ - b: p
35
+ word_final: true
36
+ - d: t
37
+ word_final: true
38
+ - g: x
39
+ word_initial: true
40
+
41
+ # Monophthongs
42
+ - b: b
43
+ repeatable: true
44
+ - d: d
45
+ repeatable: true
46
+ - f: f
47
+ - g: ɣ
48
+ - h: ɦ
49
+ - j: j
50
+ - k: k
51
+ repeatable: true
52
+ - l: l
53
+ repeatable: true
54
+ - m: m
55
+ - n: n
56
+ - p: p
57
+ repeatable: true
58
+ - r: r
59
+ - s: s
60
+ repeatable: true
61
+ - t: t
62
+ repeatable: true
63
+ - v: v
64
+ - w: ʋ
65
+ - z: z
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ require "transcribe/term"
3
+ require "yaml"
4
+
5
+ module Transcribe
6
+ class Language
7
+ def initialize(name)
8
+ @name = name
9
+ load_yaml(@name)
10
+ end
11
+
12
+ def transcribe(text)
13
+ @terms.each { |t| t.apply! text }
14
+ text
15
+ end
16
+
17
+ private
18
+
19
+ def load_yaml(name)
20
+ @terms = []
21
+ path = File.join(File.expand_path(File.dirname(__FILE__)), "language", "#{name}.yml")
22
+ yaml = YAML.load_file(path)
23
+ yaml.each { |t| @terms << Term.create_from_yaml(t) }
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ require "transcribe/term"
3
+
4
+ module Transcribe
5
+ class Term
6
+ WORD_BOUNDARY = "\\b"
7
+ REPETITION = "+"
8
+
9
+ class << self
10
+ def create_from_yaml(yaml)
11
+ from, to = yaml.shift
12
+ Term.new from, to, yaml
13
+ end
14
+ end
15
+
16
+ def initialize(from, to, opts = {})
17
+ @to = to
18
+ if opts.empty?
19
+ @from = from
20
+ else
21
+ from = Regexp.escape(from)
22
+ flags = ""
23
+ from.concat REPETITION if opts["repeatable"]
24
+ from.prepend WORD_BOUNDARY if opts["word_initial"]
25
+ from.concat WORD_BOUNDARY if opts["word_final"]
26
+ @from = Regexp.new(from, flags)
27
+ end
28
+ end
29
+
30
+ def apply!(text)
31
+ text.gsub! @from, @to
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,4 @@
1
+ # coding: utf-8
2
+ module Transcribe
3
+ VERSION = "0.0.1"
4
+ end
data/lib/transcribe.rb ADDED
@@ -0,0 +1,7 @@
1
+ # coding: utf-8
2
+ require "transcribe/language"
3
+ require "transcribe/term"
4
+ require "transcribe/version"
5
+
6
+ module Transcribe
7
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/transcribe/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Bryan McKelvey"]
6
+ gem.email = ["bryan.mckelvey@gmail.com"]
7
+ gem.description = %q{Transcribes a language into IPA}
8
+ gem.summary = %q{Transcribes a language into IPA}
9
+ gem.homepage = "https://github.com/brymck/transcribe"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "transcribe"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Transcribe::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: transcribe
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Bryan McKelvey
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-12 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Transcribes a language into IPA
15
+ email:
16
+ - bryan.mckelvey@gmail.com
17
+ executables:
18
+ - transcribe
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE
25
+ - README.md
26
+ - Rakefile
27
+ - bin/transcribe
28
+ - lib/transcribe.rb
29
+ - lib/transcribe/language.rb
30
+ - lib/transcribe/language/dutch.yml
31
+ - lib/transcribe/term.rb
32
+ - lib/transcribe/version.rb
33
+ - transcribe.gemspec
34
+ homepage: https://github.com/brymck/transcribe
35
+ licenses: []
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 1.8.21
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: Transcribes a language into IPA
58
+ test_files: []
59
+ has_rdoc: