ad nl-tts, first version

This commit is contained in:
sonora 2012-02-04 10:17:25 +01:00
parent 4f437052a9
commit 6a442dd806

View file

@ -0,0 +1,88 @@
:- op('==', xfy, 500).
version(101).
language(nl).
% before each announcement (beep)
preamble - [].
%% TURNS
turn('left', ['links afslaan ']).
turn('left_sh', ['scherp bocht naar links ']).
turn('left_sl', ['links afbuigen ']).
turn('right', ['rechts afslaan ']).
turn('right_sh', ['scherpe bocht naar rechts ']).
turn('right_sl', ['rechts afbuigen ']).
prepare_turn(Turn, Dist) == ['Na ', D, M] :- distance(Dist, dativ) == D, turn(Turn, M).
turn(Turn, Dist) == ['Na ', D, M] :- distance(Dist, dativ) == D, turn(Turn, M).
turn(Turn) == M :- turn(Turn, M).
prepare_make_ut(Dist) == ['Houdt rekening met een afslag ', D] :- distance(Dist, dativ) == D.
make_ut(Dist) == ['Na ', D, ' afslaan '] :- distance(Dist, dativ) == D.
make_ut == ['Graag afslaan '].
prepare_roundabout(Dist) == ['Afslaan bij een rotonde ', D] :- distance(Dist, dativ) == D.
roundabout(Dist, _Angle, Exit) == ['Na ', D, ' de rotonde oprijden en dan neemt u de ', E, 'afslag'] :- distance(Dist, dativ) == D, nth(Exit, E).
roundabout(_Angle, Exit) == ['Neemt u de ', E, 'afslag'] :- nth(Exit, E).
go_ahead == ['Verder doorrijden '].
go_ahead(Dist) == ['De weg', D,'volgen']:- distance(Dist, nominativ) == D.
and_arrive_destination == ['dan heeft u uw bestemming bereikt '].
then == ['dan '].
reached_destination == ['Bestemming bereikt '].
bear_right == ['rechts aanhouden '].
bear_left == ['links aanhouden '].
route_new_calc(Dist) == ['De berekende afstand is ', D, ' lang'] :- distance(Dist, nominativ) == D.
route_recalc(Dist) == ['Afstand opnieuw berekend, Verwijdering ', D] :- distance(Dist, nominativ) == D.
location_lost == ['G P S Signaal verloren '].
%%
nth(1, 'eerste ').
nth(2, 'tweede ').
nth(3, 'derde ').
nth(4, 'vierde ').
nth(5, 'vijfde ').
nth(6, 'zesde ').
nth(7, 'zevende ').
nth(8, 'achtste ').
nth(9, 'negende ').
nth(10, 'tiende ').
nth(11, 'elfde ').
nth(12, 'twaalfde ').
nth(13, 'dertiende ').
nth(14, 'viertiende ').
nth(15, 'vijftiende ').
nth(16, 'zestiende ').
nth(17, 'zeventiende ').
%%% distance measure
distance(Dist, nominativ) == [ X, ' meter'] :- Dist < 100, D is round(Dist/10)*10, num_atom(D, X).
distance(Dist, dativ) == [ X, ' meter'] :- Dist < 100, D is round(Dist/10)*10, num_atom(D, X).
distance(Dist, nominativ) == [ X, ' meter'] :- Dist < 1000, D is round(2*Dist/100)*50, num_atom(D, X).
distance(Dist, dativ) == [ X, ' meter'] :- Dist < 1000, D is round(2*Dist/100)*50, num_atom(D, X).
distance(Dist, nominativ) == ['ongeveer een kilometer '] :- Dist < 1500.
distance(Dist, dativ) == ['ongeveer een Kilometer '] :- Dist < 1500.
distance(Dist, nominativ) == ['ongeveer ', X, ' Kilometer '] :- Dist < 10000, D is round(Dist/1000), num_atom(D, X).
distance(Dist, dativ) == ['ongeveer ', X, 'Kilometer '] :- Dist < 10000, D is round(Dist/1000), num_atom(D, X).
distance(Dist, nominativ) == [ X, ' Kilometer '] :- D is round(Dist/1000), num_atom(D, X).
distance(Dist, dativ) == [ X, 'Kilometer '] :- D is round(Dist/1000), num_atom(D, X).
%% resolve command main method
%% if you are familar with Prolog you can input specific to the whole mechanism,
%% by adding exception cases.
flatten(X, Y) :- flatten(X, [], Y), !.
flatten([], Acc, Acc).
flatten([X|Y], Acc, Res):- flatten(Y, Acc, R), flatten(X, R, Res).
flatten(X, Acc, [X|Acc]).
resolve(X, Y) :- resolve_impl(X,Z), flatten(Z, Y).
resolve_impl([],[]).
resolve_impl([X|Rest], List) :- resolve_impl(Rest, Tail), ((X == L) -> append(L, Tail, List); List = Tail).