/usr/share/mozart/examples/grammar/hpsg.oz is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | %%%
%%% Authors:
%%% Gert Smolka <smolka@ps.uni-sb.de>
%%%
%%% Contributors:
%%% Denys Duchier <duchier@ps.uni-sb.de>
%%%
%%% Copyright:
%%% Gert Smolka, 1998
%%% Denys Duchier, 2002
%%%
%%% Last change:
%%% $Date: 2002-08-20 01:36:53 +0200 (Tue, 20 Aug 2002) $ by $Author: duchier $
%%% $Revision: 15058 $
%%%
%%% This file is part of Mozart, an implementation
%%% of Oz 3
%%% http://www.mozart-oz.org
%%%
%%% See the file "LICENSE" or
%%% http://www.mozart-oz.org/LICENSE.html
%%% for information on usage and redistribution
%%% of this file, and for a DISCLAIMER OF ALL
%%% WARRANTIES.
%%%
declare
proc {Rules P L R} % binary rules only P -> L R
{Phrase P}
P^phon = {Append L^phon R^phon}
thread
or P^index = 0
P^subcat = nil
P^headDtr = R
P^compDtr = L
[] P^index = 1
P^subcat = [_]
P^headDtr = L
P^compDtr = R
end
end
end
proc {Phrase P}
H C I
in
P = p(cat:_ subcat:_ phon:_ headDtr:H compDtr:C index:I)
I::0#1
H^subcat = C^cat | P^subcat % subcat principle
C^subcat = nil % saturated complements
P^cat = H^cat % head-feature principle
end
Lexicon =
% WORD # CAT # SUBCAT
[ mary # noun # nil
john # noun # nil
girl # noun # [determiner]
nice # adjective # nil
pretty # adjective # nil
the # determiner # nil
laughs # verb # [noun]
meets # verb # [noun noun]
kisses # verb # [noun noun]
embarrasses # verb # [noun noun]
thinks # verb # [verb noun]
is # verb # [adjective noun]
met # adjective # nil
kissed # adjective # nil
embarrassed # adjective # nil ]
LexiconLength = {Length Lexicon}
proc {Word W}
P C S I
in
W = w(phon:[P] cat:C subcat:S index:I)
I :: 1#LexiconLength
for Phon#Cat#Subcat in Lexicon K in 1;K+1 do
thread or I=K P=Phon C=Cat S=Subcat [] I\=:K end end
end
end
proc {Parse Phon Phrase}
Words = {Map Phon proc {$ W F} F^phon=[W] {Word F} end}
Indices = {Map Words fun {$ W} W.index end}
PORT
in
%% only one thread must be in control of the distribution strategy
%% communication with this thread is done by means of a port
%% abstractions that post disjunctions should send a message to
%% this port with a FD variable allow to choose one or the other
%% alternative of the disjunctions
thread
for Msg in {NewPort $ PORT} break:Break do
case Msg
of choose(I) then {FD.distribute naive [I]}
[] finish then
%% make sure all lexical choices have been made
{FD.distribute naive Indices}
{Break}
end
end
end
{Parse1 Words PORT Phrase}
{Send PORT finish({Map Words fun {$ W} W.index end})}
end
fun {Parse1 Fs PORT}
case Fs of [F] then {Send PORT finish} F
else {Parse1 {Move Fs PORT} PORT} end
end
proc {Move Fs PORT ?Gs}
case Fs of F|(G|Fr=T) then I in
I::0#1
{Send PORT choose(I)}
thread
or I=0 Gs={Rules $ F G}|Fr
[] I=1 then Gs=F|{Move T PORT}
end
end
else fail
end
end
proc {SParse Phon}
{ExploreOne fun {$} {Parse Phon} end}
end
/*
{SParse [the girl is nice]}
{SParse [mary thinks john embarrasses the girl]}
{SParse [john thinks mary thinks mary thinks the girl thinks
john thinks mary thinks mary thinks the girl thinks
john thinks mary thinks mary thinks the girl thinks
mary thinks the girl is embarrassed]}
*/
|