Commits

Michael Granger committed fbc91fc

* Updated for and included LinkGrammar 4.2.4
* Fixed weird typo

Comments (0)

Files changed (5)

LinkParser Project.tmproj

 <plist version="1.0">
 <dict>
 	<key>currentDocument</key>
-	<string>ext/linkage.c</string>
+	<string>tests/linkage.tests.rb</string>
 	<key>documents</key>
 	<array>
 		<dict>
 			<key>caret</key>
 			<dict>
 				<key>column</key>
-				<integer>1</integer>
+				<integer>0</integer>
 				<key>line</key>
-				<integer>62</integer>
+				<integer>704</integer>
 			</dict>
-			<key>columnSelection</key>
-			<false/>
 			<key>firstVisibleColumn</key>
 			<integer>0</integer>
 			<key>firstVisibleLine</key>
-			<integer>15</integer>
-			<key>selectFrom</key>
-			<dict>
-				<key>column</key>
-				<integer>1</integer>
-				<key>line</key>
-				<integer>56</integer>
-			</dict>
-			<key>selectTo</key>
-			<dict>
-				<key>column</key>
-				<integer>1</integer>
-				<key>line</key>
-				<integer>62</integer>
-			</dict>
+			<integer>654</integer>
 		</dict>
 		<key>ext/parseoptions.c</key>
 		<dict>
 				<key>column</key>
 				<integer>0</integer>
 				<key>line</key>
-				<integer>87</integer>
+				<integer>126</integer>
 			</dict>
 			<key>firstVisibleColumn</key>
 			<integer>0</integer>
 			<key>firstVisibleLine</key>
-			<integer>30</integer>
+			<integer>106</integer>
 		</dict>
 		<key>tests/parseoptions.tests.rb</key>
 		<dict>
 	<key>openDocuments</key>
 	<array>
 		<string>ext/linkage.c</string>
+		<string>tests/linkage.tests.rb</string>
 		<string>extconf.rb</string>
-		<string>tests/linkage.tests.rb</string>
 		<string>docs/link-includes.h</string>
 	</array>
 	<key>showFileHierarchyDrawer</key>
 	<true/>
 	<key>windowFrame</key>
-	<string>{{47, 26}, {836, 1002}}</string>
+	<string>{{47, 0}, {836, 1002}}</string>
 </dict>
 </plist>
 	names_ary = rb_ary_new2( count );
 	
 	for ( i = 0; i < count; i++ ) {
-		rb_ary_store( names_ary, i, rb_str_new2(namesquicksilver[i]) );
+		rb_ary_store( names_ary, i, rb_str_new2(names[i]) );
 	}
 	
 	return names_ary;
 	rlink_LINKAGE *ptr = get_linkage( self );
 	int rval;
 	
-	rval = linkage_compute_union( )
+	rval = linkage_compute_union( (Linkage)ptr->linkage );
+	
+	return INT2FIX( rval );
 }
 
 /*
 
 /*	rb_define_method( rlink_cLinkage, "print_constituent_tree",
 	 	rlink_linkage_print_constituent_tree, 1 );
-*/}
+*/
 
+}
+
 	  abort r.options.banner + " tests..." \
 	exit r.run \
 	EOF
+	EOF
 end
 

tests/linkage.tests.rb

 
 class LinkParser::Linkage::TestCase < Test::Unit::TestCase
 
+	@@dict = LinkParser::Dictionary.new( :verbosity => 0 )
+
 	def setup
-		@dict = LinkParser::Dictionary.new( :verbosity => 0 )
-		@simple_sentence = @dict.parse( "The flag was wet." )
+		@simple_sentence = @@dict.parse( "The flag was wet." )
+		@ss_linkage = @simple_sentence.linkages.first
 		@conjunct_sentence = 
-			@dict.parse( "The ball rolled down the hill and bumped the curb." )
+			@@dict.parse( "The ball rolled down the hill and bumped the curb." )
 	end
 
 
 		rval = nil
 		
 		assert_nothing_raised do
-			rval = @simple_sentence.linkages.first.diagram
+			rval = @ss_linkage.diagram
 		end
 		
 		assert_match( /LEFT-WALL/, rval )
 		rval = nil
 		
 		assert_nothing_raised do
