simplified recursive search of labels

This commit is contained in:
aarne
2006-09-07 09:55:49 +00:00
parent d8bf6f1c9c
commit 8b32514b40
2 changed files with 11 additions and 13 deletions

View File

@@ -584,7 +584,6 @@ and an optional tailing vocative ("John", "please").
The richest of the categories below Utterance is ``S``, Sentence. A Sentence The richest of the categories below Utterance is ``S``, Sentence. A Sentence
is formed from a Clause (``Cl``), by fixing its Tense, Anteriority, and Polarity. is formed from a Clause (``Cl``), by fixing its Tense, Anteriority, and Polarity.
The difference between Sentence and Clause is thus also rather technical.
For example, each of the following strings has a distinct syntax tree For example, each of the following strings has a distinct syntax tree
in the category Sentence: in the category Sentence:
``` ```
@@ -600,6 +599,9 @@ in the category Sentence:
``` ```
whereas in the category Clause all of them are just different forms of whereas in the category Clause all of them are just different forms of
the same tree. the same tree.
The difference between Sentence and Clause is thus also rather technical.
It may not correspond exactly to any standard usage of the terms
"clause" and "sentence".
Figure 1 shows a type-annotated syntax tree of the Text "John walks." Figure 1 shows a type-annotated syntax tree of the Text "John walks."
and gives an overview of the structural levels. and gives an overview of the structural levels.

View File

@@ -149,15 +149,14 @@ paramValues cgr = (labels,untyps,typs) where
labels = Map.fromList $ concat labels = Map.fromList $ concat
[((cat,[lab]),i): [((cat,[lab]),i):
[((cat,[lab,lab2]),j) | [((cat,[lab,lab2]),j) |
RecType rs <- [typ], (Lbg lab2 _,j) <- zip rs [0..]] ++
[((cat,[lab,L (IC ("_")),lab2]),j) |
rs <- getRec typ, (Lbg lab2 _,j) <- zip rs [0..]] rs <- getRec typ, (Lbg lab2 _,j) <- zip rs [0..]]
| |
(cat,ls) <- lincats, (Lbg lab typ,i) <- zip ls [0..]] (cat,ls) <- lincats, (Lbg lab typ,i) <- zip ls [0..]]
---- this should be made recursive to give lists of any length -- go to tables recursively
---- TODO: even go to deeper records
where where
getRec typ = case typ of getRec typ = case typ of
Table _ (RecType rs) -> [rs] RecType rs -> [rs]
Table _ t -> getRec t Table _ t -> getRec t
_ -> [] _ -> []
@@ -179,18 +178,15 @@ term2term cgr env@(labels,untyps,typs) tr = case tr of
P x@(Arg (A cat i)) lab -> P x@(Arg (A cat i)) lab ->
P x . mkLab $ maybe (prtTrace tr $ 66664) id $ P x . mkLab $ maybe (prtTrace tr $ 66664) id $
Map.lookup (cat,[lab]) labels Map.lookup (cat,[lab]) labels
P p@(P x@(Arg (A cat i)) lab1) lab2 ->
P (r2r p) . mkLab $ maybe (prtTrace tr $ 66664) id $
Map.lookup (cat,[lab1,lab2]) labels
P p lab2 -> case getLab p of P p lab2 -> case getLab p of
Just (cat,lab1) -> P (r2r p) . mkLab $ maybe (prtTrace tr $ 66664) id $ Just (cat,lab1) -> P (r2r p) . mkLab $ maybe (prtTrace tr $ 66664) id $
Map.lookup (cat,[lab1,L (IC ("_")),lab2]) labels Map.lookup (cat,[lab1,lab2]) labels
_ -> P (t2t p) $ mkLab (prtTrace tr 66665) _ -> P (t2t p) $ mkLab (prtTrace tr 66665)
P p lab2 -> P (t2t p) $ mkLab (prtTrace tr 66665)
_ -> tr ---- _ -> tr ----
---- this should be made recursive -- this goes recursively in tables
---- TODO: also recursive in records to get longer lists of labels
getLab tr = case tr of getLab tr = case tr of
S (P (Arg (A cat i)) lab1) _ -> return (cat,lab1) P (Arg (A cat i)) lab1 -> return (cat,lab1)
S p _ -> getLab p S p _ -> getLab p
_ -> Nothing _ -> Nothing
mkLab k = L (IC ("_" ++ show k)) mkLab k = L (IC ("_" ++ show k))