Fixing 'linearize' in py-bindings/test.py

This commit is contained in:
jordi.saludes
2011-12-22 21:29:45 +00:00
parent 9c467e1b40
commit 2d6d969a60
4 changed files with 6 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE ForeignFunctionInterface #-}
-- --
-- GF Python bindings -- GF Python bindings
-- Jordi Saludes, upc.edu 2010 -- Jordi Saludes, upc.edu 2010, 2011
-- --
module PyGF where module PyGF where
@@ -157,9 +157,6 @@ listToPyStrings ss = do
pcs <- pyString cs pcs <- pyString cs
pyl << pcs pyl << pcs
-- foreign export ccall "gf_freeArray" free :: Ptr a -> IO ()
foreign export ccall gf_showLanguage :: Ptr Language -> IO CString foreign export ccall gf_showLanguage :: Ptr Language -> IO CString
gf_showLanguage plang = do gf_showLanguage plang = do

View File

@@ -9,7 +9,7 @@ First you must import the library:
>>> import gf >>> import gf
then load a .pgf file, like this tiny example: then load a PGF file, like this tiny example:
>>> pgf = gf.read_pgf("Query.pgf") >>> pgf = gf.read_pgf("Query.pgf")
@@ -73,7 +73,7 @@ Is it important to note the blank space at the end, otherwise we get it again:
['is'] ['is']
But, how come that nothing is suggested at "is "? But, how come that nothing is suggested at "is "?
At the current point, a literal integer is expected so GF would have to present an infinite list of alternatives. I can not blame it for refusing to do so. At the current point, a literal integer is expected so GF would have to present an infinite list of alternatives. I cannot blame it for refusing to do so.
>>> pgf.complete(eng, "is 42 ") >>> pgf.complete(eng, "is 42 ")
['even', 'odd', 'prime'] ['even', 'odd', 'prime']

View File

@@ -267,7 +267,7 @@ static PyMethodDef expr_methods[] = {
/* tree typr: methods, constructor and destructor */ /* tree type: methods, constructor and destructor */
// Are Expr and Tree equivalent ? // Are Expr and Tree equivalent ?
REPRCB(tree_repr, Tree, gf_showExpr) REPRCB(tree_repr, Tree, gf_showExpr)

View File

@@ -108,7 +108,7 @@ class TestLinearize(unittest.TestCase):
l = self.lang l = self.lang
for abs,cnc in self.samples: for abs,cnc in self.samples:
ts = self.pgf.parse(l, cnc['eng']) ts = self.pgf.parse(l, cnc['eng'])
self.assertEqual(cnc['eng'],self.pgf.lin(l,ts[0])) self.assertEqual(cnc['eng'],self.pgf.linearize(l,ts[0]))
class TestTranslate(unittest.TestCase): class TestTranslate(unittest.TestCase):
def setUp(self): def setUp(self):
@@ -123,7 +123,7 @@ class TestTranslate(unittest.TestCase):
if i==j: continue if i==j: continue
parsed = self.pgf.parse(l, cnc[i]) parsed = self.pgf.parse(l, cnc[i])
assert len(parsed) == 1 assert len(parsed) == 1
lin = self.pgf.lin(m,parsed[0]) lin = self.pgf.linearize(m,parsed[0])
self.assertEqual(lin,cnc[j]) self.assertEqual(lin,cnc[j])
class TestUnapplyExpr(unittest.TestCase): class TestUnapplyExpr(unittest.TestCase):