1
votes

I'm trying to write a simple translation script, but the file's getting rather... long and confusing, mostly because I've stored all the translations at the end of the file. They're in the format verb(English, Finnish).

I'm wondering if there's any way to store those in a different file, so I don't need to deal with them. I've looked into using the consult predicate, but I don't think that does exactly what I need. Is there any way to do this in SWI-prolog?

For the record, if I use the consult predicate, I get this error message:

If I try using the consult predicate, though, I get this error:

Warning: The predicates below are not defined. If these are defined
Warning: at runtime using assert/1, use :- dynamic Name/Arity.
Warning: 
Warning: verb/2, which is referenced by
Warning:        c:/users/grant/documents/prolog/string_dictionary.pl:6:8: 1-st clause of translate_word/2
2

2 Answers

1
votes

you can use the directive multifile, together with consult/1 or include/1, but I would recommend instead to switch to modules. A bit more work, rewarding with better maintenance and support.

Add at top of verb file the declarations

:- module(verbs, [verb/2]).

and then in your translation script add

:- use_module(verbs).
0
votes

I think consult/1 is what you need.

Just put your verb facts (btw, why is Verb capitalized in your question? Facts and rules names can't start with capital letters) into separate file and consult that file in your main Prolog file.