markos_linguistics 1.0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +640 -0
- data/LICENSE +27 -0
- data/README +166 -0
- data/README.english +245 -0
- data/Rakefile +338 -0
- data/examples/generalize_sentence.rb +46 -0
- data/lib/linguistics.rb +366 -0
- data/lib/linguistics/en.rb +1728 -0
- data/lib/linguistics/en/infinitive.rb +1145 -0
- data/lib/linguistics/en/linkparser.rb +109 -0
- data/lib/linguistics/en/wordnet.rb +257 -0
- data/lib/linguistics/iso639.rb +461 -0
- data/rake/191_compat.rb +26 -0
- data/rake/dependencies.rb +76 -0
- data/rake/helpers.rb +434 -0
- data/rake/hg.rb +261 -0
- data/rake/manual.rb +782 -0
- data/rake/packaging.rb +144 -0
- data/rake/publishing.rb +318 -0
- data/rake/rdoc.rb +30 -0
- data/rake/style.rb +62 -0
- data/rake/svn.rb +668 -0
- data/rake/testing.rb +187 -0
- data/rake/verifytask.rb +64 -0
- data/rake/win32.rb +190 -0
- data/spec/linguistics/en_spec.rb +215 -0
- data/spec/linguistics/iso639_spec.rb +72 -0
- data/spec/linguistics_spec.rb +107 -0
- data/tests/en/infinitive.tests.rb +207 -0
- data/tests/en/inflect.tests.rb +1389 -0
- data/tests/en/lafcadio.tests.rb +77 -0
- data/tests/en/linkparser.tests.rb +42 -0
- data/tests/en/lprintf.tests.rb +77 -0
- data/tests/en/titlecase.tests.rb +73 -0
- data/tests/en/wordnet.tests.rb +95 -0
- metadata +121 -0
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
#
|
3
|
+
# Unit test for additions donated by Francis Hwang, author of Lafcadio
|
4
|
+
# $Id$
|
5
|
+
#
|
6
|
+
# Converted from ts_english.rb.
|
7
|
+
#
|
8
|
+
|
9
|
+
unless defined? Linguistics::TestCase
|
10
|
+
testsdir = File::dirname( File::dirname(File::expand_path( __FILE__ )) )
|
11
|
+
$LOAD_PATH.unshift testsdir unless $LOAD_PATH.include?( testsdir )
|
12
|
+
|
13
|
+
require 'lingtestcase'
|
14
|
+
end
|
15
|
+
|
16
|
+
### This test case tests ...
|
17
|
+
class LafcadioAdditionsTestCase < Linguistics::TestCase
|
18
|
+
|
19
|
+
Linguistics::use( :en )
|
20
|
+
include Linguistics::EN
|
21
|
+
|
22
|
+
CamelCaseStrings = [
|
23
|
+
["productCategory", "product category"],
|
24
|
+
["ProductCategory", "product category"],
|
25
|
+
["catalogOrder", "catalog order"],
|
26
|
+
["product", "product"],
|
27
|
+
["theNameOfAMethod", "the name of a method"],
|
28
|
+
]
|
29
|
+
|
30
|
+
ProperNouns = {
|
31
|
+
"albania" => "Albania",
|
32
|
+
"bosnia and herzegovina" => "Bosnia and Herzegovina",
|
33
|
+
"faroe islands" => "Faroe Islands",
|
34
|
+
"macedonia, the former yugoslav republic of" =>
|
35
|
+
"Macedonia, the Former Yugoslav Republic of",
|
36
|
+
"virgin islands, u.s." => "Virgin Islands, U.S.",
|
37
|
+
}
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
#################################################################
|
42
|
+
### T E S T S
|
43
|
+
#################################################################
|
44
|
+
|
45
|
+
def test_camel_case_to_english_should_transform_to_english
|
46
|
+
printTestHeader "Lafcadio Additions: CamelCase to English"
|
47
|
+
res = nil
|
48
|
+
|
49
|
+
CamelCaseStrings.each do |src, dst|
|
50
|
+
assert_nothing_raised { res = src.en.camel_case_to_english }
|
51
|
+
assert_equal dst, res
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
### This already worked before the additions, but might as well test 'em
|
56
|
+
### some more.
|
57
|
+
def test_plural
|
58
|
+
assert_equal "product categories", "product category".en.plural
|
59
|
+
assert_equal "products", "product".en.plural
|
60
|
+
assert_equal 'addresses', 'address'.en.plural
|
61
|
+
assert_equal 'taxes', 'tax'.en.plural
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
### String#proper_noun
|
66
|
+
def test_proper_noun_should_return_caseified_string
|
67
|
+
printTestHeader "Lafcadio Additions: Proper Nouns"
|
68
|
+
|
69
|
+
ProperNouns.each do |key,expected|
|
70
|
+
input = key.dup # Get around hash keys being frozen
|
71
|
+
debug_msg "Trying %p, expect: %p" % [input, expected]
|
72
|
+
assert_equal expected, input.en.proper_noun
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
#
|
3
|
+
# Unit test for English link grammar
|
4
|
+
# $Id$
|
5
|
+
#
|
6
|
+
# Copyright (c) 2003-2005 The FaerieMUD Consortium.
|
7
|
+
#
|
8
|
+
|
9
|
+
unless defined? Linguistics::TestCase
|
10
|
+
testsdir = File::dirname( File::dirname(File::expand_path( __FILE__ )) )
|
11
|
+
$LOAD_PATH.unshift testsdir unless $LOAD_PATH.include?( testsdir )
|
12
|
+
|
13
|
+
require 'lingtestcase'
|
14
|
+
end
|
15
|
+
|
16
|
+
### This test case tests the English language link grammar extension of
|
17
|
+
### Linguistics::EN.
|
18
|
+
class LinkParserTestCase < Linguistics::TestCase
|
19
|
+
|
20
|
+
Linguistics::use(:en)
|
21
|
+
include Linguistics::EN
|
22
|
+
|
23
|
+
### Overridden to skip tests if WordNet isn't installed.
|
24
|
+
def run( result )
|
25
|
+
return super if Linguistics::EN::has_link_parser?
|
26
|
+
yield( STARTED, name )
|
27
|
+
result.add_run
|
28
|
+
yield( FINISHED, name )
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def test_sentence_should_return_a_parsed_linkparser_sentence
|
33
|
+
rval = nil
|
34
|
+
|
35
|
+
assert_nothing_raised do
|
36
|
+
rval = "He is a dog.".en.sentence
|
37
|
+
end
|
38
|
+
|
39
|
+
assert_instance_of LinkParser::Sentence, rval
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
#
|
3
|
+
# Unit test for Linguistics::EN#lprintf
|
4
|
+
# $Id$
|
5
|
+
#
|
6
|
+
# Copyright (c) 2006 The FaerieMUD Consortium.
|
7
|
+
#
|
8
|
+
|
9
|
+
unless defined?( Linguistics::TestCase )
|
10
|
+
require 'pathname'
|
11
|
+
basedir = Pathname.new( __FILE__ ).dirname.parent.parent.expand_path
|
12
|
+
|
13
|
+
libdir = basedir + "lib"
|
14
|
+
testsdir = basedir + "tests"
|
15
|
+
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
16
|
+
$LOAD_PATH.unshift( testsdir ) unless $LOAD_PATH.include?( testsdir )
|
17
|
+
|
18
|
+
require 'lingtestcase'
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'linguistics/en'
|
22
|
+
|
23
|
+
### This test case tests the lprintf method of the Linguistics English module
|
24
|
+
class Linguistics::LPrintfTestCase < Linguistics::TestCase
|
25
|
+
|
26
|
+
Items = %w{ruby moose mouse nexus}
|
27
|
+
|
28
|
+
def initialize( *args )
|
29
|
+
Linguistics::use( :en )
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_lprintf_with_conjunct_tag_should_conjunctionize_the_corresponding_argument
|
34
|
+
rval = nil
|
35
|
+
|
36
|
+
assert_nothing_raised do
|
37
|
+
rval = "I have %CONJUNCT in my pocket".en.lprintf( Items )
|
38
|
+
end
|
39
|
+
|
40
|
+
assert_equal "I have a ruby, a moose, a mouse, and a nexus in my pocket",
|
41
|
+
rval
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def test_lprintf_with_plural_tag_should_pluralize_the_corresponding_argument
|
46
|
+
rval = nil
|
47
|
+
|
48
|
+
assert_nothing_raised do
|
49
|
+
rval = "What's with all the %PL?".en.lprintf( "llama" )
|
50
|
+
end
|
51
|
+
|
52
|
+
assert_equal "What's with all the llamas?", rval
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def test_lprintf_with_indef_article_tag_should_use_an_for_umbrella
|
57
|
+
rval = nil
|
58
|
+
|
59
|
+
assert_nothing_raised do
|
60
|
+
rval = "You pick up %A.".en.lprintf( "umbrella" )
|
61
|
+
end
|
62
|
+
|
63
|
+
assert_equal "You pick up an umbrella.", rval
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def test_lprintf_with_indef_article_tag_should_use_a_for_flagon_of_mead
|
68
|
+
rval = nil
|
69
|
+
|
70
|
+
assert_nothing_raised do
|
71
|
+
rval = "You pick up %A.".en.lprintf( "flagon of mead" )
|
72
|
+
end
|
73
|
+
|
74
|
+
assert_equal "You pick up a flagon of mead.", rval
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
#
|
3
|
+
# Unit test for English language module's title case method
|
4
|
+
# $Id$
|
5
|
+
#
|
6
|
+
# Copyright (c) 2005 The FaerieMUD Consortium.
|
7
|
+
#
|
8
|
+
|
9
|
+
unless defined? Linguistics::TestCase
|
10
|
+
testsdir = File::dirname( File::dirname(File::expand_path( __FILE__ )) )
|
11
|
+
$LOAD_PATH.unshift testsdir unless $LOAD_PATH.include?( testsdir )
|
12
|
+
|
13
|
+
require 'lingtestcase'
|
14
|
+
end
|
15
|
+
|
16
|
+
### This test case tests the #titlecase method of the english-language extension
|
17
|
+
### for the Linguistics library.
|
18
|
+
class TitleCaseTestCase < Linguistics::TestCase
|
19
|
+
|
20
|
+
Linguistics::use( :en )
|
21
|
+
|
22
|
+
Titles = File::open(__FILE__).read.split("__END__").last.split("\n")
|
23
|
+
|
24
|
+
def test_nothing
|
25
|
+
debug_msg "Not tested, as the functionality it tests hasn't been released yet."
|
26
|
+
end
|
27
|
+
|
28
|
+
def dont_test_titles
|
29
|
+
printTestHeader "TitleCase: Titles"
|
30
|
+
rval = nil
|
31
|
+
|
32
|
+
debug_msg "Titles = %p" % [Titles]
|
33
|
+
|
34
|
+
Titles.each do |title|
|
35
|
+
next if !/\w/.match( title )
|
36
|
+
|
37
|
+
assert_nothing_raised do
|
38
|
+
rval = title.downcase.en.titlecase
|
39
|
+
end
|
40
|
+
|
41
|
+
assert_instance_of String, rval
|
42
|
+
assert_equal title, rval
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
__END__
|
50
|
+
A Certain Kind of Longing
|
51
|
+
A Connecticut Yankee in King Arthur's Court
|
52
|
+
A Portrait of the Artist as a Young Man
|
53
|
+
Alice in Wonderland
|
54
|
+
Catcher in the Rye
|
55
|
+
Crime and Punishment
|
56
|
+
Death of a Salesman
|
57
|
+
Dr. Jekyll and Mr. Hyde
|
58
|
+
Gone With the Wind
|
59
|
+
Gone but Not Forgotten
|
60
|
+
Gulliver's Travels
|
61
|
+
Last of the Mohicans
|
62
|
+
Lord of the Flies
|
63
|
+
Love in the Time of Cholera
|
64
|
+
Maggie, A Girl of the Streets
|
65
|
+
Notes from the Underground
|
66
|
+
Of Mice and Men
|
67
|
+
Pride and Prejudice
|
68
|
+
The Adventures of Don Quixote
|
69
|
+
The Good Earth
|
70
|
+
The Heart of Darkness
|
71
|
+
The Lord of the Rings
|
72
|
+
The Old Man and the Sea
|
73
|
+
Mrs. Frisby and the Rats of N.I.M.H.
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
#
|
3
|
+
# Unit test for Linguistics::EN WordNet functions
|
4
|
+
# $Id$
|
5
|
+
#
|
6
|
+
# Copyright (c) 2003 The FaerieMUD Consortium.
|
7
|
+
#
|
8
|
+
|
9
|
+
unless defined? Linguistics::TestCase
|
10
|
+
testsdir = File::dirname( File::dirname(File::expand_path( __FILE__ )) )
|
11
|
+
$LOAD_PATH.unshift testsdir unless $LOAD_PATH.include?( testsdir )
|
12
|
+
|
13
|
+
require 'lingtestcase'
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
### This test case tests ...
|
18
|
+
class EnglishWordnetTestCase < Linguistics::TestCase
|
19
|
+
|
20
|
+
Linguistics::use( :en, :installProxy => true )
|
21
|
+
|
22
|
+
TestObjects = [ "auto", 5, [%w{ash bin}] ]
|
23
|
+
|
24
|
+
### Overridden to skip tests if WordNet isn't installed.
|
25
|
+
def run( result )
|
26
|
+
return super if Linguistics::EN::has_wordnet?
|
27
|
+
yield( STARTED, name )
|
28
|
+
result.add_run
|
29
|
+
yield( FINISHED, name )
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
#################################################################
|
34
|
+
### T E S T S
|
35
|
+
#################################################################
|
36
|
+
|
37
|
+
### Test the wn_lexicon method of the EN module
|
38
|
+
def test_00_Lexicon
|
39
|
+
printTestHeader "English: WordNet: Lexicon"
|
40
|
+
|
41
|
+
assert_respond_to Linguistics::EN, :wn_lexicon
|
42
|
+
assert_nothing_raised {
|
43
|
+
lex = Linguistics::EN::wn_lexicon
|
44
|
+
assert_instance_of WordNet::Lexicon, lex
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
### Test synset method
|
49
|
+
def test_05_Synset
|
50
|
+
printTestHeader "English: WordNet: Synsets"
|
51
|
+
rval = nil
|
52
|
+
|
53
|
+
TestObjects.each do |obj|
|
54
|
+
assert_respond_to obj, :en
|
55
|
+
assert_respond_to obj.en, :synset
|
56
|
+
|
57
|
+
assert_nothing_raised { rval = obj.en.synset }
|
58
|
+
assert_instance_of WordNet::Synset, rval,
|
59
|
+
".en.synset for %p" % obj
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
### Test proxy method
|
64
|
+
def test_06_ProxyMethod
|
65
|
+
printTestHeader "English: WordNet: Proxy method"
|
66
|
+
rval = nil
|
67
|
+
|
68
|
+
TestObjects.each do |obj|
|
69
|
+
assert_nothing_raised { rval = obj.synset }
|
70
|
+
assert_instance_of WordNet::Synset, rval,
|
71
|
+
".synset for %p" % obj
|
72
|
+
end
|
73
|
+
|
74
|
+
self.class.addSetupBlock {
|
75
|
+
@obj = TestObjects[0]
|
76
|
+
}
|
77
|
+
self.class.addTeardownBlock {
|
78
|
+
@obj = nil
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
### Test #coordinates
|
83
|
+
def test_10_Coordinates
|
84
|
+
printTestHeader "English: WordNet: Coordinate terms"
|
85
|
+
rval = nil
|
86
|
+
|
87
|
+
assert_nothing_raised {
|
88
|
+
rval = @obj.coordinates
|
89
|
+
}
|
90
|
+
assert_instance_of Array, rval
|
91
|
+
assert_instance_of WordNet::Synset, rval.first
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: markos_linguistics
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 121
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 8
|
10
|
+
- 3
|
11
|
+
version: 1.0.8.3
|
12
|
+
platform: ruby
|
13
|
+
authors:
|
14
|
+
- Michael Granger
|
15
|
+
- Marko Iskander
|
16
|
+
autorequire:
|
17
|
+
bindir: bin
|
18
|
+
cert_chain: []
|
19
|
+
|
20
|
+
date: 2009-11-17 00:00:00 -05:00
|
21
|
+
default_executable:
|
22
|
+
dependencies: []
|
23
|
+
|
24
|
+
description: |-
|
25
|
+
in any language. It includes a generic language-independant front end, a
|
26
|
+
module for mapping language codes into language names, and a module which
|
27
|
+
contains various English-language utilities.
|
28
|
+
email:
|
29
|
+
- markoiskander@gmail.com
|
30
|
+
executables: []
|
31
|
+
|
32
|
+
extensions: []
|
33
|
+
|
34
|
+
extra_rdoc_files:
|
35
|
+
- ChangeLog
|
36
|
+
- README
|
37
|
+
- LICENSE
|
38
|
+
files:
|
39
|
+
- Rakefile
|
40
|
+
- ChangeLog
|
41
|
+
- README
|
42
|
+
- LICENSE
|
43
|
+
- spec/linguistics/en_spec.rb
|
44
|
+
- spec/linguistics/iso639_spec.rb
|
45
|
+
- spec/linguistics_spec.rb
|
46
|
+
- tests/en/infinitive.tests.rb
|
47
|
+
- tests/en/inflect.tests.rb
|
48
|
+
- tests/en/lafcadio.tests.rb
|
49
|
+
- tests/en/linkparser.tests.rb
|
50
|
+
- tests/en/lprintf.tests.rb
|
51
|
+
- tests/en/titlecase.tests.rb
|
52
|
+
- tests/en/wordnet.tests.rb
|
53
|
+
- lib/linguistics/en/infinitive.rb
|
54
|
+
- lib/linguistics/en/linkparser.rb
|
55
|
+
- lib/linguistics/en/wordnet.rb
|
56
|
+
- lib/linguistics/en.rb
|
57
|
+
- lib/linguistics/iso639.rb
|
58
|
+
- lib/linguistics.rb
|
59
|
+
- rake/191_compat.rb
|
60
|
+
- rake/dependencies.rb
|
61
|
+
- rake/helpers.rb
|
62
|
+
- rake/hg.rb
|
63
|
+
- rake/manual.rb
|
64
|
+
- rake/packaging.rb
|
65
|
+
- rake/publishing.rb
|
66
|
+
- rake/rdoc.rb
|
67
|
+
- rake/style.rb
|
68
|
+
- rake/svn.rb
|
69
|
+
- rake/testing.rb
|
70
|
+
- rake/verifytask.rb
|
71
|
+
- rake/win32.rb
|
72
|
+
- ./examples/generalize_sentence.rb
|
73
|
+
- ./README.english
|
74
|
+
has_rdoc: true
|
75
|
+
homepage: http://deveiate.org/projects/Linguistics/
|
76
|
+
licenses: []
|
77
|
+
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options:
|
80
|
+
- -w
|
81
|
+
- "4"
|
82
|
+
- -HN
|
83
|
+
- -i
|
84
|
+
- .
|
85
|
+
- -m
|
86
|
+
- README
|
87
|
+
- -t
|
88
|
+
- linguistics
|
89
|
+
- -W
|
90
|
+
- http://deveiate.org/projects/Linguistics/browser/
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
hash: 3
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
hash: 3
|
108
|
+
segments:
|
109
|
+
- 0
|
110
|
+
version: "0"
|
111
|
+
requirements: []
|
112
|
+
|
113
|
+
rubyforge_project: deveiate
|
114
|
+
rubygems_version: 1.3.7
|
115
|
+
signing_key:
|
116
|
+
specification_version: 3
|
117
|
+
summary: a framework for building linguistic utilities for Ruby objects
|
118
|
+
test_files:
|
119
|
+
- spec/linguistics/en_spec.rb
|
120
|
+
- spec/linguistics/iso639_spec.rb
|
121
|
+
- spec/linguistics_spec.rb
|