Skip to content

Commit

Permalink
Some fixes after merging #24
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaljurand committed Jul 14, 2018
1 parent 23255fa commit 00fb91d
Show file tree
Hide file tree
Showing 23 changed files with 95 additions and 69 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
APE Change Log
==============

Version 6.7-180714
------------------

- Package APE as a [SWI-Prolog extension package](http://www.swi-prolog.org/howto/Pack.txt)
(Thanks to @fnogatz, see more at https://github.com/Attempto/APE/pull/24)
- Small fixes to improve compatibility with dependencies

Version 6.7-131003
------------------

Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Unofficial Makefile for some tasks
# Tested only on Ubuntu Linux.

SHELL=/bin/bash

version = 6.7

text1 = "John likes Mary."
Expand All @@ -22,18 +24,18 @@ help:


build:
swipl -O -F none -g "working_directory(_, 'prolog/parser'), [fit_to_plp], halt." -t halt ; swipl -O -f ape.pl -g "qsave_program('ape.exe', [goal(ape), toplevel(halt), local(25000), global(50000)])." -t halt
swipl -O -F none -g "working_directory(_, 'prolog/parser'), [fit_to_plp], halt." -t halt ; swipl -O -f ape.pl -g "qsave_program('ape.exe', [goal(ape), toplevel(halt)])." -t halt

install: build

check:

clean:
rm -f *.exe *.toc parser/*.plp parser/*.html parser/*.toc
rm -f *.exe *.toc prolog/parser/*.{plp,html,toc}

doc:
cat parser/grammar.fit parser/grammar_functionwords.fit parser/grammar_contentwords.fit | perl parser/make_syntax_report.perl
cat parser/grammar.fit parser/grammar_functionwords.fit parser/grammar_contentwords.fit | perl parser/make_syntax_report.perl --number $(version) > syntax_report.html
cat prolog/parser/{grammar,grammar_functionwords,grammar_contentwords}.fit | perl prolog/parser/make_syntax_report.perl
cat prolog/parser/{grammar,grammar_functionwords,grammar_contentwords}.fit | perl prolog/parser/make_syntax_report.perl --number $(version) > syntax_report.html

test:
./ape.exe -text $(text1) -cdrspp -cparaphrase -cowlfsspp -csyntax -csyntaxpp -csyntaxd -csyntaxdpp
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Compilation
-----------

Before you can run APE, you have to compile the APE source code. Just execute the file
`make_exe.bat` in the case of Windows or `make_exe.sh` in the case of Mac OS X, Linux, or any other
Unix system. Both files are located in the root directory of the APE distribution. As a result (and
`make_exe.bat` in the case of Windows or `make install` in the case of Mac OS X, Linux, or any other
Unix system. Both the bat-file and the Makefile are located in the root directory of the APE distribution. As a result (and
given that there were no compilation errors), a new file `ape.exe` is created in the current
directory.

Expand Down Expand Up @@ -245,7 +245,8 @@ context of `ape.exe`. For example, the following command displays the source cod
Code
----

The distribution includes the following packages containing the main code in Prolog:
The distribution includes the following packages containing the main code in Prolog
(in the prolog-directory):

- `logger/` contains the error logger module
- `lexicon/` contains various lexicon files, notably a content words lexicon with ~2,000 entries
Expand Down
10 changes: 3 additions & 7 deletions ape.pl
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@
@author Tobias Kuhn
@author Kaarel Kaljurand
Building the executable file (stack sizes are in kilobytes):
Building the executable file:
==
swipl -g "working_directory(_, 'parser'), [fit_to_plp], halt."
swipl -O -F none -g "[ape], qsave_program('ape.exe', [goal(ape), toplevel(halt), local(25000), global(50000)])." -t halt
swipl -g "working_directory(_, 'prolog/parser'), [fit_to_plp], halt."
swipl -O -F none -g "[ape], qsave_program('ape.exe', [goal(ape), toplevel(halt)])." -t halt
==
Note that you can use smaller stack sizes if needed. It is known that global stack of 25600 was not
enough to parse 1687 sentences of the Ordnance Survey Hydrology ontology verbalization.
TODO:
- Do better checking of which arguments can be used together. E.g. if the user uses both -server
Expand Down
2 changes: 1 addition & 1 deletion examples/ace_to_ace.pl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/

% We point to the directory where APE modules and the lexicons are located.
:- assert(user:file_search_path(ape, '..')).
:- assert(user:file_search_path(ape, '../prolog')).

:- use_module(ape('parser/ace_to_drs'), [
acetext_to_drs/5
Expand Down
2 changes: 1 addition & 1 deletion examples/ace_to_owl.pl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

% We point to the directory where APE modules and the lexicons are located.
:- assert(user:file_search_path(ape, '..')).
:- assert(user:file_search_path(ape, '../prolog')).

:- use_module(ape('parser/ace_to_drs'), [
acetext_to_drs/5
Expand Down
4 changes: 3 additions & 1 deletion examples/output_tests.pl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

% We point to the directory where APE modules and the lexicons are located.
:- assert(user:file_search_path(ape, '..')).
:- assert(user:file_search_path(ape, '../prolog')).

:- use_module(ape('parser/tokenizer'), [
tokenize/2
Expand All @@ -39,6 +39,8 @@
pronoun_split/3
]).

:- assert(user:file_search_path(ape, '..')).

:- consult(ape('tests/acetexts')).


Expand Down
2 changes: 1 addition & 1 deletion examples/paraphrase_roundtrip.pl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

% We point to the directory where APE modules and the lexicons are located.
:- assert(user:file_search_path(ape, '..')).
:- assert(user:file_search_path(ape, '../prolog')).

% We import the needed modules.
:- use_module(ape(parser/ace_to_drs), [acetext_to_drs/8]).
Expand Down
3 changes: 0 additions & 3 deletions make_exe.sh

This file was deleted.

2 changes: 1 addition & 1 deletion pack.pl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name(ape).
version('6.7.131003').
version('6.7.180714').

% see http://www.swi-prolog.org/howto/PackInfo.html

Expand Down
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
prolog=swipl

$prolog -g "working_directory(_, parser), [fit_to_plp], halt."
$prolog -g "working_directory(_, 'prolog/parser'), [fit_to_plp], halt."
$prolog -g "[runape]."
32 changes: 16 additions & 16 deletions runape.pl
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
% Parsing Engine (APE). If not, see http://www.gnu.org/licenses/.


:- use_module(utils/drs_to_drslist).
:- use_module(prolog/utils/drs_to_drslist).

:- use_module(parser/ace_to_drs).
:- use_module(parser/ape_utils).
:- use_module(parser/tokenizer).
:- use_module(utils/morphgen, [
:- use_module(prolog/parser/ace_to_drs).
:- use_module(prolog/parser/ape_utils).
:- use_module(prolog/parser/tokenizer).
:- use_module(prolog/utils/morphgen, [
acesentencelist_pp/2
]).
:- use_module(utils/is_wellformed, [
:- use_module(prolog/utils/is_wellformed, [
is_wellformed/1
]).
:- use_module(utils/drs_to_ascii).
:- use_module(utils/trees_to_ascii).
:- use_module(utils/drs_to_ace, [
:- use_module(prolog/utils/drs_to_ascii).
:- use_module(prolog/utils/trees_to_ascii).
:- use_module(prolog/utils/drs_to_ace, [
drs_to_ace/2
]).
:- use_module(logger/error_logger, [
:- use_module(prolog/logger/error_logger, [
clear_messages/0,
get_messages/1,
is_error_message/4
Expand All @@ -40,8 +40,8 @@
% Import the lexicons
:- style_check(-singleton).
:- style_check(-discontiguous).
:- use_module(lexicon/clex).
:- use_module(lexicon/ulex).
:- use_module(prolog/lexicon/clex).
:- use_module(prolog/lexicon/ulex).
:- style_check(+discontiguous).
:- style_check(+singleton).

Expand Down Expand Up @@ -102,9 +102,9 @@
call_parser(_, [gr]) :-
style_check(-discontiguous),
style_check(-singleton),
compile('parser/grammar.plp'),
compile('parser/grammar_functionwords.plp'),
compile('parser/grammar_contentwords.plp'),
compile('prolog/parser/grammar.plp'),
compile('prolog/parser/grammar_functionwords.plp'),
compile('prolog/parser/grammar_contentwords.plp'),
style_check(+discontiguous),
style_check(+singleton),
!,
Expand Down Expand Up @@ -180,7 +180,7 @@
%
%
make_ape :-
working_directory(Old, parser),
working_directory(Old, 'prolog/parser'),
compile(fit_to_plp),
working_directory(_, Old),
make.
Expand Down
3 changes: 3 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Introduction
This document explains how to test APE including the various DRS translators
that APE contains.

It is recommended to run `bash rtest.bash` first because it downloads the large
lexicon used by all the test scripts in this directory.


### APE Regression test

Expand Down
1 change: 1 addition & 0 deletions tests/acetexts.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3807,3 +3807,4 @@
text_drs_eval(0, 3776, 'A = 2*3^4^5.', drs([A], [object(A, something, dom, na, na, na)-1/1, formula(A, =, expr(*, int(2), expr(^, expr(^, int(3), int(4)), int(5))))-1/2]), [[specification, [formula, [var, 'A'], =, [expr, [int, 2], [expr, [expr, [int, 3], [int, 4]], [int, 5]]]], '.']], '2013-04-21-23-09-41', '89.206.119.170', '').
text_drs_eval(0, 3777, 'How many beaches have how much sand?', drs([], [question(drs([A, B, C], [query(A, howm)-1/1, object(A, beach, countable, na, geq, 2)-1/3, query(B, howm)-1/5, object(B, sand, mass, na, na, na)-1/7, predicate(C, have, A, B)-1/4]))]), [[query, [question, [np, [qdet, 'how many'], [nbar, [n, beaches]]], [vp, [vbar, [vcompl, [v, have], [np, [qdet, 'how much'], [nbar, [n, sand]]]]]]], ?]], '2013-12-14-11-52-12', '87.64.104.15', '').
text_drs_eval(0, 3778, 'Errol is not Hedwig. Hedwig is not Errol.\nHarryPotter is not NevilleLongbottom. NevilleLongbottom is not HarryPotter.\nNevilleLongbottom is not RonWeasley. RonWeasley is not NevilleLongbottom.\nNevilleLongbottom is not TomRiddle. TomRiddle is not NevilleLongbottom.', drs([], [-drs([A], [predicate(A, be, named('Errol'), named('Hedwig'))-1/2]), -drs([B], [predicate(B, be, named('Hedwig'), named('Errol'))-2/2]), -drs([C], [predicate(C, be, named('HarryPotter'), named('NevilleLongbottom'))-3/2]), -drs([D], [predicate(D, be, named('NevilleLongbottom'), named('HarryPotter'))-4/2]), -drs([E], [predicate(E, be, named('NevilleLongbottom'), named('RonWeasley'))-5/2]), -drs([F], [predicate(F, be, named('RonWeasley'), named('NevilleLongbottom'))-6/2]), -drs([G], [predicate(G, be, named('NevilleLongbottom'), named('TomRiddle'))-7/2]), -drs([H], [predicate(H, be, named('TomRiddle'), named('NevilleLongbottom'))-8/2])]), [[specification, [s, [np, [pname, 'Errol']], [vp, [aux, is, not], [np, [pname, 'Hedwig']]]], '.'], [specification, [s, [np, [pname, 'Hedwig']], [vp, [aux, is, not], [np, [pname, 'Errol']]]], '.'], [specification, [s, [np, [pname, 'HarryPotter']], [vp, [aux, is, not], [np, [pname, 'NevilleLongbottom']]]], '.'], [specification, [s, [np, [pname, 'NevilleLongbottom']], [vp, [aux, is, not], [np, [pname, 'HarryPotter']]]], '.'], [specification, [s, [np, [pname, 'NevilleLongbottom']], [vp, [aux, is, not], [np, [pname, 'RonWeasley']]]], '.'], [specification, [s, [np, [pname, 'RonWeasley']], [vp, [aux, is, not], [np, [pname, 'NevilleLongbottom']]]], '.'], [specification, [s, [np, [pname, 'NevilleLongbottom']], [vp, [aux, is, not], [np, [pname, 'TomRiddle']]]], '.'], [specification, [s, [np, [pname, 'TomRiddle']], [vp, [aux, is, not], [np, [pname, 'NevilleLongbottom']]]], '.']], '2016-01-12-18-23-27', '203.199.213.3', '').
text_drs_eval(1, 3779, 'John likes to eat his own apple.', drs([A, B], [predicate(A, like, named('John'), B)-1/2, B:drs([C, D], [relation(C, of, E)-1/5, object(C, apple, countable, na, eq, 1)-1/7, predicate(D, eat, named('John'), C)-1/4])]), [[specification, [s, [np, [pname, 'John']], [vp, [vbar, [v, likes], to, [vp, [vbar, [vcompl, [v, eat], [np, [posspn, 'his own'], [nbar, [n, apple]]]]]]]]], '.']], '2018-05-31-20-10-18', '84.113.137.30', '"likes to" "his own" together cause the bug').
2 changes: 1 addition & 1 deletion tests/bugs_and_requests.pl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


% We point to the directory where APE modules and the lexicons are located.
:- assert(user:file_search_path(ape, '..')).
:- assert(user:file_search_path(ape, '../prolog')).

% We point to the directory where the regression test set is located.
:- assert(user:file_search_path(rt, '.')).
Expand Down
2 changes: 1 addition & 1 deletion tests/make_acetext_drs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/

% We point to the directory where APE modules and the lexicons are located.
:- assert(user:file_search_path(ape, '..')).
:- assert(user:file_search_path(ape, '../prolog')).

% We point to the directory where the regression test set is located.
:- assert(user:file_search_path(rt, '.')).
Expand Down
4 changes: 1 addition & 3 deletions tests/rtest.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# download the testset manually before running the script (without `d', in this case).

prolog=swipl
#prolog=/usr/local/lib/swipl-6.4.1/bin/x86_64-linux/swipl
#prolog=/opt/local/bin/swipl
#prolog=`which swipl`

#downloader='curl -o'
Expand Down Expand Up @@ -51,7 +49,7 @@ fi
mkdir -p testruns/

# Convert fit-files into plp-files.
$prolog -g "working_directory(_, '../parser'), [fit_to_plp], halt."
$prolog -g "working_directory(_, '../prolog/parser'), [fit_to_plp], halt."

# Run the regression test.
#time echo "[test_ape]. main. halt." | $prolog -q > testruns/rtest_$timestamp.txt
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ape.pl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*/

% We point to the directory where APE modules and the lexicons are located.
:- assert(user:file_search_path(ape, '..')).
:- assert(user:file_search_path(ape, '../prolog')).

% We point to the directory where the regression test set is located.
:- assert(user:file_search_path(rt, '.')).
Expand Down
11 changes: 8 additions & 3 deletions tests/test_drace.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/local/bin/swipl -f none -g test_drace(core) -t halt -s
#!/usr/bin/swipl -f none -g test_drace(core) -t halt -s

/**
* @title Test Drace Core or Drace NP
Expand Down Expand Up @@ -31,10 +31,15 @@
*/

% We point to the directory where APE modules and the lexicons are located.
:- assert(user:file_search_path(ape, '../')).
:- assert(user:file_search_path(ape, '../prolog')).

% We point to the directory where the regression test set is located.
:- assert(user:file_search_path(rt, '.')).

:- compile(acetexts).
% Consult the regression test set.
:- style_check(-singleton).
:- consult(rt(acetexts)).
:- style_check(+singleton).

:- use_module(ape('parser/ace_to_drs'), [
acetext_to_drs/5
Expand Down
12 changes: 9 additions & 3 deletions tests/test_drs_to_x.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/local/bin/swipl -f none -g main -t halt -s
#!/usr/bin/swipl -f none -g main -t halt -s

/**
*
Expand All @@ -15,9 +15,15 @@
*/

% We point to the directory where APE modules and the lexicons are located.
:- assert(user:file_search_path(ape, '../')).
:- assert(user:file_search_path(ape, '../prolog')).

:- compile(acetexts).
% We point to the directory where the regression test set is located.
:- assert(user:file_search_path(rt, '.')).

% Consult the regression test set.
:- style_check(-singleton).
:- consult(rt(acetexts)).
:- style_check(+singleton).

:- use_module(ape('parser/ace_to_drs'), [
acetext_to_drs/5
Expand Down
21 changes: 15 additions & 6 deletions tests/test_duration.pl
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,25 @@
* - benchmark all the main components separately
*/

:- use_module('../parser/ace_to_drs', [
acetext_to_drs/5
]).
% We point to the directory where APE modules and the lexicons are located.
:- assert(user:file_search_path(ape, '../prolog')).

% We point to the directory where the regression test set is located.
:- assert(user:file_search_path(rt, '.')).

:- compile(acetexts).
:- use_module(ape('parser/ace_to_drs'), [
acetext_to_drs/5
]).

:- use_module('../parser/ape_utils', [
cpu_time/2
:- use_module(ape('parser/ape_utils'), [
cpu_time/2
]).

% Consult the regression test set.
:- style_check(-singleton).
:- consult(rt(acetexts)).
:- style_check(+singleton).

% Import the lexicons
:- style_check(-discontiguous).
:- consult(clex:clex_lexicon).
Expand Down
5 changes: 1 addition & 4 deletions tests/test_owlswrl.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
% $ swipl -f none -g main -t halt -s test_owlswrl.pl
% Writes the test results into STDIN and statistics into STDERR.

:- assert(user:file_search_path(ape, '../')).
:- assert(user:file_search_path(ape, '../prolog')).

:- use_module(ape('parser/ace_to_drs'), [
acetext_to_drs/5
Expand All @@ -29,9 +29,6 @@
read_ulex/1
]).




:- set_prolog_flag(float_format, '%.11g').

t('1-1', 'Every man is a human.').
Expand Down
Loading

0 comments on commit 00fb91d

Please sign in to comment.