rwdeliza 0.03

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 (222) hide show
  1. data/ElizaData/database/db.1 +7015 -0
  2. data/ElizaData/database/db.10 +7001 -0
  3. data/ElizaData/database/db.11 +7001 -0
  4. data/ElizaData/database/db.12 +7003 -0
  5. data/ElizaData/database/db.13 +7003 -0
  6. data/ElizaData/database/db.14 +7008 -0
  7. data/ElizaData/database/db.15 +7001 -0
  8. data/ElizaData/database/db.16 +7001 -0
  9. data/ElizaData/database/db.17 +7001 -0
  10. data/ElizaData/database/db.18 +7001 -0
  11. data/ElizaData/database/db.19 +7001 -0
  12. data/ElizaData/database/db.2 +7001 -0
  13. data/ElizaData/database/db.20 +5467 -0
  14. data/ElizaData/database/db.3 +7001 -0
  15. data/ElizaData/database/db.4 +7001 -0
  16. data/ElizaData/database/db.5 +7001 -0
  17. data/ElizaData/database/db.6 +7001 -0
  18. data/ElizaData/database/db.7 +7001 -0
  19. data/ElizaData/database/db.8 +7001 -0
  20. data/ElizaData/database/db.9 +7001 -0
  21. data/ElizaData/responses/hello.res +1 -0
  22. data/ElizaData/responses/i_agree.res +1 -0
  23. data/ElizaData/responses/i_am_listening_to_you.res +1 -0
  24. data/ElizaData/responses/please_explain.res +1 -0
  25. data/ElizaData/responses/thank_you.res +1 -0
  26. data/ElizaData/tiny.dict +211 -0
  27. data/ElizaData/words/adjectives1.words +906 -0
  28. data/ElizaData/words/adjectives2w.words +1 -0
  29. data/ElizaData/words/noun0.words +15 -0
  30. data/ElizaData/words/noun1.words +1391 -0
  31. data/ElizaData/words/noun2.words +1924 -0
  32. data/ElizaData/words/noun4.words +330 -0
  33. data/ElizaData/words/pronoun1.words +6 -0
  34. data/ElizaData/words/verb4.words +350 -0
  35. data/ElizaData/words/verb42.words +391 -0
  36. data/ElizaData/words/verb42w.words +1 -0
  37. data/ElizaData/words/verb43.words +402 -0
  38. data/ElizaData/words/verb43w.words +1 -0
  39. data/ElizaData/words/verb45.words +452 -0
  40. data/ElizaData/words/verb4w.words +1 -0
  41. data/ElizaData/words/verb5.words +13 -0
  42. data/ElizaData/words/verb61.words +35 -0
  43. data/ElizaData/words/verb62.words +41 -0
  44. data/ElizaData/words/verb83.words +17 -0
  45. data/Readme.txt +462 -0
  46. data/bin/rwdeliza +19 -0
  47. data/code/01rwdcore/01rwdcore.rb +29 -0
  48. data/code/01rwdcore/02helptexthashbegin.rb +4 -0
  49. data/code/01rwdcore/03helptexthash.rb +23 -0
  50. data/code/01rwdcore/04helptextend.rb +6 -0
  51. data/code/01rwdcore/jumplinkcommand.rb +26 -0
  52. data/code/01rwdcore/openhelpwindow.rb +31 -0
  53. data/code/01rwdcore/returntomain.rb +10 -0
  54. data/code/01rwdcore/rundocuments.rb +10 -0
  55. data/code/01rwdcore/runeditconfiguration.rb +10 -0
  56. data/code/01rwdcore/runhelpabout.rb +10 -0
  57. data/code/01rwdcore/runopentinkerdocument.rb +7 -0
  58. data/code/01rwdcore/rwdtinkerversion.rb +22 -0
  59. data/code/01rwdcore/rwdwindowreturn.rb +9 -0
  60. data/code/01rwdcore/selectiontab.rb +9 -0
  61. data/code/01rwdcore/setuphelpaboutoptions.rb +13 -0
  62. data/code/01rwdcore/setuptinkerdocuments.rb +6 -0
  63. data/code/01rwdcore/test_cases.rb +109 -0
  64. data/code/01rwdcore/test_harness.rb +13 -0
  65. data/code/01rwdcore/uploadreturns.rb +62 -0
  66. data/code/dd0viewphoto/dd0viewphoto.rb +3 -0
  67. data/code/superant.com.rwdeliza/0uninstallapplet.rb +10 -0
  68. data/code/superant.com.rwdeliza/eliza01.rb +45 -0
  69. data/code/superant.com.rwdeliza/helptexthashrwdeliza.rb +39 -0
  70. data/code/superant.com.rwdeliza/openhelpwindowrwdeliza.rb +23 -0
  71. data/code/superant.com.rwdeliza/runrwdshellwindow.rb +12 -0
  72. data/code/superant.com.rwdeliza/rwdtinkerversion.rb +10 -0
  73. data/code/superant.com.rwdeliza/tagsentence.rb +39 -0
  74. data/code/superant.com.rwdtinkerbackwindow/diagnostictab.rb +19 -0
  75. data/code/superant.com.rwdtinkerbackwindow/helptexthashtinkerwin2.rb +61 -0
  76. data/code/superant.com.rwdtinkerbackwindow/initiateapplets.rb +240 -0
  77. data/code/superant.com.rwdtinkerbackwindow/installgemapplet.rb +34 -0
  78. data/code/superant.com.rwdtinkerbackwindow/installremotegem.rb +20 -0
  79. data/code/superant.com.rwdtinkerbackwindow/listgemdirs.rb +12 -0
  80. data/code/superant.com.rwdtinkerbackwindow/listgemzips.rb +53 -0
  81. data/code/superant.com.rwdtinkerbackwindow/listinstalledfiles.rb +12 -0
  82. data/code/superant.com.rwdtinkerbackwindow/listzips.rb +27 -0
  83. data/code/superant.com.rwdtinkerbackwindow/loadconfigurationrecord.rb +22 -0
  84. data/code/superant.com.rwdtinkerbackwindow/loadconfigurationvariables.rb +14 -0
  85. data/code/superant.com.rwdtinkerbackwindow/network.rb +87 -0
  86. data/code/superant.com.rwdtinkerbackwindow/openappletname.rb +19 -0
  87. data/code/superant.com.rwdtinkerbackwindow/openhelpwindowtinkerwin2.rb +38 -0
  88. data/code/superant.com.rwdtinkerbackwindow/remotegemlist.rb +24 -0
  89. data/code/superant.com.rwdtinkerbackwindow/removeapplet.rb +46 -0
  90. data/code/superant.com.rwdtinkerbackwindow/removeappletvariables.rb +52 -0
  91. data/code/superant.com.rwdtinkerbackwindow/runremoteinstall.rb +11 -0
  92. data/code/superant.com.rwdtinkerbackwindow/runrwdtinkerbackwindow.rb +15 -0
  93. data/code/superant.com.rwdtinkerbackwindow/rwdtinkerwin2version.rb +13 -0
  94. data/code/superant.com.rwdtinkerbackwindow/saveconfigurationrecord.rb +19 -0
  95. data/code/superant.com.rwdtinkerbackwindow/viewappletcontents.rb +22 -0
  96. data/code/superant.com.rwdtinkerbackwindow/viewgemappletcontents.rb +24 -0
  97. data/code/superant.com.words/dictlookup.rb +20 -0
  98. data/code/superant.com.words/runfortunewindow.rb +14 -0
  99. data/code/superant.com.words/runrwdwordsbackwindow.rb +10 -0
  100. data/code/superant.com.words/runrwdwordsversion.rb +14 -0
  101. data/code/superant.com.words/rwdtinkerversion.rb +10 -0
  102. data/code/zz0applicationend/zz0end.rb +4 -0
  103. data/configuration/language.dist +8 -0
  104. data/configuration/rwdapplicationidentity.dist +3 -0
  105. data/configuration/rwdtinker.dist +18 -0
  106. data/configuration/rwdweliza-0.03.dist +31 -0
  107. data/configuration/tinkerwin2variables.dist +17 -0
  108. data/gui/00coreguibegin/applicationguitop.rwd +4 -0
  109. data/gui/frontwindow0/cc0openphoto.rwd +22 -0
  110. data/gui/frontwindowselections/00selectiontabbegin.rwd +11 -0
  111. data/gui/frontwindowselections/jumplinkcommands.rwd +15 -0
  112. data/gui/frontwindowselections/wwselectionend.rwd +3 -0
  113. data/gui/frontwindowtdocuments/00documentbegin.rwd +6 -0
  114. data/gui/frontwindowtdocuments/tinkerdocuments.rwd +14 -0
  115. data/gui/frontwindowtdocuments/zzdocumentend.rwd +8 -0
  116. data/gui/helpaboutbegin/zzzrwdlasttab.rwd +6 -0
  117. data/gui/helpaboutbegin/zzzzhelpscreenstart.rwd +3 -0
  118. data/gui/helpaboutbegin/zzzzzzhelpabouttab.rwd +15 -0
  119. data/gui/helpaboutzend/helpscreenend.rwd +3 -0
  120. data/gui/helpaboutzend/zhelpscreenstart2.rwd +3 -0
  121. data/gui/helpaboutzend/zzzzhelpabout2.rwd +15 -0
  122. data/gui/helpaboutzend/zzzzhelpscreen2end.rwd +3 -0
  123. data/gui/tinkerbackwindows/superant.com.refreshwindow/fortunerefreshwindowtwo.rwd +9 -0
  124. data/gui/tinkerbackwindows/superant.com.rwdeliza/1appname.rwd +5 -0
  125. data/gui/tinkerbackwindows/superant.com.rwdeliza/1eliza.rwd +21 -0
  126. data/gui/tinkerbackwindows/superant.com.rwdeliza/4sentance.rwd +21 -0
  127. data/gui/tinkerbackwindows/superant.com.rwdeliza/98jumplinkcommands.rwd +17 -0
  128. data/gui/tinkerbackwindows/superant.com.rwdeliza/zbackend.rwd +6 -0
  129. data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/1appname.rwd +5 -0
  130. data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/20downloadftp.rwd +45 -0
  131. data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/67viewconfiguration.rwd +29 -0
  132. data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/70rwddiagnostics.rwd +16 -0
  133. data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/m01menubegin.rwd +18 -0
  134. data/gui/tinkerbackwindows/superant.com.rwdschedulebackwindow/zvbackend.rwd +6 -0
  135. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/1appname.rwd +5 -0
  136. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/40rwdlistzips.rwd +41 -0
  137. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/45installremotezip.rwd +44 -0
  138. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/50rwdlistapplets.rwd +44 -0
  139. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/60editconfiguration.rwd +30 -0
  140. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/70rwddiagnostics.rwd +29 -0
  141. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/81jumplinkcommands.rwd +17 -0
  142. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/9backend.rwd +6 -0
  143. data/gui/tinkerbackwindows/superant.com.tinkerhelpwindow/1appname.rwd +31 -0
  144. data/gui/tinkerbackwindows/superant.com.tinkerhelpwindow/9end.rwd +4 -0
  145. data/gui/tinkerbackwindows/superant.com.versionwindow/1appname.rwd +19 -0
  146. data/gui/tinkerbackwindows/superant.com.versionwindow/helpaboutwindow.rwd +17 -0
  147. data/gui/tinkerbackwindows/superant.com.words/1appname.rwd +4 -0
  148. data/gui/tinkerbackwindows/superant.com.words/1dictionary.rwd +19 -0
  149. data/gui/tinkerbackwindows/superant.com.words/3rwdfortune.rwd +14 -0
  150. data/gui/tinkerbackwindows/superant.com.words/77jumplinkcommands.rwd +17 -0
  151. data/gui/tinkerbackwindows/superant.com.words/z9end.rwd +6 -0
  152. data/gui/zzcoreguiend/yy9rwdend.rwd +4 -0
  153. data/init.rb +277 -0
  154. data/installed/rwdweliza-0.03.inf +24 -0
  155. data/installed/temp.rb +1 -0
  156. data/lang/en/rwdcore/languagefile.rb +58 -0
  157. data/lang/es/rwdcore/languagefile-es.rb +62 -0
  158. data/lang/fr/rwdcore/languagefile.rb +64 -0
  159. data/lang/jp/rwdcore/languagefile.rb +72 -0
  160. data/lang/nl/rwdcore/languagefile.rb +75 -0
  161. data/lib/dict.rb +438 -0
  162. data/lib/druida.rb +499 -0
  163. data/lib/hashslice.rb +71 -0
  164. data/lib/linguistics.rb +360 -0
  165. data/lib/linguistics/en.rb +1601 -0
  166. data/lib/linguistics/en/infinitive.rb +1148 -0
  167. data/lib/linguistics/en/linkparser.rb +142 -0
  168. data/lib/linguistics/en/wordnet.rb +253 -0
  169. data/lib/linguistics/iso639.rb +456 -0
  170. data/lib/linkparser.rb +461 -0
  171. data/lib/linkparser/connection.rb +81 -0
  172. data/lib/linkparser/connector.rb +201 -0
  173. data/lib/linkparser/definition.rb +225 -0
  174. data/lib/linkparser/dictionary.rb +208 -0
  175. data/lib/linkparser/linkage.rb +185 -0
  176. data/lib/linkparser/log.rb +39 -0
  177. data/lib/linkparser/sentence.rb +79 -0
  178. data/lib/linkparser/utils.rb +540 -0
  179. data/lib/linkparser/word.rb +92 -0
  180. data/lib/rconftool.rb +380 -0
  181. data/lib/rwd/browser.rb +123 -0
  182. data/lib/rwd/ftools.rb +174 -0
  183. data/lib/rwd/mime.rb +328 -0
  184. data/lib/rwd/net.rb +866 -0
  185. data/lib/rwd/ruby.rb +889 -0
  186. data/lib/rwd/rwd.rb +1942 -0
  187. data/lib/rwd/sgml.rb +236 -0
  188. data/lib/rwd/thread.rb +63 -0
  189. data/lib/rwd/tree.rb +371 -0
  190. data/lib/rwd/xml.rb +101 -0
  191. data/lib/zip/ioextras.rb +114 -0
  192. data/lib/zip/stdrubyext.rb +111 -0
  193. data/lib/zip/tempfile_bugfixed.rb +195 -0
  194. data/lib/zip/zip.rb +1378 -0
  195. data/lib/zip/zipfilesystem.rb +558 -0
  196. data/lib/zip/ziprequire.rb +61 -0
  197. data/rwd_files/HowTo_Eliza.txt +195 -0
  198. data/rwd_files/HowTo_Tinker.txt +471 -0
  199. data/rwd_files/HowTo_TinkerWin2.txt +202 -0
  200. data/rwd_files/Readme.txt +57 -0
  201. data/rwd_files/RubyWebDialogs.html +6 -0
  202. data/rwd_files/favicon.ico +0 -0
  203. data/rwd_files/rdoc-style.css +175 -0
  204. data/rwd_files/rwdapplications.html +54 -0
  205. data/rwd_files/tinker.png +0 -0
  206. data/rwdconfig.dist +21 -0
  207. data/rwdeliza.rb +1 -0
  208. data/tests/RubyGauge.rb +179 -0
  209. data/tests/checkdepends.sh +4 -0
  210. data/tests/cleancnf.sh +6 -0
  211. data/tests/makedist-rwdweliza.rb +56 -0
  212. data/tests/makedist.rb +66 -0
  213. data/tests/rdep.rb +354 -0
  214. data/tests/totranslate.lang +93 -0
  215. data/zips/rwdwaddresses-1.05.zip +0 -0
  216. data/zips/rwdwcalc-0.61.zip +0 -0
  217. data/zips/rwdwgutenberg-0.09.zip +0 -0
  218. data/zips/rwdwschedule-1.04.zip +0 -0
  219. data/zips/rwdwshell-1.04.zip +0 -0
  220. data/zips/temp.rb +1 -0
  221. data/zips/wrubyslippers-1.06.zip +0 -0
  222. metadata +282 -0
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # This file contains the extensions to the Linguistics::EN module which provide
4
+ # support for the Ruby LinkParser module. LinkParser enables grammatic queries
5
+ # of English language sentences.
6
+ #
7
+ # == Synopsis
8
+ #
9
+ # # Test to see whether or not the link parser is loaded.
10
+ # Linguistics::EN.has_link_parser?
11
+ # # => true
12
+ #
13
+ # # Diagram the first linkage for a test sentence
14
+ # puts "he is a big dog".sentence.linkages.first.to_s
15
+ # +---O*---+
16
+ # | +--Ds--+
17
+ # +Ss+ | +-A-+
18
+ # | | | | |
19
+ # he is a big dog
20
+ #
21
+ # # Find the verb in the sentence
22
+ # "he is a big dog".en.sentence.verb.to_s
23
+ # # => "is"
24
+ #
25
+ # # Combined infinitive + LinkParser: Find the infinitive form of the verb of the
26
+ # given sentence.
27
+ # "he is a big dog".en.sentence.verb.infinitive
28
+ # # => "be"
29
+ #
30
+ # # Find the direct object of the sentence
31
+ # "he is a big dog".en.sentence.object.to_s
32
+ # # => "dog"
33
+ #
34
+ # # Look at the raw LinkParser::Word for the direct object of the sentence.
35
+ # "he is a big dog".en.sentence.object
36
+ # # => #<LinkParser::Word:0x403da0a0 @definition=[[{@A-}, Ds-, {@M+}, J-], [{@A-},
37
+ # Ds-, {@M+}, Os-], [{@A-}, Ds-, {@M+}, Ss+, {@CO-}, {C-}], [{@A-}, Ds-, {@M+},
38
+ # Ss+, R-], [{@A-}, Ds-, {@M+}, SIs-], [{@A-}, Ds-, {R+}, {Bs+}, J-], [{@A-}, Ds-,
39
+ # {R+}, {Bs+}, Os-], [{@A-}, Ds-, {R+}, {Bs+}, Ss+, {@CO-}, {C-}], [{@A-}, Ds-,
40
+ # {R+}, {Bs+}, Ss+, R-], [{@A-}, Ds-, {R+}, {Bs+}, SIs-]], @right=[], @suffix="",
41
+ # @left=[#<LinkParser::Connection:0x403da028 @rword=#<LinkParser::Word:0x403da0a0
42
+ # ...>, @lword=#<LinkParser::Word:0x403da0b4 @definition=[[Ss-, O+, {@MV+}], [Ss-,
43
+ # B-, {@MV+}], [Ss-, P+], [Ss-, AF-], [RS-, Bs-, O+, {@MV+}], [RS-, Bs-, B-,
44
+ # {@MV+}], [RS-, Bs-, P+], [RS-, Bs-, AF-], [{Q-}, SIs+, O+, {@MV+}], [{Q-}, SIs+,
45
+ # B-, {@MV+}], [{Q-}, SIs+, P+], [{Q-}, SIs+, AF-]],
46
+ # @right=[#<LinkParser::Connection:0x403da028 ...>], @suffix="", @left=[],
47
+ # @name="is", @position=1>, @subName="*", @name="O", @length=3>], @name="dog",
48
+ # @position=4>
49
+ #
50
+ # # Combine WordNet + LinkParser to find the definition of the direct object of
51
+ # # the sentence
52
+ # "he is a big dog".en.sentence.object.gloss
53
+ # # => "a member of the genus Canis (probably descended from the common wolf) that
54
+ # has been domesticated by man since prehistoric times; occurs in many breeds;
55
+ # \"the dog barked all night\""
56
+ #
57
+ # == Authors
58
+ #
59
+ # * Martin Chase <stillflame@FaerieMUD.org>
60
+ # * Michael Granger <ged@FaerieMUD.org>
61
+ #
62
+ # == Copyright
63
+ #
64
+ # Copyright (c) 2003 The FaerieMUD Consortium. All rights reserved.
65
+ #
66
+ # This module is free software. You may use, modify, and/or redistribute this
67
+ # software under the terms of the Perl Artistic License. (See
68
+ # http://language.perl.com/misc/Artistic.html)
69
+ #
70
+ # # == Version
71
+ #
72
+ # $Id: linkparser.rb,v 1.4 2003/09/14 11:15:33 deveiant Exp $
73
+ #
74
+
75
+ require 'linguistics/en'
76
+
77
+ module Linguistics::EN
78
+
79
+ @hasLinkParser = true
80
+ @lpParser = nil
81
+ @lpError = nil
82
+
83
+ begin
84
+ require "linkparser"
85
+ @hasLinkParser = true
86
+ rescue LoadError => err
87
+ @lpError = err
88
+ end
89
+
90
+
91
+ #################################################################
92
+ ### M O D U L E M E T H O D S
93
+ #################################################################
94
+ class << self
95
+
96
+ ### Returns +true+ if LinkParser was loaded okay
97
+ def hasLinkParser? ; @hasLinkParser ; end
98
+
99
+ ### If #hasLinkParser? returns +false+, this can be called to fetch the
100
+ ### exception which was raised when trying to load LinkParser.
101
+ def lpError ; @lpError ; end
102
+
103
+ ### The instance of LinkParser used for all Linguistics LinkParser
104
+ ### functions.
105
+ def linkParser
106
+ if @lpError
107
+ raise NotImplementedError,
108
+ "LinkParser functions are not loaded: %s" %
109
+ @lpError.message
110
+ end
111
+
112
+ return @lpParser if ! @lpParser.nil?
113
+
114
+ LinkParser::Word::extend( Linguistics )
115
+ Linguistics::installDelegatorProxy( LinkParser::Word, :en )
116
+
117
+ dictOpts = Hash.new('')
118
+ dictOpts['datadir'] = 'ElizaData'
119
+ dictOpts['dict'] = 'tiny.dict'
120
+ parseOpts = Hash.new
121
+
122
+ @lpParser = LinkParser.new( dictOpts, parseOpts )
123
+ end
124
+ end
125
+
126
+
127
+ #################################################################
128
+ ### L I N K P A R S E R I N T E R F A C E
129
+ #################################################################
130
+
131
+ ###############
132
+ module_function
133
+ ###############
134
+
135
+ ### Return a LinkParser::Sentence, with or without a sentence in it.
136
+ def linkParse( sent )
137
+ return Linguistics::EN::linkParser.parse( sent.to_s )
138
+ end
139
+ alias_method :sentence, :linkParse
140
+ module_function :sentence
141
+
142
+ end
@@ -0,0 +1,253 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # This file contains functions for finding relations for English words. It
4
+ # requires the Ruby-WordNet module to be installed; if it is not installed,
5
+ # calling the functions defined by this file will raise NotImplemented
6
+ # exceptions if called. Requiring this file adds functions and constants to the
7
+ # Linguistics::EN module.
8
+ #
9
+ # == Synopsis
10
+ #
11
+ # # Test to be sure the WordNet module loaded okay.
12
+ # Linguistics::EN.has_wordnet?
13
+ # # => true
14
+ #
15
+ # # Fetch the default synset for the word "balance"
16
+ # "balance".synset
17
+ # # => #<WordNet::Synset:0x40376844 balance (noun): "a state of equilibrium"
18
+ # (derivations: 3, antonyms: 1, hypernyms: 1, hyponyms: 3)>
19
+ #
20
+ # # Fetch the synset for the first verb sense of "balance"
21
+ # "balance".en.synset( :verb )
22
+ # # => #<WordNet::Synset:0x4033f448 balance, equilibrate, equilibrize, equilibrise
23
+ # (verb): "bring into balance or equilibrium; "She has to balance work and her
24
+ # domestic duties"; "balance the two weights"" (derivations: 7, antonyms: 1,
25
+ # verbGroups: 2, hypernyms: 1, hyponyms: 5)>
26
+ #
27
+ # # Fetch the second noun sense
28
+ # "balance".en.synset( 2, :noun )
29
+ # # => #<WordNet::Synset:0x404ebb24 balance (noun): "a scale for weighing; depends
30
+ # on pull of gravity" (hypernyms: 1, hyponyms: 5)>
31
+ #
32
+ # # Fetch the second noun sense's hypernyms (more-general words, like a superclass)
33
+ # "balance".en.synset( 2, :noun ).hypernyms
34
+ # # => [#<WordNet::Synset:0x404e5620 scale, weighing machine (noun): "a measuring
35
+ # instrument for weighing; shows amount of mass" (derivations: 2, hypernyms: 1,
36
+ # hyponyms: 2)>]
37
+ #
38
+ # # A simpler way of doing the same thing:
39
+ # "balance".en.hypernyms( 2, :noun )
40
+ # # => [#<WordNet::Synset:0x404e5620 scale, weighing machine (noun): "a measuring
41
+ # instrument for weighing; shows amount of mass" (derivations: 2, hypernyms: 1,
42
+ # hyponyms: 2)>]
43
+ #
44
+ # # Fetch the first hypernym's hypernyms
45
+ # "balance".en.synset( 2, :noun ).hypernyms.first.hypernyms
46
+ # # => [#<WordNet::Synset:0x404c60b8 measuring instrument, measuring system,
47
+ # measuring device (noun): "instrument that shows the extent or amount or quantity
48
+ # or degree of something" (hypernyms: 1, hyponyms: 83)>]
49
+ #
50
+ # # Find the synset to which both the second noun sense of "balance" and the
51
+ # # default sense of "shovel" belong.
52
+ # ("balance".en.synset( 2, :noun ) | "shovel".en.synset)
53
+ # # => #<WordNet::Synset:0x40473da4 instrumentality, instrumentation (noun): "an
54
+ # artifact (or system of artifacts) that is instrumental in accomplishing some
55
+ # end" (derivations: 1, hypernyms: 1, hyponyms: 13)>
56
+ #
57
+ # # Fetch just the words for the other kinds of "instruments"
58
+ # "instrument".en.hyponyms.collect {|synset| synset.words}.flatten
59
+ # # => ["analyzer", "analyser", "cautery", "cauterant", "drafting instrument",
60
+ # "extractor", "instrument of execution", "instrument of punishment", "measuring
61
+ # instrument", "measuring system", "measuring device", "medical instrument",
62
+ # "navigational instrument", "optical instrument", "plotter", "scientific
63
+ # instrument", "sonograph", "surveying instrument", "surveyor's instrument",
64
+ # "tracer", "weapon", "arm", "weapon system", "whip"]
65
+ #
66
+ #
67
+ # == Authors
68
+ #
69
+ # * Michael Granger <ged@FaerieMUD.org>
70
+ #
71
+ # == Copyright
72
+ #
73
+ # Copyright (c) 2003 The FaerieMUD Consortium. All rights reserved.
74
+ #
75
+ # This module is free software. You may use, modify, and/or redistribute this
76
+ # software under the terms of the Perl Artistic License. (See
77
+ # http://language.perl.com/misc/Artistic.html)
78
+ #
79
+ # == Version
80
+ #
81
+ # $Id: wordnet.rb,v 1.3 2003/09/14 11:28:02 deveiant Exp $
82
+ #
83
+
84
+ module Linguistics
85
+ module EN
86
+
87
+ @hasWordnet = false
88
+ @wnError = nil
89
+ @wnLexicon = nil
90
+
91
+ # Load WordNet and open the lexicon if possible, saving the error that
92
+ # occurs if anything goes wrong.
93
+ begin
94
+ require 'wordnet'
95
+ @hasWordnet = true
96
+ rescue LoadError => err
97
+ @wnError = err
98
+ end
99
+
100
+
101
+ #################################################################
102
+ ### M O D U L E M E T H O D S
103
+ #################################################################
104
+ class << self
105
+
106
+ ### Returns +true+ if WordNet was loaded okay
107
+ def hasWordnet? ; @hasWordnet; end
108
+
109
+ ### If #haveWordnet? returns +false+, this can be called to fetch the
110
+ ### exception which was raised when WordNet was loaded.
111
+ def wnError ; @wnError; end
112
+
113
+ ### The instance of the WordNet::Lexicon used for all Linguistics WordNet
114
+ ### functions.
115
+ def wnLexicon
116
+ if @wnError
117
+ raise NotImplementedError,
118
+ "WordNet functions are not loaded: %s" %
119
+ @wnError.message
120
+ end
121
+
122
+ @wnLexicon ||= WordNet::Lexicon::new
123
+ end
124
+
125
+ ### Make a function that calls the method +meth+ on the synset of an input
126
+ ### word.
127
+ def def_synset_function( meth )
128
+ (class << self; self; end).instance_eval do
129
+ define_method( meth ) {|*args|
130
+ word, pos, sense = *args
131
+ raise ArgumentError,
132
+ "wrong number of arguments (0 for 1)" unless word
133
+ sense ||= 1
134
+
135
+ syn = synset( word.to_s, pos, sense )
136
+ return syn.nil? ? nil : syn.send( meth )
137
+ }
138
+ end
139
+ end
140
+ end
141
+
142
+
143
+
144
+ #################################################################
145
+ ### W O R D N E T I N T E R F A C E
146
+ #################################################################
147
+
148
+ ###############
149
+ module_function
150
+ ###############
151
+
152
+ ### Look up the synset associated with the given word or collocation in the
153
+ ### WordNet lexicon and return a WordNet::Synset object.
154
+ def synset( word, pos=nil, sense=1 )
155
+ lex = Linguistics::EN::wnLexicon
156
+ if pos.is_a?( Fixnum)
157
+ sense = pos
158
+ pos = nil
159
+ end
160
+ postries = pos ? [pos] : [:noun, :verb, :adjective, :adverb, :other]
161
+ syn = nil
162
+
163
+ postries.each {|pos|
164
+ break if syn = lex.lookupSynsets( word.to_s, pos, sense )
165
+ }
166
+
167
+ return syn
168
+ end
169
+
170
+
171
+ ### Look up all the synsets associated with the given word or collocation in
172
+ ### the WordNet lexicon and return an Array of WordNet::Synset objects. If
173
+ ### +pos+ is +nil+, return synsets for all parts of speech.
174
+ def synsets( word, pos=nil )
175
+ lex = Linguistics::EN::wnLexicon
176
+ postries = pos ? [pos] : [:noun, :verb, :adjective, :adverb, :other]
177
+ syns = []
178
+
179
+ postries.each {|pos|
180
+ syns << lex.lookupSynsets( word.to_s, pos )
181
+ }
182
+
183
+ return syns.flatten.compact
184
+ end
185
+
186
+
187
+ # Returns definitions and/or example sentences as a String.
188
+ def_synset_function :gloss
189
+
190
+ # Returns definitions and/or example sentences as an Array.
191
+ def_synset_function :glosses
192
+
193
+ # Return nouns or verbs that have the same hypernym as the receiver.
194
+ def_synset_function :coordinates
195
+
196
+ # Returns the Array of synonyms contained in the synset for the receiver.
197
+ def_synset_function :words
198
+ def_synset_function :synonyms
199
+
200
+ # Returns the name of the lexicographer file that contains the raw data for
201
+ # the receiver.
202
+ def_synset_function :lexInfo
203
+
204
+ # :TODO: Finish these comments, and figure out how the hell to get the
205
+ # methods to show up in RDoc.
206
+ def_synset_function :frames
207
+
208
+ def_synset_function :antonyms
209
+ def_synset_function :hypernyms
210
+ def_synset_function :entailment
211
+ def_synset_function :hyponyms
212
+ def_synset_function :causes
213
+ def_synset_function :verbgroups
214
+ def_synset_function :similarTo
215
+ def_synset_function :participles
216
+ def_synset_function :pertainyms
217
+ def_synset_function :attributes
218
+ def_synset_function :derivedFrom
219
+ def_synset_function :seeAlso
220
+ def_synset_function :functions
221
+
222
+ def_synset_function :meronyms
223
+ def_synset_function :memberMeronyms
224
+ def_synset_function :stuffMeronyms
225
+ def_synset_function :portionMeronyms
226
+ def_synset_function :componentMeronyms
227
+ def_synset_function :featureMeronyms
228
+ def_synset_function :phaseMeronyms
229
+ def_synset_function :placeMeronyms
230
+
231
+ def_synset_function :holonyms
232
+ def_synset_function :memberHolonyms
233
+ def_synset_function :stuffHolonyms
234
+ def_synset_function :portionHolonyms
235
+ def_synset_function :componentHolonyms
236
+ def_synset_function :featureHolonyms
237
+ def_synset_function :phaseHolonyms
238
+ def_synset_function :placeHolonyms
239
+
240
+ def_synset_function :domains
241
+ def_synset_function :categoryDomains
242
+ def_synset_function :regionDomains
243
+ def_synset_function :usageDomains
244
+
245
+ def_synset_function :members
246
+ def_synset_function :categoryMembers
247
+ def_synset_function :regionMembers
248
+ def_synset_function :usageMembers
249
+
250
+
251
+ end # module EN
252
+ end # module Linguistics
253
+
@@ -0,0 +1,456 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # linguistics/iso639.rb - A hash of International 2- and 3-letter
4
+ # ISO639-1 and ISO639-2 language codes. Each entry has two keys:
5
+ #
6
+ # [<tt>:codes</tt>]
7
+ # All of the codes known for this language
8
+ # [<tt>:desc</tt>]
9
+ # The English-language description of the language.
10
+ #
11
+
12
+ ### A language-independent framework for adding linguistics functions to Ruby
13
+ ### classes.
14
+ module Linguistics
15
+
16
+ # Hash of ISO639 2- and 3-letter language codes
17
+ LanguageCodes = {}
18
+
19
+ # Read through the source for this file, capturing everything
20
+ # between __END__ and __END_DATA__ tokens.
21
+ inDataSection = false
22
+ File::readlines( __FILE__ ).each {|line|
23
+ case line
24
+ when /^__END_DATA__$/
25
+ inDataSection = false
26
+ false
27
+
28
+ when /^__END__$/
29
+ inDataSection = true
30
+ false
31
+
32
+ else
33
+ if inDataSection
34
+ codes, desc = line[0,15].split(%r{/|\s+}), line[15...-1]
35
+ codes.delete_if {|code| code.empty?}
36
+ entry = {
37
+ :desc => desc.strip,
38
+ :codes => codes.dup,
39
+ }
40
+ codes.each {|code|
41
+ raise "Duplicate language code #{code}:"\
42
+ "(#{LanguageCodes[code][:desc]}})}" \
43
+ if LanguageCodes.key?( code )
44
+ LanguageCodes[ code.strip ] = entry
45
+ }
46
+ end
47
+ end
48
+ }
49
+ end
50
+
51
+ __END__
52
+ abk ab Abkhazian
53
+ ace Achinese
54
+ ach Acoli
55
+ ada Adangme
56
+ aar aa Afar
57
+ afh Afrihili
58
+ afr af Afrikaans
59
+ afa Afro-Asiatic (Other)
60
+ aka Akan
61
+ akk Akkadian
62
+ alb/sqi sq Albanian
63
+ ale Aleut
64
+ alg Algonquian languages
65
+ tut Altaic (Other)
66
+ amh am Amharic
67
+ apa Apache languages
68
+ ara ar Arabic
69
+ arc Aramaic
70
+ arp Arapaho
71
+ arn Araucanian
72
+ arw Arawak
73
+ arm/hye hy Armenian
74
+ art Artificial (Other)
75
+ asm as Assamese
76
+ ath Athapascan languages
77
+ map Austronesian (Other)
78
+ ava Avaric
79
+ ave Avestan
80
+ awa Awadhi
81
+ aym ay Aymara
82
+ aze az Azerbaijani
83
+ nah Aztec
84
+ ban Balinese
85
+ bat Baltic (Other)
86
+ bal Baluchi
87
+ bam Bambara
88
+ bai Bamileke languages
89
+ bad Banda
90
+ bnt Bantu (Other)
91
+ bas Basa
92
+ bak ba Bashkir
93
+ baq/eus eu Basque
94
+ bej Beja
95
+ bem Bemba
96
+ ben bn Bengali
97
+ ber Berber (Other)
98
+ bho Bhojpuri
99
+ bih bh Bihari
100
+ bik Bikol
101
+ bin Bini
102
+ bis bi Bislama
103
+ bra Braj
104
+ bre br Breton
105
+ bug Buginese
106
+ bul bg Bulgarian
107
+ bua Buriat
108
+ bur/mya my Burmese
109
+ bel be Byelorussian
110
+ cad Caddo
111
+ car Carib
112
+ cat ca Catalan
113
+ cau Caucasian (Other)
114
+ ceb Cebuano
115
+ cel Celtic (Other)
116
+ cai Central American Indian (Other)
117
+ chg Chagatai
118
+ cha Chamorro
119
+ che Chechen
120
+ chr Cherokee
121
+ chy Cheyenne
122
+ chb Chibcha
123
+ chi/zho zh Chinese
124
+ chn Chinook jargon
125
+ cho Choctaw
126
+ chu Church Slavic
127
+ chv Chuvash
128
+ cop Coptic
129
+ cor Cornish
130
+ cos co Corsican
131
+ cre Cree
132
+ mus Creek
133
+ crp Creoles and Pidgins (Other)
134
+ cpe Creoles and Pidgins, English-based (Other)
135
+ cpf Creoles and Pidgins, French-based (Other)
136
+ cpp Creoles and Pidgins, Portuguese-based (Other)
137
+ cus Cushitic (Other)
138
+ hr Croatian
139
+ ces/cze cs Czech
140
+ dak Dakota
141
+ dan da Danish
142
+ del Delaware
143
+ din Dinka
144
+ div Divehi
145
+ doi Dogri
146
+ dra Dravidian (Other)
147
+ dua Duala
148
+ dut/nla nl Dutch
149
+ dum Dutch, Middle (ca. 1050-1350)
150
+ dyu Dyula
151
+ dzo dz Dzongkha
152
+ efi Efik
153
+ egy Egyptian (Ancient)
154
+ eka Ekajuk
155
+ elx Elamite
156
+ eng en English
157
+ enm English, Middle (ca. 1100-1500)
158
+ ang English, Old (ca. 450-1100)
159
+ esk Eskimo (Other)
160
+ epo eo Esperanto
161
+ est et Estonian
162
+ ewe Ewe
163
+ ewo Ewondo
164
+ fan Fang
165
+ fat Fanti
166
+ fao fo Faroese
167
+ fij fj Fijian
168
+ fin fi Finnish
169
+ fiu Finno-Ugrian (Other)
170
+ fon Fon
171
+ fra/fre fr French
172
+ frm French, Middle (ca. 1400-1600)
173
+ fro French, Old (842- ca. 1400)
174
+ fry fy Frisian
175
+ ful Fulah
176
+ gaa Ga
177
+ gae/gdh Gaelic (Scots)
178
+ glg gl Gallegan
179
+ lug Ganda
180
+ gay Gayo
181
+ gez Geez
182
+ geo/kat ka Georgian
183
+ deu/ger de German
184
+ gmh German, Middle High (ca. 1050-1500)
185
+ goh German, Old High (ca. 750-1050)
186
+ gem Germanic (Other)
187
+ gil Gilbertese
188
+ gon Gondi
189
+ got Gothic
190
+ grb Grebo
191
+ grc Greek, Ancient (to 1453)
192
+ ell/gre el Greek, Modern (1453-)
193
+ kal kl Greenlandic
194
+ grn gn Guarani
195
+ guj gu Gujarati
196
+ hai Haida
197
+ hau ha Hausa
198
+ haw Hawaiian
199
+ heb he Hebrew
200
+ her Herero
201
+ hil Hiligaynon
202
+ him Himachali
203
+ hin hi Hindi
204
+ hmo Hiri Motu
205
+ hun hu Hungarian
206
+ hup Hupa
207
+ iba Iban
208
+ ice/isl is Icelandic
209
+ ibo Igbo
210
+ ijo Ijo
211
+ ilo Iloko
212
+ inc Indic (Other)
213
+ ine Indo-European (Other)
214
+ ind id Indonesian
215
+ ina ia Interlingua (International Auxiliary language Association)
216
+ ile Interlingue
217
+ iku iu Inuktitut
218
+ ipk ik Inupiak
219
+ ira Iranian (Other)
220
+ gai/iri ga Irish
221
+ sga Irish, Old (to 900)
222
+ mga Irish, Middle (900 - 1200)
223
+ iro Iroquoian languages
224
+ ita it Italian
225
+ jpn ja Japanese
226
+ jav/jaw jv/jw Javanese
227
+ jrb Judeo-Arabic
228
+ jpr Judeo-Persian
229
+ kab Kabyle
230
+ kac Kachin
231
+ kam Kamba
232
+ kan kn Kannada
233
+ kau Kanuri
234
+ kaa Kara-Kalpak
235
+ kar Karen
236
+ kas ks Kashmiri
237
+ kaw Kawi
238
+ kaz kk Kazakh
239
+ kha Khasi
240
+ khm km Khmer
241
+ khi Khoisan (Other)
242
+ kho Khotanese
243
+ kik Kikuyu
244
+ kin rw Kinyarwanda
245
+ kir ky Kirghiz
246
+ kom Komi
247
+ kon Kongo
248
+ kok Konkani
249
+ kor ko Korean
250
+ kpe Kpelle
251
+ kro Kru
252
+ kua Kuanyama
253
+ kum Kumyk
254
+ kur ku Kurdish
255
+ kru Kurukh
256
+ kus Kusaie
257
+ kut Kutenai
258
+ lad Ladino
259
+ lah Lahnda
260
+ lam Lamba
261
+ oci oc Langue d'Oc (post 1500)
262
+ lao lo Lao
263
+ lat la Latin
264
+ lav lv Latvian
265
+ ltz Letzeburgesch
266
+ lez Lezghian
267
+ lin ln Lingala
268
+ lit lt Lithuanian
269
+ loz Lozi
270
+ lub Luba-Katanga
271
+ lui Luiseno
272
+ lun Lunda
273
+ luo Luo (Kenya and Tanzania)
274
+ mac/mke mk Macedonian
275
+ mad Madurese
276
+ mag Magahi
277
+ mai Maithili
278
+ mak Makasar
279
+ mlg mg Malagasy
280
+ may/msa ms Malay
281
+ mal Malayalam
282
+ mlt ml Maltese
283
+ man Mandingo
284
+ mni Manipuri
285
+ mno Manobo languages
286
+ max Manx
287
+ mao/mri mi Maori
288
+ mar mr Marathi
289
+ chm Mari
290
+ mah Marshall
291
+ mwr Marwari
292
+ mas Masai
293
+ myn Mayan languages
294
+ men Mende
295
+ mic Micmac
296
+ min Minangkabau
297
+ mis Miscellaneous (Other)
298
+ moh Mohawk
299
+ mol mo Moldavian
300
+ mkh Mon-Kmer (Other)
301
+ lol Mongo
302
+ mon mn Mongolian
303
+ mos Mossi
304
+ mul Multiple languages
305
+ mun Munda languages
306
+ nau na Nauru
307
+ nav Navajo
308
+ nde Ndebele, North
309
+ nbl Ndebele, South
310
+ ndo Ndongo
311
+ nep ne Nepali
312
+ new Newari
313
+ nic Niger-Kordofanian (Other)
314
+ ssa Nilo-Saharan (Other)
315
+ niu Niuean
316
+ non Norse, Old
317
+ nai North American Indian (Other)
318
+ nor no Norwegian
319
+ nno Norwegian (Nynorsk)
320
+ nub Nubian languages
321
+ nym Nyamwezi
322
+ nya Nyanja
323
+ nyn Nyankole
324
+ nyo Nyoro
325
+ nzi Nzima
326
+ oji Ojibwa
327
+ ori or Oriya
328
+ orm om Oromo
329
+ osa Osage
330
+ oss Ossetic
331
+ oto Otomian languages
332
+ pal Pahlavi
333
+ pau Palauan
334
+ pli Pali
335
+ pam Pampanga
336
+ pag Pangasinan
337
+ pan pa Panjabi
338
+ pap Papiamento
339
+ paa Papuan-Australian (Other)
340
+ fas/per fa Persian
341
+ peo Persian, Old (ca 600 - 400 B.C.)
342
+ phn Phoenician
343
+ pol pl Polish
344
+ pon Ponape
345
+ por pt Portuguese
346
+ pra Prakrit languages
347
+ pro Provencal, Old (to 1500)
348
+ pus ps Pushto
349
+ que qu Quechua
350
+ roh rm Rhaeto-Romance
351
+ raj Rajasthani
352
+ rar Rarotongan
353
+ roa Romance (Other)
354
+ ron/rum ro Romanian
355
+ rom Romany
356
+ run rn Rundi
357
+ rus ru Russian
358
+ sal Salishan languages
359
+ sam Samaritan Aramaic
360
+ smi Sami languages
361
+ smo sm Samoan
362
+ sad Sandawe
363
+ sag sg Sango
364
+ san sa Sanskrit
365
+ srd Sardinian
366
+ sco Scots
367
+ sel Selkup
368
+ sem Semitic (Other)
369
+ sr Serbian
370
+ scr sh Serbo-Croatian
371
+ srr Serer
372
+ shn Shan
373
+ sna sn Shona
374
+ sid Sidamo
375
+ bla Siksika
376
+ snd sd Sindhi
377
+ sin si Singhalese
378
+ sit Sino-Tibetan (Other)
379
+ sio Siouan languages
380
+ sla Slavic (Other)
381
+ ss Siswati
382
+ slk/slo sk Slovak
383
+ slv sl Slovenian
384
+ sog Sogdian
385
+ som so Somali
386
+ son Songhai
387
+ wen Sorbian languages
388
+ nso Sotho, Northern
389
+ sot st Sotho, Southern
390
+ sai South American Indian (Other)
391
+ esl/spa es Spanish
392
+ suk Sukuma
393
+ sux Sumerian
394
+ sun su Sudanese
395
+ sus Susu
396
+ swa sw Swahili
397
+ ssw Swazi
398
+ sve/swe sv Swedish
399
+ syr Syriac
400
+ tgl tl Tagalog
401
+ tah Tahitian
402
+ tgk tg Tajik
403
+ tmh Tamashek
404
+ tam ta Tamil
405
+ tat tt Tatar
406
+ tel te Telugu
407
+ ter Tereno
408
+ tha th Thai
409
+ bod/tib bo Tibetan
410
+ tig Tigre
411
+ tir ti Tigrinya
412
+ tem Timne
413
+ tiv Tivi
414
+ tli Tlingit
415
+ tog to Tonga (Nyasa)
416
+ ton Tonga (Tonga Islands)
417
+ tru Truk
418
+ tsi Tsimshian
419
+ tso ts Tsonga
420
+ tsn tn Tswana
421
+ tum Tumbuka
422
+ tur tr Turkish
423
+ ota Turkish, Ottoman (1500 - 1928)
424
+ tuk tk Turkmen
425
+ tyv Tuvinian
426
+ twi tw Twi
427
+ uga Ugaritic
428
+ uig ug Uighur
429
+ ukr uk Ukrainian
430
+ umb Umbundu
431
+ und Undetermined
432
+ urd ur Urdu
433
+ uzb uz Uzbek
434
+ vai Vai
435
+ ven Venda
436
+ vie vi Vietnamese
437
+ vol vo Volap�k
438
+ vot Votic
439
+ wak Wakashan languages
440
+ wal Walamo
441
+ war Waray
442
+ was Washo
443
+ cym/wel cy Welsh
444
+ wol wo Wolof
445
+ xho xh Xhosa
446
+ sah Yakut
447
+ yao Yao
448
+ yap Yap
449
+ yid yi Yiddish
450
+ yor yo Yoruba
451
+ zap Zapotec
452
+ zen Zenaga
453
+ zha za Zhuang
454
+ zul zu Zulu
455
+ zun Zuni
456
+ __END_DATA__