Functor Lexicon
(see Section A.9) imports module Entry
defined in the previous section, and exports function Get
which takes an atom as an argument (representing the full form of a word) and returns the corresponding list of lexicon entries, or raises exception unknownword(Word)
if the word does not appear in the lexicon.
- <
Lexicon.oz
>= functor
import Entry
export Get
define
Lexicon = {Dictionary.new}
proc {PUT Word Spec}
{Dictionary.put Lexicon Word
{Entry.lexEncode Spec}|{Dictionary.condGet Lexicon Word nil}}
end
fun {Get Word}
try Lexicon.Word
catch _ then
raise unknownword(Word) end
end
end
<Lexicon entries>
end