pils 0.1.4
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 +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/README.md +39 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/pils +3 -0
- data/lib/pils.rb +64 -0
- data/lib/pils/de.rb +24 -0
- data/lib/pils/de/skeleton.rb +207 -0
- data/lib/pils/de/small.rb +128 -0
- data/lib/pils/parsing.rb +31 -0
- data/lib/pils/parsing/cat.rb +62 -0
- data/lib/pils/parsing/grammar.rb +47 -0
- data/lib/pils/parsing/lexicon.rb +100 -0
- data/lib/pils/parsing/parser.rb +310 -0
- data/lib/pils/parsing/rule.rb +43 -0
- data/lib/pils/parsing/tree.rb +147 -0
- data/lib/pils/parsing/wordform.rb +44 -0
- data/lib/pils/structures.rb +7 -0
- data/lib/pils/structures/avm.rb +98 -0
- data/lib/pils/tcf.rb +37 -0
- data/lib/pils/tcf/annotation.rb +42 -0
- data/lib/pils/tcf/bounded_element.rb +46 -0
- data/lib/pils/tcf/geo_annotation.rb +29 -0
- data/lib/pils/tcf/named_entity_annotation.rb +31 -0
- data/lib/pils/tcf/sentence.rb +47 -0
- data/lib/pils/tcf/tcf_document.rb +296 -0
- data/lib/pils/tcf/token.rb +52 -0
- data/lib/pils/tcf/transform/transformer.rb +468 -0
- data/lib/pils/version.rb +3 -0
- data/pils-0.1.2.gem +0 -0
- data/pils.gemspec +41 -0
- data/tasks/testing.rake +23 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 357658e3b7c5d1479053eb5d8cfafcd1d8e3a3df2d8e4d97436a3aa1e7f4960a
|
4
|
+
data.tar.gz: c2a44334af701eeb1228cd2641abf09b9c8196fa684a3ff6e480838e46626b39
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dca1324113a3f5ba96cfd0af49eb46232eb70234c299b6ff3a3c04c46484a3fe4556c39529fa9b3efa611bd33ed5d2f69bbfd44bb7d6709524375d52b43e4e07
|
7
|
+
data.tar.gz: 89534de943b6491ea6e9cb169cc50180ec2bd717939ed5fd82e2ce8a8fd1b7492bc898de7a5cfe9948c350a4fcc257596aa6a4df88146a1a7d955c3420046d4d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at peter.menke@upb.de. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Pils
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pils`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'pils'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install pils
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pils. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## Code of Conduct
|
38
|
+
|
39
|
+
Everyone interacting in the Pils project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/pils/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "pils"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/pils
ADDED
data/lib/pils.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# (c) 2019 Peter Menke
|
4
|
+
#
|
5
|
+
# This file is part of pils
|
6
|
+
# ("Programming in linguistic seminars").
|
7
|
+
#
|
8
|
+
# pils is free software: you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation, either version 3 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# pils is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with pils. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
21
|
+
require "pils/version"
|
22
|
+
require 'pils/structures'
|
23
|
+
require 'pils/parsing'
|
24
|
+
require 'pils/de'
|
25
|
+
require 'pils/tcf'
|
26
|
+
|
27
|
+
|
28
|
+
# The pils module is the overall container for all code snippets,
|
29
|
+
# classes and methods that deal with linguistic modelling.
|
30
|
+
module Pils
|
31
|
+
# Your code goes here...
|
32
|
+
|
33
|
+
# The output stream used for pils-internal writing.
|
34
|
+
def self.out
|
35
|
+
@out
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.out=(new_out)
|
39
|
+
@out=new_out
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.err
|
43
|
+
@err
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.err=(new_err)
|
47
|
+
@err=new_err
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.log(msg, stream=:err)
|
51
|
+
if stream==:err && !self.err.nil?
|
52
|
+
self.err << msg
|
53
|
+
self.err << "\n"
|
54
|
+
end
|
55
|
+
if stream==:out && !self.out.nil?
|
56
|
+
self.out << msg
|
57
|
+
self.out << "\n"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
self.out=STDOUT#nil#STDOUT
|
62
|
+
self.err=nil#STDERR
|
63
|
+
|
64
|
+
end
|
data/lib/pils/de.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# This file is part of Pils.
|
2
|
+
#
|
3
|
+
# Pils is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU Lesser General Public License as
|
5
|
+
# published by the Free Software Foundation, either version 3 of
|
6
|
+
# the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# Pils is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the
|
14
|
+
# GNU Lesser General Public License along with Pils.
|
15
|
+
# If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
module Pils
|
18
|
+
module De
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
require "pils/de/small"
|
24
|
+
require "pils/de/skeleton"
|
@@ -0,0 +1,207 @@
|
|
1
|
+
# This file is part of Pils.
|
2
|
+
#
|
3
|
+
# Pils is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU Lesser General Public License as
|
5
|
+
# published by the Free Software Foundation, either version 3 of
|
6
|
+
# the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# Pils is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the
|
14
|
+
# GNU Lesser General Public License along with Pils.
|
15
|
+
# If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
17
|
+
# This is a language config file.
|
18
|
+
|
19
|
+
module Pils
|
20
|
+
module De
|
21
|
+
module Skeleton
|
22
|
+
|
23
|
+
|
24
|
+
CAS = %w(nom gen dat acc) #[:nom, :gen, :dat, :acc]
|
25
|
+
NUM = %w(sg pl) #[:sg, :pl]
|
26
|
+
GEN = %w(m f n) # [:m, :f, :n]
|
27
|
+
PER = %w(1 2 3) # [:er, :zw, :dr]
|
28
|
+
MOD = %w(imp ind) # [:imp, :fin, :inf]
|
29
|
+
TMP = %w(pres)
|
30
|
+
VAL = %w(t0 tdir tind tdirind)
|
31
|
+
|
32
|
+
ADJ_SUFFIXES_WEAK = %w(e en en en en en en en)
|
33
|
+
ADJ_SUFFIXES_STRONG = %w(er en em en e er er e es en em es)
|
34
|
+
ADJ_SUFFIXES_STRONG_PLURAL = %w(e er en e)
|
35
|
+
|
36
|
+
def self.add_german_verb(lex, grundform, zweitform, praetform, partform, valence, semantic_component)
|
37
|
+
lex.add_wordform Wordform.new(normalize_forms("#{grundform}e"), "V_fin_sg_1_pres_#{valence}".to_sym, {}, semantic_component.clone )
|
38
|
+
lex.add_wordform Wordform.new(normalize_forms("#{zweitform}st"), "V_fin_sg_2_pres_#{valence}".to_sym, {}, semantic_component.clone )
|
39
|
+
lex.add_wordform Wordform.new(normalize_forms("#{zweitform}t"), "V_fin_sg_3_pres_#{valence}".to_sym, {}, semantic_component.clone )
|
40
|
+
lex.add_wordform Wordform.new(normalize_forms("#{grundform}en"), "V_fin_pl_1_pres_#{valence}".to_sym, {}, semantic_component.clone )
|
41
|
+
lex.add_wordform Wordform.new(normalize_forms("#{grundform}t"), "V_fin_pl_2_pres_#{valence}".to_sym, {}, semantic_component.clone )
|
42
|
+
lex.add_wordform Wordform.new(normalize_forms("#{grundform}en"), "V_fin_pl_3_pres_#{valence}".to_sym, {}, semantic_component.clone )
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.add_irregular_verb(lex, tempus, valence, semantic_component, *forms)
|
46
|
+
lex.add_wordform Wordform.new(normalize_forms(forms[0]), "V_fin_sg_1_#{tempus}_#{valence}".to_sym, {}, semantic_component.clone )
|
47
|
+
lex.add_wordform Wordform.new(normalize_forms(forms[1]), "V_fin_sg_2_#{tempus}_#{valence}".to_sym, {}, semantic_component.clone )
|
48
|
+
lex.add_wordform Wordform.new(normalize_forms(forms[2]), "V_fin_sg_3_#{tempus}_#{valence}".to_sym, {}, semantic_component.clone )
|
49
|
+
lex.add_wordform Wordform.new(normalize_forms(forms[3]), "V_fin_pl_1_#{tempus}_#{valence}".to_sym, {}, semantic_component.clone )
|
50
|
+
lex.add_wordform Wordform.new(normalize_forms(forms[4]), "V_fin_pl_2_#{tempus}_#{valence}".to_sym, {}, semantic_component.clone )
|
51
|
+
lex.add_wordform Wordform.new(normalize_forms(forms[5]), "V_fin_pl_3_#{tempus}_#{valence}".to_sym, {}, semantic_component.clone )
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.add_german_noun(lex, semantic_component, gender, forms)
|
55
|
+
lex.add_wordform(Wordform.new(forms[0], "N_nom_sg_#{gender}_3".to_sym, {}, semantic_component.clone.merge({number: :singular}) ))
|
56
|
+
lex.add_wordform(Wordform.new(forms[1], "N_gen_sg_#{gender}_3".to_sym, {}, semantic_component.clone.merge({number: :singular}) ))
|
57
|
+
lex.add_wordform(Wordform.new(forms[2], "N_dat_sg_#{gender}_3".to_sym, {}, semantic_component.clone.merge({number: :singular}) ))
|
58
|
+
lex.add_wordform(Wordform.new(forms[3], "N_acc_sg_#{gender}_3".to_sym, {}, semantic_component.clone.merge({number: :singular}) ))
|
59
|
+
lex.add_wordform(Wordform.new(forms[4], "N_nom_pl_#{gender}_3".to_sym, {}, semantic_component.clone.merge({number: :plural}) ))
|
60
|
+
lex.add_wordform(Wordform.new(forms[5], "N_gen_pl_#{gender}_3".to_sym, {}, semantic_component.clone.merge({number: :plural}) ))
|
61
|
+
lex.add_wordform(Wordform.new(forms[6], "N_dat_pl_#{gender}_3".to_sym, {}, semantic_component.clone.merge({number: :plural}) ))
|
62
|
+
lex.add_wordform(Wordform.new(forms[7], "N_acc_pl_#{gender}_3".to_sym, {}, semantic_component.clone.merge({number: :plural}) ))
|
63
|
+
end
|
64
|
+
|
65
|
+
# adds adjective forms in a simple way
|
66
|
+
# e.g., we do not distinguish starke und schwache Flexion in the category
|
67
|
+
def self.add_german_adjective(lex, stamm, semantic_component)
|
68
|
+
CAS.each_with_index do |k,x|
|
69
|
+
GEN.each_with_index do |g,z|
|
70
|
+
NUM.each_with_index do |n,y|
|
71
|
+
suff = ADJ_SUFFIXES_WEAK[x+y*4]
|
72
|
+
lex.add_wordform(Wordform.new(normalize_forms("#{stamm}#{suff}"), "ADJA_#{k}_#{n}_#{g}_3".to_sym, {}, semantic_component.clone))
|
73
|
+
end
|
74
|
+
suff = ADJ_SUFFIXES_STRONG[x+z*4]
|
75
|
+
lex.add_wordform(Wordform.new(normalize_forms("#{stamm}#{suff}"), "ADJA_#{k}_sg_#{g}_3".to_sym, {}, semantic_component.clone))
|
76
|
+
suff = ADJ_SUFFIXES_STRONG_PLURAL[x]
|
77
|
+
lex.add_wordform(Wordform.new(normalize_forms("#{stamm}#{suff}"), "ADJA_#{k}_pl_#{g}_3".to_sym, {}, semantic_component.clone))
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.normalize_forms(form)
|
83
|
+
form = form.gsub(/ee/, 'e')
|
84
|
+
form
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.define_grammar
|
88
|
+
include Pils::Parsing
|
89
|
+
g = Grammar.new()
|
90
|
+
sentence = Cat.new(:S)
|
91
|
+
g.starting_cats = [ sentence ]
|
92
|
+
|
93
|
+
# Define rules for S -> NP VP
|
94
|
+
# for each combination of (NUM, PER, TMP, GEN)
|
95
|
+
NUM.each do |num|
|
96
|
+
PER.each do |per|
|
97
|
+
TMP.each do |tmp|
|
98
|
+
# define a rule VP_fin -> V_fin
|
99
|
+
r = Rule.new(Cat.new("VP_fin_#{num}_#{per}_#{tmp}".to_sym, :agens), [ Cat.new("V_fin_#{num}_#{per}_#{tmp}_t0".to_sym, :predicate)], {})
|
100
|
+
g.rules << r
|
101
|
+
GEN.each do |gen|
|
102
|
+
r = Rule.new(Cat.new(:S), [ Cat.new("NP_nom_#{num}_#{gen}_#{per}".to_sym, :agens), Cat.new("VP_fin_#{num}_#{per}_#{tmp}".to_sym, :predicate)], {})
|
103
|
+
g.rules << r
|
104
|
+
|
105
|
+
# define a rule VP_fin -> V_fin NP_!AKK (both NUM, all PER, all GEN)
|
106
|
+
# independent PERSON!
|
107
|
+
NUM.each do |num2|
|
108
|
+
r = Rule.new(Cat.new("VP_fin_#{num}_#{per}_#{tmp}".to_sym, :agens),
|
109
|
+
[ Cat.new("V_fin_#{num}_#{per}_#{tmp}_tdir".to_sym, :predicate),
|
110
|
+
Cat.new("NP_acc_#{num2}_#{gen}_#{per}".to_sym, :dirobj)], {})
|
111
|
+
g.rules << r
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# NP rules
|
119
|
+
# NP -> DET NPX
|
120
|
+
# NPX -> ADJA NPX
|
121
|
+
# NPX -> N
|
122
|
+
# for each combination of (CAS, NUM, GEN)
|
123
|
+
CAS.each do |cas|
|
124
|
+
NUM.each do |num|
|
125
|
+
GEN.each do |gen|
|
126
|
+
#PER.each do |per|
|
127
|
+
r = Rule.new(Cat.new("NP_#{cas}_#{num}_#{gen}_3".to_sym), [ Cat.new("DETD_#{cas}_#{num}_#{gen}_3".to_sym), Cat.new("NPX_#{cas}_#{num}_#{gen}_3".to_sym)], {})
|
128
|
+
g.rules << r
|
129
|
+
r = Rule.new(Cat.new("NP_#{cas}_#{num}_#{gen}_3".to_sym), [ Cat.new("INTP_#{cas}_#{num}_#{gen}_3".to_sym), Cat.new("NPX_#{cas}_#{num}_#{gen}_3".to_sym)], {})
|
130
|
+
g.rules << r
|
131
|
+
r = Rule.new(Cat.new("NPX_#{cas}_#{num}_#{gen}_3".to_sym), [ Cat.new("N_#{cas}_#{num}_#{gen}_3".to_sym)], {})
|
132
|
+
g.rules << r
|
133
|
+
#r = Rule.new(Cat.new("NPX_#{cas}_#{num}_#{gen}_3".to_sym), [ Cat.new("ADJA_#{cas}_#{num}_#{gen}_3".to_sym, :attrib), Cat.new("NPX_#{cas}_#{num}_#{gen}_3".to_sym)], {})
|
134
|
+
#g.rules << r
|
135
|
+
|
136
|
+
r = Rule.new(Cat.new("NPX_#{cas}_#{num}_#{gen}_3".to_sym), [ Cat.new("AP_#{cas}_#{num}_#{gen}_3".to_sym, :attrib), Cat.new("NPX_#{cas}_#{num}_#{gen}_3".to_sym)], {})
|
137
|
+
g.rules << r
|
138
|
+
r = Rule.new(Cat.new("AP_#{cas}_#{num}_#{gen}_3".to_sym), [ Cat.new("ADJA_#{cas}_#{num}_#{gen}_3".to_sym)], {})
|
139
|
+
g.rules << r
|
140
|
+
#end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
# NP rules, plural: nouns only
|
146
|
+
CAS.each do |cas|
|
147
|
+
GEN.each do |gen|
|
148
|
+
r = Rule.new(Cat.new("NP_#{cas}_pl_#{gen}_3".to_sym), [ Cat.new("NPX_#{cas}_pl_#{gen}_3".to_sym)], {det: :no})
|
149
|
+
g.rules << r
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
return g
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
def self.define_lexicon
|
158
|
+
lexicon = Lexicon.new()
|
159
|
+
|
160
|
+
# Definite Artikel
|
161
|
+
definite_articles = %w(der des dem den die der den die die der der die die der den die das des dem das die der den die)
|
162
|
+
id = 0
|
163
|
+
GEN.each do |gen|
|
164
|
+
NUM.each do |num|
|
165
|
+
CAS.each do |cas|
|
166
|
+
form = definite_articles[id]
|
167
|
+
id = id + 1
|
168
|
+
semantics = {det: :yes}
|
169
|
+
semantics[:number] = :singular if num=='sg'
|
170
|
+
semantics[:number] = :plural if num=='pl'
|
171
|
+
lexicon.add_wordform Wordform.new(form, "DETD_#{cas}_#{num}_#{gen}_3".to_sym, {}, semantics)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
indefinite_articles = %w(ein eines einem einen eine einer einer eine ein eines einem ein)
|
177
|
+
id = 0
|
178
|
+
GEN.each do |gen|
|
179
|
+
CAS.each do |cas|
|
180
|
+
form = indefinite_articles[id]
|
181
|
+
id = id + 1
|
182
|
+
lexicon.add_wordform Wordform.new(form, "DETD_#{cas}_sg_#{gen}_3".to_sym, {}, {det: :yes})
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
interrog = %w(welcher welches welchem welchen welche welcher welchen welche)
|
187
|
+
interrog << %w(welche welcher welcher welche welche welcher welchen welche)
|
188
|
+
interrog << %w(welches welchen welchem welches welche welcher welchen welche)
|
189
|
+
interrog.flatten!
|
190
|
+
id=0
|
191
|
+
GEN.each do |gen|
|
192
|
+
NUM.each do |num|
|
193
|
+
CAS.each do |cas|
|
194
|
+
form = interrog[id]
|
195
|
+
id = id + 1
|
196
|
+
semantics = {det: :yes, pronoun_type: :interrogative}
|
197
|
+
semantics[:number] = :singular if num=='sg'
|
198
|
+
semantics[:number] = :plural if num=='pl'
|
199
|
+
lexicon.add_wordform Wordform.new(form, "INTP_#{cas}_#{num}_#{gen}_3".to_sym, {}, semantics)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
return lexicon
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|