reina 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/reina/stream_parser.rb +93 -0
  3. metadata +58 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f7189c79c0dbf6896c213647d41544e53c50ef18
4
+ data.tar.gz: 656ea92b8ee16de825b7f78bc6ec67865a800e46
5
+ SHA512:
6
+ metadata.gz: 389937264d110c39aadaece98379a495417fe1c7912c7009a76d2d11e537a3315b85e5d7668735d3e19359c23dcc0e6acfac1d41ab260266e4df714d56098001
7
+ data.tar.gz: 0fb3744dc445694446fef3e599920e942b69c079113976abfba3df74e591de1d71b060c278cd8e03d0183bd897f320f8bbba86635fce7c1809c355328e5a2af6
@@ -0,0 +1,93 @@
1
+ # Copyright (C) 2014 Vee Satayamas
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY
18
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require "whittle"
23
+
24
+ module Reina
25
+ class Lu
26
+ attr_reader :surface, :analyses
27
+
28
+ def initialize
29
+ @analyses = []
30
+ end
31
+ end
32
+
33
+ class AmbiLu < Lu
34
+ def initialize(surface, analyses)
35
+ super()
36
+ @surface = surface
37
+ @analyses = analyses
38
+ end
39
+ end
40
+
41
+ class UnkLu < Lu
42
+ def initialize(surface)
43
+ super()
44
+ @surface = surface
45
+ end
46
+ end
47
+
48
+ class NonLu < Lu
49
+ def initialize(surface)
50
+ super()
51
+ @surface = surface
52
+ end
53
+ end
54
+
55
+ class StreamParser < Whittle::Parser
56
+ rule(:wsp => /\s+/).skip!
57
+ rule(:surface => /\^[^\^^\$^\<][^\$^<^\/]*/)
58
+ rule(:text => /[^\/^\^^\$^\<][^\^]*/)
59
+ rule(:elu => /\$/)
60
+ rule(:tag => /<\w+>/)
61
+ rule(:lemma => /\/[^\*^\$^<]+/)
62
+ rule(:unk => /\/\*[^\$]+/)
63
+
64
+ rule(:tags) do |r|
65
+ r[:tags, :tag].as {|tags, tag|
66
+ tags + [tag]
67
+ }
68
+ r[:tag].as {|t| [t[1..-2]]}
69
+ end
70
+
71
+ rule(:analysis) do |r|
72
+ r[:lemma, :tags].as {|lemma, tags| {tags: tags, lemma: lemma[1..-1]}}
73
+ end
74
+
75
+ rule(:analyses) do |r|
76
+ r[:analyses, :analysis].as {|analyses, analysis| analyses + [analysis]}
77
+ r[:analysis].as {|analysis| [analysis]}
78
+ end
79
+
80
+ rule(:lu) do |r|
81
+ r[:surface, :analyses, :elu].as {|surface, analyses, _|
82
+ AmbiLu.new(surface[1..-1], analyses)}
83
+ r[:surface, :unk, :elu].as {|surface, _, _| UnkLu.new(surface[1..-1])}
84
+ r[:text].as {|txt| NonLu.new(txt)}
85
+ end
86
+
87
+ rule(:stream) do |r|
88
+ r[:stream, :lu].as {|lu_lst, lu| lu_lst + [lu]}
89
+ r[:lu].as {|lu| [lu]}
90
+ end
91
+ start(:stream)
92
+ end
93
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reina
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Vee Satayamas
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: whittle
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.8
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.8
27
+ description: Reina.rb is a toolset for Apertium written in Ruby
28
+ email: vsatayamas@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/reina/stream_parser.rb
34
+ homepage: https://github.com/veer66/reinarb
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 2.1.11
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: A toolset for Apertium written in Ruby
58
+ test_files: []