20.07.2013 Views

Notes on computational linguistics.pdf - UCLA Department of ...

Notes on computational linguistics.pdf - UCLA Department of ...

Notes on computational linguistics.pdf - UCLA Department of ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Stabler - Lx 185/209 2003<br />

1 ?- [col12].<br />

% col12 compiled 2.13 sec, 52 bytes<br />

Yes<br />

2 ?- tell(’col12r.pl’),lex(Word,[B|C]),atom_chars(Word,Chars),<br />

portray_clause(lex(B,C,Chars)),fail;told.<br />

No<br />

You do not need to know about the special prolog facilities that are used here, but in case you are interested,<br />

here is a quick explanati<strong>on</strong>.<br />

The built-in command tell causes all output to be written to the specified file; then each clause <strong>of</strong> lex is<br />

written in the new format using the built-in command portray_clause – which is just like write except that<br />

its argument is followed by a period, etc. so that it can be read as a clause; then the fail causes the prolog to<br />

backtrack an find the next clause, and the next and so <strong>on</strong>, until all <strong>of</strong> them are found. When all ways <strong>of</strong> proving<br />

the first c<strong>on</strong>juncts fail, then the built-in command told closes the file that was opened by tell and succeeds.<br />

After executing this command, we have a new representati<strong>on</strong> <strong>of</strong> the lexic<strong>on</strong> that has clauses like this in it:<br />

...<br />

lex(&, [d, m, @, r, @, l, t, ’I’], [a, d, m, i, r, a, l, t, y]).<br />

lex(&, [d, m, @, r, eI, ’S’, n], [a, d, m, i, r, a, t, i, o, n]).<br />

lex(@, [d, m, aI, @, ’R’], [a, d, m, i, r, e]).<br />

lex(@, [d, m, aI, @, d], [a, d, m, i, r, e, d]).<br />

lex(@, [d, m, aI, r, @, ’R’], [a, d, m, i, r, e, r]).<br />

lex(@, [d, m, aI, r, @, z], [a, d, m, i, r, e, r, s]).<br />

lex(@, [d, m, aI, @, z], [a, d, m, i, r, e, s]).<br />

lex(@, [d, m, aI, @, r, ’I’, ’N’], [a, d, m, i, r, i, n, g]).<br />

lex(@, [d, m, aI, @, r, ’I’, ’N’, l, ’I’], [a, d, m, i, r, i, n, g, l, y]).<br />

lex(@, [d, m, ’I’, s, @, b, ’I’, l, ’I’, t, ’I’], [a, d, m, i, s, s, i, b, i, l, i, t, y]).<br />

lex(@, [d, m, ’I’, s, @, b, l], [a, d, m, i, s, s, i, b, l, e]).<br />

lex(@, [d, m, ’I’, ’S’, n], [a, d, m, i, s, s, i, o, n]).<br />

lex(@, [d, m, ’I’, ’S’, n, z], [a, d, m, i, s, s, i, o, n, s]).<br />

lex(@, [d, m, ’I’, t], [a, d, m, i, t]).<br />

lex(@, [d, m, ’I’, t, s], [a, d, m, i, t, s]).<br />

lex(@, [d, m, ’I’, t, n, s], [a, d, m, i, t, t, a, n, c, e]).<br />

...<br />

This lexic<strong>on</strong> is more efficiently accessed because the first symbol <strong>of</strong> the ph<strong>on</strong>etic transcripti<strong>on</strong> is exposed as<br />

the first argument.<br />

We just need to modify slightly the translate program to use this new representati<strong>on</strong> <strong>of</strong> the dicti<strong>on</strong>ary:<br />

%File: medprog.pl<br />

% first, we load the first 2 columns <strong>of</strong> the Mitt<strong>on</strong> lexic<strong>on</strong> in the new format<br />

:- [col12r].<br />

%translate(Ph<strong>on</strong>es,Words)<br />

translate([],[]).<br />

translate(Ph<strong>on</strong>es,[Word|Words]) :append([First|MorePh<strong>on</strong>es],RestPh<strong>on</strong>es,Ph<strong>on</strong>es),<br />

%% minor change here<br />

lex(First,MorePh<strong>on</strong>es,Chars), %% minor change here<br />

atom_chars(Word,Chars),<br />

translate(RestPh<strong>on</strong>es,Words).<br />

36

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!