1% This file is part of the Attempto Parsing Engine (APE).
    2% Copyright 2008-2013, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch).
    3%
    4% The Attempto Parsing Engine (APE) is free software: you can redistribute it and/or modify it
    5% under the terms of the GNU Lesser General Public License as published by the Free Software
    6% Foundation, either version 3 of the License, or (at your option) any later version.
    7%
    8% The Attempto Parsing Engine (APE) is distributed in the hope that it will be useful, but WITHOUT
    9% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   10% PURPOSE. See the GNU Lesser General Public License for more details.
   11%
   12% You should have received a copy of the GNU Lesser General Public License along with the Attempto
   13% Parsing Engine (APE). If not, see http://www.gnu.org/licenses/.
   14
   15
   16:- module(drs_to_ace, [drs_to_ace/2]).   17
   18:- use_module(drs_to_drslist, [
   19		drs_to_drslist/2
   20	]).   21
   22:- use_module(drs_to_coreace).   23
   24:- use_module(drs_to_npace).

DRS to ACE verbalizer

Translate an Attempto DRS into Attempto Controlled English (ACE). The result is either in Core ACE or in NP ACE.

author
- Kaarel Kaljurand
version
- 2009-06-03 */
 drs_to_ace(+Drs:drs, -Ace:list) is det
Splits the given DRS into a list of (smaller) DRSs, and verbalizes each split in either Core ACE or NP ACE.
Arguments:
Drs- is an Attempto DRS (untyped)
Ace- is a list of ACE sentences
   44drs_to_ace(Drs, Ace) :-
   45	drs_to_drslist(Drs, DrsList),
   46	drslist_to_ace(DrsList, Ace).
 drslist_to_ace
   52drslist_to_ace([], []).
   53
   54drslist_to_ace([Drs | DrsList], [Ace | AceList]) :-
   55	drs_to_ace_x(Drs, Ace),
   56	drslist_to_ace(DrsList, AceList).
   57
   58
   59% BUG: As Drace NP might take very long (due to a bug?) we add
   60% a timeout to fail if it takes longer than, say, 0.5 seconds.
   61drs_to_ace_x(Drs, Ace) :-
   62	catch(
   63		call_with_time_limit(
   64			0.5,
   65			drs_to_npace:drs_to_npace(Drs, Ace)
   66		),
   67		time_limit_exceeded,
   68		fail
   69	),
   70	Ace \= [],
   71	\+ member('ERROR', Ace),
   72	!.
   73
   74drs_to_ace_x(Drs, Ace) :-
   75	drs_to_coreace:drs_to_coreace(Drs, Ace)