diff options
| author | aarne <unknown> | 2003-10-01 12:46:44 +0000 |
|---|---|---|
| committer | aarne <unknown> | 2003-10-01 12:46:44 +0000 |
| commit | c985dab565416251d9973f5b3bafe4d9d205b249 (patch) | |
| tree | ada69513d8a20338af8058d35ce2bc75e5495d4b /src/GF/Data/Str.hs | |
| parent | 8ed7749eb674e3afe4485cfb3d4d50485a2cf097 (diff) | |
Putting def definitions in place.
Diffstat (limited to 'src/GF/Data/Str.hs')
| -rw-r--r-- | src/GF/Data/Str.hs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/GF/Data/Str.hs b/src/GF/Data/Str.hs index 743bd71b8..0c1ecf7c9 100644 --- a/src/GF/Data/Str.hs +++ b/src/GF/Data/Str.hs @@ -16,6 +16,7 @@ newtype Str = Str [Tok] deriving (Read, Show, Eq, Ord) data Tok = TK String | TN Ss [(Ss, [String])] -- variants depending on next string +--- | TP Ss [(Ss, [String])] -- variants depending on previous string deriving (Eq, Ord, Show, Read) -- notice that having both pre and post would leave to inconsistent situations: @@ -31,14 +32,19 @@ type Ss = [String] matchPrefix :: Ss -> [(Ss,[String])] -> [String] -> Ss matchPrefix s vs t = - head ([u | (u,as) <- vs, any (\c -> isPrefixOf c (concat t)) as] ++ [s]) + head ([u | (u,as) <- vs, any (\c -> isPrefixOf c (concat t)) as] ++ [s]) + +matchSuffix :: String -> Ss -> [(Ss,[String])] -> Ss +matchSuffix t s vs = + head ([u | (u,as) <- vs, any (\c -> isSuffixOf c t) as] ++ [s]) str2strings :: Str -> Ss str2strings (Str st) = alls st where alls st = case st of - TK s : ts -> s : alls ts - TN ds vs : ts -> matchPrefix ds vs t ++ t where t = alls ts - [] -> [] + TK s : ts -> s : alls ts + TN ds vs : ts -> matchPrefix ds vs t ++ t where t = alls ts +---- u :TP ds vs: ts -> [u] ++ matchSuffix u ds vs ++ alls ts + [] -> [] str2allStrings :: Str -> [Ss] str2allStrings (Str st) = alls st where |
