dm_wordnet 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ Capfile
2
+ config
3
+ config/deploy.rb
4
+ wordnatra.tmproj
5
+ database.yml
@@ -0,0 +1,13 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'dm_wordnet'
3
+ s.version = '0.1.0'
4
+ s.summary = 'DataMapper models for Wordnet'
5
+ s.description = 'https://github.com/laMarciana/dm_wordnet/'
6
+ s.license = 'MIT'
7
+ s.authors = ['Marc Busqué']
8
+ s.homepage = 'https://github.com/laMarciana/dm_wordnet/'
9
+ s.email = ['marc@lamarciana.com']
10
+ s.files = `git ls-files`.split("\n")
11
+
12
+ s.add_runtime_dependency "data_mapper", "~>1.0"
13
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Brian Knox
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 AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,130 @@
1
+ -- exploring relationships betweent tables
2
+ select sense.wordid, word.lemma,
3
+ synset.definition, sample.sample, categorydef.name,
4
+ sentenceref.sentenceid, sentencedef.sentence,
5
+ frameref.frameid, framedef.frame,
6
+ morphref.morphid, morphdef.lemma as morphdef_lemma,
7
+ casedword.lemma as casedword_lemma
8
+ from sense
9
+ inner join word on sense.wordid = word.wordid
10
+ left outer join wordposition on sense.wordid = wordposition.wordid and sense.synsetid = wordposition.synsetid
11
+ inner join synset on sense.synsetid = synset.synsetid
12
+ left outer join sample on synset.synsetid = sample.synsetid
13
+ left outer join categorydef on synset.categoryid = categorydef.categoryid
14
+ left outer join casedword on sense.wordid = casedword.wordid
15
+ left outer join sentenceref on sense.synsetid = sentenceref.synsetid and sense.wordid = sentenceref.wordid
16
+ left outer join sentencedef on sentenceref.sentenceid = sentencedef.sentenceid
17
+ left outer join frameref on sense.synsetid = frameref.synsetid and sense.wordid = frameref.wordid
18
+ left outer join framedef on frameref.frameid = framedef.frame
19
+ left outer join morphref on word.wordid = morphref.wordid
20
+ left outer join morphdef on morphref.morphid = morphdef.morphid
21
+ where word.lemma = 'love' and sense.rank = 2
22
+
23
+ -- hypernyms horse (n)
24
+ select se1.rank,w2.lemma
25
+ from word w1
26
+ left join sense se1 on w1.wordid = se1.wordid
27
+ left join synset sy1 on se1.synsetid = sy1.synsetid
28
+ left join semlinkref on sy1.synsetid = semlinkref.synset1id
29
+ left join synset sy2 on semlinkref.synset2id = sy2.synsetid
30
+ left join sense se2 on sy2.synsetid = se2.synsetid
31
+ left join word w2 on se2.wordid = w2.wordid
32
+ where w1.lemma = 'horse'
33
+ and sy1.pos = 'n'
34
+ and semlinkref.linkid = 1
35
+ order by se1.rank asc;
36
+
37
+ -- hyponyms horse (n)
38
+ select se1.rank,w2.lemma
39
+ from word w1
40
+ left join sense se1 on w1.wordid = se1.wordid
41
+ left join synset sy1 on se1.synsetid = sy1.synsetid
42
+ left join semlinkref on sy1.synsetid = semlinkref.synset1id
43
+ left join synset sy2 on semlinkref.synset2id = sy2.synsetid
44
+ left join sense se2 on sy2.synsetid = se2.synsetid
45
+ left join word w2 on se2.wordid = w2.wordid
46
+ where w1.lemma = 'horse'
47
+ and sy1.pos = 'n'
48
+ and semlinkref.linkid = 2
49
+ order by se1.rank asc;
50
+
51
+ -- get verbnet thematic roles for verb 'want'
52
+ select word.lemma,synset.synsetid,vnrole.rolesetid,vnroletype.type,vnselrestrs.selrestrs
53
+ from word
54
+ left join sense on word.wordid=sense.wordid
55
+ left join synset on sense.synsetid=synset.synsetid
56
+ left join vnrole on synset.synsetid=vnrole.synsetid and word.wordid=vnrole.wordid
57
+ left join vnroletype on vnrole.roletypeid=vnroletype.roletypeid
58
+ left join vnselrestrs on vnrole.selrestrsid=vnselrestrs.selrestrsid
59
+ where synset.pos='v' and word.lemma='want';
60
+
61
+ -- get xwordnet parses for verb 'want'
62
+ select word.lemma,synset.synsetid,xwnparselft.parse
63
+ from word
64
+ left join sense on word.wordid=sense.wordid
65
+ left join synset on sense.synsetid=synset.synsetid
66
+ left join xwnparselft on synset.synsetid=xwnparselft.synsetid
67
+ where synset.pos='v' and word.lemma='want';
68
+
69
+ -- get xwordnet lft for verb 'want'
70
+ select word.lemma,synset.synsetid,xwnparselft.lft
71
+ from word
72
+ left join sense on word.wordid=sense.wordid
73
+ left join synset on sense.synsetid=synset.synsetid
74
+ left join xwnparselft on synset.synsetid=xwnparselft.synsetid
75
+ where synset.pos='v' and word.lemma='want';
76
+
77
+ -- get xwordnet wsd for verb 'want'
78
+ select word.lemma,synset.synsetid,xwnwsd.wsd
79
+ from word
80
+ left join sense on word.wordid=sense.wordid
81
+ left join synset on sense.synsetid=synset.synsetid
82
+ left join xwnwsd on synset.synsetid=xwnwsd.synsetid
83
+ where synset.pos='v' and word.lemma='want';
84
+
85
+ -- get verbnet syntax/semantics for verb 'want'
86
+ select word.lemma,synset.synsetid,vnframeref.frameid,vnexampledef.example,vnframedef.syntax,vnframedef.semantics
87
+ from word
88
+ left join sense on word.wordid=sense.wordid
89
+ left join synset on sense.synsetid=synset.synsetid
90
+ left join vnframeref on synset.synsetid=vnframeref.synsetid and word.wordid=vnframeref.wordid
91
+ left join vnframedef on vnframeref.frameid=vnframedef.frameid
92
+ left join vnexampleref on vnframeref.frameid=vnexampleref.frameid
93
+ left join vnexampledef on vnexampleref.exampleid=vnexampledef.exampleid
94
+ where synset.pos='v' and word.lemma='want';
95
+
96
+ -- wordnet 2.0->3.0
97
+ select *
98
+ from legacy2030
99
+ where synsetid2=100124550;
100
+
101
+ --wordnet 3.0->2.0
102
+ select *
103
+ from legacy2030
104
+ where synsetid=100130045;
105
+
106
+ ----wordnet 2.0->3.0 for 'want' from sensekey
107
+ select legacy2030.*,legacysensekey2030.sensekey
108
+ from legacysensekey2030
109
+ left join legacy2030 on legacy2030.mapid = legacysensekey2030.mapid
110
+ where legacysensekey2030.sensekey like 'want\%%';
111
+
112
+ --get synonyms for 'house' (all senses)
113
+ select synsetid, w2.lemma from sense
114
+ left join word as w2 on w2.wordid=sense.wordid
115
+ where sense.synsetid in
116
+ (
117
+ select sense.synsetid from word as w1
118
+ left join sense on w1.wordid=sense.wordid
119
+ where w1.lemma='house'
120
+ )
121
+ and w2.lemma<>'house';
122
+
123
+ --get synset offset of 'guide' in WordNet database files
124
+ select synsetid
125
+ from sense
126
+ left join word on word.wordid = sense.wordid
127
+ where word.lemma = 'guide';
128
+
129
+
130
+
@@ -0,0 +1,38 @@
1
+ +---------------------+
2
+ | Tables_in_wordnet30 |
3
+ +---------------------+
4
+ | casedword |
5
+ | categorydef |
6
+ | framedef |
7
+ | frameref |
8
+ | legacy2021 |
9
+ | legacy2030 |
10
+ | legacy2130 |
11
+ | legacysensekey2021 |
12
+ | legacysensekey2030 |
13
+ | legacysensekey2130 |
14
+ | lexlinkref |
15
+ | linkdef |
16
+ | morphdef |
17
+ | morphref |
18
+ | sample |
19
+ | semlinkref |
20
+ | sense |
21
+ | sentencedef |
22
+ | sentenceref |
23
+ | synset |
24
+ | vnclass |
25
+ | vnexampledef |
26
+ | vnexampleref |
27
+ | vnframedef |
28
+ | vnframeref |
29
+ | vnrole |
30
+ | vnroletype |
31
+ | vnselrestr |
32
+ | vnselrestrs |
33
+ | word |
34
+ | wordposition |
35
+ | xwnparselft |
36
+ | xwnwsd |
37
+ +---------------------+
38
+
Binary file
Binary file
@@ -0,0 +1,24 @@
1
+ %w[
2
+ data_mapper
3
+ ].each do |lib|
4
+ require lib
5
+ end
6
+
7
+ require 'dm_wordnet/models/casedword'
8
+ require 'dm_wordnet/models/categorydef'
9
+ require 'dm_wordnet/models/framedef'
10
+ require 'dm_wordnet/models/frameref'
11
+ require 'dm_wordnet/models/lexlinkref'
12
+ require 'dm_wordnet/models/linkdef'
13
+ require 'dm_wordnet/models/morfdef'
14
+ require 'dm_wordnet/models/morphref'
15
+ require 'dm_wordnet/models/sample'
16
+ require 'dm_wordnet/models/sense'
17
+ require 'dm_wordnet/models/sentencedef'
18
+ require 'dm_wordnet/models/sentenceref'
19
+ require 'dm_wordnet/models/symlinkref'
20
+ require 'dm_wordnet/models/synset'
21
+ require 'dm_wordnet/models/word'
22
+ require 'dm_wordnet/models/wordposition'
23
+
24
+ DataMapper.finalize
@@ -0,0 +1,9 @@
1
+ module DmWordnet
2
+ class Casedword
3
+ include DataMapper::Resource
4
+ storage_names[:default]='casedword'
5
+ property :wordid, Integer, :key => true, :writer => :protected
6
+ property :lemma, String, :writer => :protected
7
+ has 1, :sense, :child_key => [:casedwordid]
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module DmWordnet
2
+ class Categorydef
3
+ include DataMapper::Resource
4
+ storage_names[:default]='categorydef'
5
+ property :categoryid, Integer, :key => true, :writer => :protected
6
+ property :name, String, :writer => :protected
7
+ property :pos, String, :writer => :protected
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ module DmWordnet
2
+ class Framedef
3
+ include DataMapper::Resource
4
+ storage_names[:framedef]
5
+ property :frameid, Integer, :key => true, :writer => :protected
6
+ property :frame, String, :writer => :protected
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ module DmWordnet
2
+ class Frameref
3
+ include DataMapper::Resource
4
+ storage_names[:frameref]
5
+ property :synsetid, Integer, :key => true, :writer => :protected
6
+ property :wordid, Integer, :key => true, :writer => :protected
7
+ property :frameid, Integer, :key => true, :writer => :protected
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module DmWordnet
2
+ class Lexlinkref
3
+ include DataMapper::Resource
4
+ storage_names[:default]='lexlinkref'
5
+ property :synset1id, Integer, :key => true, :writer => :protected
6
+ property :word1id, Integer, :key => true, :writer => :protected
7
+ property :synset2id, Integer, :key => true, :writer => :protected
8
+ property :word2id, Integer, :key => true, :writer => :protected
9
+ property :linkid, Integer, :key => true, :writer => :protected
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module DmWordnet
2
+ class Linkdef
3
+ include DataMapper::Resource
4
+ storage_names[:default]='linkdef'
5
+ property :linkid, Integer, :key => true, :writer => :protected
6
+ property :name, String, :writer => :protected
7
+ property :recurses, Boolean, :writer => :protected
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ module DmWordnet
2
+ class Morphdef
3
+ include DataMapper::Resource
4
+ storage_names[:morphdef]
5
+ property :morphid, Integer, :key => true, :writer => :protected
6
+ property :lemma, String, :writer => :protected
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ module DmWordnet
2
+ class Morphref
3
+ include DataMapper::Resource
4
+ storage_names[:morphref]
5
+ property :wordid, Integer, :key => true, :writer => :protected
6
+ property :pos, String, :key => true, :writer => :protected
7
+ property :morphid, Integer, :key => true, :writer => :protected
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ module DmWordnet
2
+ class Sample
3
+ include DataMapper::Resource
4
+ storage_names[:default]='sample'
5
+ property :sampleid, Integer, :key => true, :writer => :protected
6
+ property :synsetid, Integer, :key => true, :writer => :protected
7
+ property :sample, String, :writer => :protected
8
+ belongs_to :synset, :child_key => [:synsetid]
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ module DmWordnet
2
+ class Sense
3
+ include DataMapper::Resource
4
+ storage_names[:default]='sense'
5
+ property :synsetid, Integer, :key => true, :writer => :protected
6
+ property :wordid, Integer, :key => true, :writer => :protected
7
+ property :tagcount, Integer, :writer => :protected
8
+ property :casedwordid, Integer, :writer => :protected
9
+ property :lexid, Integer, :writer => :protected
10
+ property :rank, Integer, :writer => :protected
11
+ belongs_to :word, :child_key => [:wordid]
12
+ belongs_to :synset, :child_key => [:synsetid]
13
+ has n, :wordpositions, :child_key => [:synsetid, :wordid]
14
+ end
15
+ end
@@ -0,0 +1,8 @@
1
+ module DmWordnet
2
+ class Sentencedef
3
+ include DataMapper::Resource
4
+ storage_names[:sentencedef]
5
+ property :sentenceid, Integer, :key => true, :writer => :protected
6
+ property :sentence, String, :writer => :protected
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ module DmWordnet
2
+ class Sentenceref
3
+ include DataMapper::Resource
4
+ storage_names[:sentenceref]
5
+ property :synsetid, Integer, :key => true, :writer => :protected
6
+ property :wordid, Integer, :key => true, :writer => :protected
7
+ property :sentenceid, Integer, :key => true, :writer => :protected
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module DmWordnet
2
+ class Semlinkref
3
+ include DataMapper::Resource
4
+ storage_names[:default]='semlinkref'
5
+ property :synset1id, Integer, :key => true, :writer => :protected
6
+ property :synset2id, Integer, :key => true, :writer => :protected
7
+ property :linkid, Integer, :key => true, :writer => :protected
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ module DmWordnet
2
+ class Synset
3
+ include DataMapper::Resource
4
+ storage_names[:default]='synset'
5
+ property :synsetid, Integer, :key => true, :writer => :protected
6
+ property :categoryid, Integer, :writer => :protected
7
+ property :definition, String, :writer => :protected
8
+ property :pos, String, :writer => :protected
9
+ belongs_to :categorydef, :child_key => [:categoryid]
10
+ has n, :samples, :child_key => [:synsetid]
11
+ has n, :senses, :child_key => [:synsetid]
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ module DmWordnet
2
+ class Word
3
+ include DataMapper::Resource
4
+ storage_names[:default]='word'
5
+ property :wordid, Integer, :key => true, :writer => :protected
6
+ property :lemma, String, :writer => :protected
7
+ has n, :senses, :child_key => [:wordid], :order => [:rank.asc, :synsetid.asc]
8
+ has n, :synsets, :through => :senses, :child_key => [:wordid], :order => [:synsetid.asc]
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ module DmWordnet
2
+ class Wordposition
3
+ include DataMapper::Resource
4
+ storage_names[:default]='wordposition'
5
+ property :synsetid, Integer, :key => true, :writer => :protected
6
+ property :wordid, Integer, :key => true, :writer => :protected
7
+ belongs_to :sense, :child_key => [:synsetid, :wordid]
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dm_wordnet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Marc Busqué
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: data_mapper
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ description: https://github.com/laMarciana/dm_wordnet/
31
+ email:
32
+ - marc@lamarciana.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - dm_wordnet.gemspec
39
+ - doc/MIT-LICENSE
40
+ - doc/sample_queries.sql
41
+ - doc/table_list.txt
42
+ - doc/wnsql.png
43
+ - doc/wordnet30_keys.pdf
44
+ - lib/dm_wordnet.rb
45
+ - lib/dm_wordnet/models/casedword.rb
46
+ - lib/dm_wordnet/models/categorydef.rb
47
+ - lib/dm_wordnet/models/framedef.rb
48
+ - lib/dm_wordnet/models/frameref.rb
49
+ - lib/dm_wordnet/models/lexlinkref.rb
50
+ - lib/dm_wordnet/models/linkdef.rb
51
+ - lib/dm_wordnet/models/morfdef.rb
52
+ - lib/dm_wordnet/models/morphref.rb
53
+ - lib/dm_wordnet/models/sample.rb
54
+ - lib/dm_wordnet/models/sense.rb
55
+ - lib/dm_wordnet/models/sentencedef.rb
56
+ - lib/dm_wordnet/models/sentenceref.rb
57
+ - lib/dm_wordnet/models/symlinkref.rb
58
+ - lib/dm_wordnet/models/synset.rb
59
+ - lib/dm_wordnet/models/word.rb
60
+ - lib/dm_wordnet/models/wordposition.rb
61
+ homepage: https://github.com/laMarciana/dm_wordnet/
62
+ licenses:
63
+ - MIT
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 1.8.23
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: DataMapper models for Wordnet
86
+ test_files: []