-			rval = @simple_sentence.linkages.first.links_and_domains
+			rval = @ss_linkage.links_and_domains
 		end
 		
 		assert_match( /LEFT-WALL/, rval )
 			rval = @conjunct_sentence.linkages.first.num_sublinkages
 		end
 		
-		assert_equal 2, rval, "2 conjunctions"
+		assert_equal 2, rval, "2 sublinkages"
 	end
 	
+	def test_linkage_api_should_respond_to_num_words
+		assert_respond_to @ss_linkage, :num_words
+	end
+
+
+	def test_simple_sentence_linkage_should_have_seven_words
+		rval = nil
+		
+		assert_nothing_raised do
+			rval = @ss_linkage.num_words
+		end
+		
+		assert_equal 7, rval, "words: %p" % 
+			[ @ss_linkage.words ]
+	end
+
+	def test_linkage_api_should_respond_to_num_links
+		assert_respond_to @ss_linkage, :num_links
+	end
+
+	def test_simple_sentence_linkage_should_have_six_links
+		rval = nil
+		
+		assert_nothing_raised do
+			rval = @ss_linkage.num_links
+		end
+		
+         #1         LEFT-WALL      Xp      <---Xp---->  Xp        .
+         #2   (m)   LEFT-WALL      Wd      <---Wd---->  Wd        flag.n
+         #3+4 (m)   the            D       <---Ds---->  Ds        flag.n
+         #5   (m)   flag.n         Ss      <---Ss---->  Ss        was.v
+         #6   (m)   was.v          Pa      <---Pa---->  Pa        wet.a
+		assert_equal 6, rval
+	end
 	
+	def test_linkage_api_should_respond_to_link_lword
+		assert_respond_to @ss_linkage, :link_lword
+	end
+
+
+	def test_linkage_api_should_respond_to_link_rword
+		assert_respond_to @ss_linkage, :link_rword
+	end
+
+
+	def test_linkage_api_should_respond_to_link_length
+		assert_respond_to @ss_linkage, :link_length
+	end
+
+
+	def test_linkage_api_should_respond_to_link_label
+		assert_respond_to @ss_linkage, :link_label
+	end
+
+
+	def test_linkage_api_should_respond_to_link_llabel
+		assert_respond_to @ss_linkage, :link_llabel
+	end
+
+
+	def test_linkage_api_should_respond_to_link_rlabel
+		assert_respond_to @ss_linkage, :link_rlabel
+	end
+
+
+	def test_linkage_api_should_respond_to_link_num_domains
+		assert_respond_to @ss_linkage, :link_num_domains
+	end
+
+	def test_linkage_api_should_respond_to_link_domain_names
+		assert_respond_to @ss_linkage, :link_domain_names
+	end
+	
+	def test_linkage_api_should_respond_to_words
+		assert_respond_to @ss_linkage, :words
+	end
+
+
+	def test_linkage_api_should_respond_to_compute_union
+		assert_respond_to @ss_linkage, :compute_union
+	end
+
+
+	def test_linkage_api_should_respond_to_unused_word_cost
+		assert_respond_to @ss_linkage, :unused_word_cost
+	end
+
+
+	def test_linkage_api_should_respond_to_disjunct_cost
+		assert_respond_to @ss_linkage, :disjunct_cost
+	end
+
+
+	def test_linkage_api_should_respond_to_and_cost
+		assert_respond_to @ss_linkage, :and_cost
+	end
+
+
+	def test_linkage_api_should_respond_to_link_cost
+		assert_respond_to @ss_linkage, :link_cost
+	end
+
+
+	def test_linkage_api_should_respond_to_canonical?
+		assert_respond_to @ss_linkage, :canonical?
+	end
+
+
+	def test_linkage_api_should_respond_to_improper?
+		assert_respond_to @ss_linkage, :improper?
+	end
+
+
+	def test_linkage_api_should_respond_to_has_inconsistent_domains?
+		assert_respond_to @ss_linkage, :has_inconsistent_domains?
+	end
+
+
+	def test_linkage_api_should_respond_to_violation_name
+		assert_respond_to @ss_linkage, :violation_name
+	end
+
 end