mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-05 09:12:51 -06:00
change tabularLinearize in the Haskell binding to return a list instead of map this preserves the order
This commit is contained in:
@@ -363,7 +363,7 @@ then the right method to use is <tt>tabularLinearize</tt>:
|
|||||||
</pre>
|
</pre>
|
||||||
<pre class="haskell">
|
<pre class="haskell">
|
||||||
Prelude PGF2> tabularLinearize eng e
|
Prelude PGF2> tabularLinearize eng e
|
||||||
fromList [("s Pl Gen","red theatres'"),("s Pl Nom","red theatres"),("s Sg Gen","red theatre's"),("s Sg Nom","red theatre")]
|
[("s Sg Nom","red theatre"),("s Sg Gen","red theatre's"),("s Pl Nom","red theatres"),("s Pl Gen","red theatres'")]
|
||||||
</pre>
|
</pre>
|
||||||
<pre class="java">
|
<pre class="java">
|
||||||
for (Map.Entry<String,String> entry : eng.tabularLinearize(e).entrySet()) {
|
for (Map.Entry<String,String> entry : eng.tabularLinearize(e).entrySet()) {
|
||||||
|
|||||||
@@ -648,7 +648,7 @@ linearizeAll lang e = unsafePerformIO $
|
|||||||
throwIO (PGFError "The abstract tree cannot be linearized")
|
throwIO (PGFError "The abstract tree cannot be linearized")
|
||||||
|
|
||||||
-- | Generates a table of linearizations for an expression
|
-- | Generates a table of linearizations for an expression
|
||||||
tabularLinearize :: Concr -> Expr -> Map.Map String String
|
tabularLinearize :: Concr -> Expr -> [(String, String)]
|
||||||
tabularLinearize lang e = unsafePerformIO $
|
tabularLinearize lang e = unsafePerformIO $
|
||||||
withGuPool $ \tmpPl -> do
|
withGuPool $ \tmpPl -> do
|
||||||
exn <- gu_new_exn tmpPl
|
exn <- gu_new_exn tmpPl
|
||||||
@@ -660,7 +660,7 @@ tabularLinearize lang e = unsafePerformIO $
|
|||||||
peek ptr
|
peek ptr
|
||||||
if ctree == nullPtr
|
if ctree == nullPtr
|
||||||
then do touchExpr e
|
then do touchExpr e
|
||||||
return Map.empty
|
return []
|
||||||
else do labels <- alloca $ \p_n_lins ->
|
else do labels <- alloca $ \p_n_lins ->
|
||||||
alloca $ \p_labels -> do
|
alloca $ \p_labels -> do
|
||||||
pgf_lzr_get_table (concr lang) ctree p_n_lins p_labels
|
pgf_lzr_get_table (concr lang) ctree p_n_lins p_labels
|
||||||
@@ -670,7 +670,7 @@ tabularLinearize lang e = unsafePerformIO $
|
|||||||
labels <- mapM peekCString labels
|
labels <- mapM peekCString labels
|
||||||
return labels
|
return labels
|
||||||
lins <- collect lang ctree 0 labels exn tmpPl
|
lins <- collect lang ctree 0 labels exn tmpPl
|
||||||
return (Map.fromList lins)
|
return lins
|
||||||
where
|
where
|
||||||
collect lang ctree lin_idx [] exn tmpPl = return []
|
collect lang ctree lin_idx [] exn tmpPl = return []
|
||||||
collect lang ctree lin_idx (label:labels) exn tmpPl = do
|
collect lang ctree lin_idx (label:labels) exn tmpPl = do
|
||||||
|
|||||||
Reference in New Issue
Block a user