contents index next

8. List of Predicates

This chapter lists the important predicates used in Hdrug.

8.1. concat(Atom,Atom,Atom)

Two of the three arguments must be Prolog atoms. The print-name of the third atom is the concatenation of the print names of the first two atoms. Examples:

| ?- concat(foo,bar,X).
X = foobar ?
yes
| ?- concat(X,bar,foobar).
X = foo ?
yes
| ?- concat(foo,X,foobar).
X = bar ?

8.2. concat_all(+ListOfAtoms,?Atom[,+Atom])

concetenates the print names of all the atoms in ListOfAtoms together; possibly using the optional third argument as a seperator. Example:

?- concat_all([foo,bar,foo,bar],L,'+').
L = 'foo+bar+foo+bar' ?

8.3. between(+Lower, +Upper, ?Number[, +/-])

Is true when Lower, Upper, and Number are integers, and Lower =< Number =< Upper. If Lower and Upper are given, Number can be tested or enumerated. If either Lower or Upper is absent, there is not enough information to find it, hence failure. Numbers are generated in ascending order. If you want descending order, use between/4. The optional fourth argument is the atom + to indicate ascending order, or

?- findall(X,between(1,10,X), Xs).
Xs = [1,2,3,4,5,6,7,8,9,10] ?
?- findall(X,between(1,10,X,-), Xs).
Xs = [10,9,8,7,6,5,4,3,2,1] ?

8.4. atom_term(+Atom,?Term).

Atom is read-in as if it where a Prolog term. Example:

| ?- atom_term('f(A,B,A)',L).
L = f(_A,_B,_A) ?

8.5. term_atom(+Term,?Atom).

The Prolog term Term is turned into an atom, as if quotes were placed around it. Example:

| ?- term_atom(f(f(f(f))),L).
L = 'f(f(f(f)))' ?

As is clear from the following example, the result is arbitrary in case Term contains variables:

?- term_atom(f(_A,_B,_A),L).
L = 'f(_83,_105,_83)' ?

8.6. gen_sym(-Atom[,+Prefix])

A new atom Atom is generated. If Prefix is specified, then the print name of Atom will start with Prefix.

8.7. report_count_edges_pred(:Spec)

Writes to standard output the number of times :Spec succeeds. Example:

| ?- report_count_edges_pred(library_directory/1).
library_directory/1: 2

8.8. report_count_edges(:Goal)

Writes to standard output the number of times :Goal succeeds. Example:

| ?- report_count_edges(lists:member(_,[a,b,c,d])).
lists:member(_95,[a,b,c,d]) : 4

8.9. count_edges(:Goal,?Int)

Int is an integer indicating the number of times Goal succeeds.

8.10. debug_call(+Int,:Goal)

If Int is smaller or equal to the current value of flag(debug), then Goal is called. Used to wrap around debugging and continuation calls. Larger values for Int indicate that the goal is executed less often.

8.11. debug_message(+Int,+FormatStr,+FormatArgs)

If Int is smaller or equal to the current value of flag(debug), then the goal format(user_error,FormatStr,FormatArgs) is executed.

8.12. initialize_flag(+Flag,?Val)

Hdrug manages a number of global variables, called flags. This predicate sets flag Flag to Val only if Flag is currently undefined.

8.13. set_flag(+Flag,?Val)

Hdrug manages a number of global variables, called flags. This predicate sets flag Flag to Val.

8.14. flag(+Flag[,?OldVal[,?NewVal]])

Hdrug manages a number of global variables, called flags. This predicate sets flag Flag to NewVal, unifying the old value with OldVal. If only two arguments are given, then the flag is unchanged. If only a single argument is given, then Flag is allowed to be uninstantiated. It will be bound to all existing flags upon backtracking.

8.15. un_prettyvars(+Term0,?Term)

Reverses the effect of prettyvars; i.e. all '$VAR'/1 terms are replaced by corresponding variables.

8.16. prettyvars(?Term)

Similar to the built-in numbervars, except that all variables which only occur once in Term are replaced by '$VAR'('_').

8.17. prolog_conjunction(Conjunction, ListOfConjuncts)

handles the syntax of conjuncts. This code wraps call(_) around variables, flattens conjunctions to (A;(B;(C;(D;E)))) form, and drops 'true' conjuncts.

8.18. prolog_disjunction(Disjunction,ListOfDisjuncts)

handles the syntax of disjuncts. This code wraps call(_) around variables, flattens disjunctions to (A,(B,(C,(D,E)))) form, and drops 'false' disjuncts.

8.19. try_hook(:Goal[,:Goal])

Tries to call Goal, but only if the predicate is known to exist. If the first Goal fails, or if it does not exist, then the second goal is called. If no second goal is given then the predicate succeeds.

8.20. hook(:Goal).

hook/1 calls its argument, but only if it is defined; if it is not defined the precate fails. Useful to call optional hook predicates for which no undefined predicate warnings should be produced.

8.21. if_gui(:Goal[,:AltGoal])

calls Goal only if graphical user interface is currently running; if not the predicate calls AltGoal, if it is specified, or succeeds

8.22. r

Starts the command interpreter.

8.23. start_x

Attempts to start the graphical user interface, but will not start it if flag(tcltk) is switched off

8.24. update_array(+List,+ArrayName)

a Tcl array named ArrayName is constructed where the values in List are to be the values in the array, i.e. ArrayName(1), ArrayName(2), etc.; the special value ArrayName(max) is set to the last index of the array (counting starts at 0). The flag update_array_max can be used to pass to Tcl only the first N items. If that value is 0 then all items are passed on (default=1000).

8.25. tk_fs(+Term)

Term is displayed as a feature-structure on the canvas widget of the graphical user interface

8.26. tk_fs(List)

Each Term in List is displayed as a feature-structure on the canvas widget of the graphical user interface

8.27. tk_term(?Term)

Term is displayed on the canvas of the graphical user interface

8.28. tcl_eval(+Cmd[,-Return])

Abbrevation for the tcltk library predicate tcl_eval/3. The current TclTk interpreter, accessible through the tcl_interp flag, is added as the first argument.

8.29. tcl(+Expr[,+Subs[,-ReturnAtom]])

Expr is a string as accepted as the second argument of format/3; the optional Subs is equivalent to the third argument of format/3. After evaluating the meta-charcters in Expr, the string is sent as a tcl command using the current tcl interpreter (flag tcl_interp). The return string is turned into an atom and available in the optional third argument.

8.30. show_object_no(+No,+Style,+Output)

Displays the object numbered No using the Style and Output. These latter two arguments are of the type accepted by the first and second argument of the generic show/3 predicate.

8.31. show(+Style,+Medium,+Things)

Generic interface to the Hdrug visualization tools. Style is one of:

words (only defined for object/2 things; displays the phonological representation of an object, i.e. Phon in object(Ident,o(Cat,Phon,Sem))

sem (only defined for object/2 things; displays the semantic representation of an object, i.e. Sem in object(Ident,o(Cat,Phon,Sem))

fs(+Path) (extracts the feature structure at path Path; and displays the result as a feature structure in matrix notation. In such a Path the prefix might consist of integers to refer to daughters in a tree/3 tree structure; 0 is the root node of a local tree.)

fs (feature structure in matrix notation)

term(print) output as a Prolog term, using print where appropriate (in order that any application-specific portray/1 hook predicates will be applicable)

term(write) same as term(print), but not using print.

tree(Format) displays as a tree using Format as the relevant tree-format. Such a tree-format is defined by clauses for the hook predicates graphic_path, graphic_daughter and graphic_label.

Medium is one of:

user (normal text to SICStus Prolog standard output).

tk (on a canvas of the graphical user interface).

latex (latex code is input to latex and either xdvi or dvips followed by ghostview).

clig (using the CLiG system).

dot

and Things is a list where each element is one of:

object(Ident,o(Cat,Words,Sem))

value(Term)

clause(Head,Body), Body a list of goals.

8.32. hdrug_latex:latex_tree(+TreeFormat,+Term)

Displays Term as a tree according to the TreeFormat specifications, in Ghostview. This predicate produces LaTeX code (with PsTricks extensions); it runs LaTeX and dvips on the result. The TreeFormat should be specified by means of clauses for the hook predicates graphic_path, graphic_daughter and graphic_label.

8.33. hdrug_latex:latex_tree(+TreeFormat,+ListOfTerms)

Displays each Term in ListOfTerms as a tree according to the TreeFormat specifications, in Ghostview. This predicate produces LaTeX code (with PsTricks extensions); it runs LaTeX and dvips on the result. The TreeFormat should be specified by means of clauses for the hook predicates graphic_path, graphic_daughter and graphic_label.

8.34. hdrug_latex:latex_fs(+Term)

Displays Term as a feature structure in Xdvi. The predicate produces LaTeX code (using Chris Manning's avm macro's); it runs LaTeX and xdvi on the result.

8.35. hdrug_latex:latex_fs_list(+List)

Displays each Term in List as a feature structure in Xdvi. The predicate produces LaTeX code (using Chris Manning's avm macro's); it runs LaTeX and xdvi on the result.

8.36. hdrug_latex:latex_term(+Term)

Displays Term in Xdvi. The predicate produces LaTeX code; it runs LaTeX and xdvi on the result.

8.37. hdrug_latex:latex_term_list(+List)

Displays each Term in List in Xdvi. The predicate produces LaTeX code; it runs LaTeX and xdvi on the result.

8.38. generate(Sem)

generates from the semantic representation Sem. Sem is first filtered through the hook predicate extern_sem.

8.39. parse(Phon)

parses from the phonological representation Phon; typically Phon is a list of atoms, refer to the extern_phon hook predicate for more complex possibilities.

8.40. generate_obj_no(Integer)

generated from the semantic representation of object Integer. Only the semantic representation of that object is passed to the generator.

8.41. available

Lists all available parsers and generators, and their associated activity status. During parser comparison and generator comparison, only those parsers and generators are compared which are currenly active.

8.42. object(No,Object)

Results of parsing and generation are normally added to the database. This predicate can be used to fetch such an object. The first argument is an integer used as the key of the object, the second argument is a triple o(Cat,Phon,Sem).

8.43. reset_table / reset_table(ParGen)

Without an argument, removes all results of parser comparison and generator comparison runs. With an argument, only remove information concerning that particular parser or generator.

8.44. parser_comparisons / parser_comparisons(Keys)

Without arguments, compares active parsers on all sentences in test suite. With an argument, Keys is a list of keys which relate to the first argument of the sentence hook predicate. The active parsers will be compared on sentences with a matching key.

8.45. generator_comparisons / generator_comparisons(Keys)

Without arguments, compares active generators for all logical forms of test suite. With an argument, Keys is a list of keys which relate to the first argument of the lf hook predicate. Only the logical forms with a matching key are compared.

8.46. sentences

lists all sentences in test-suite

8.47. lfs

lists all logical forms in test-suite

8.48. parse_compare(Sentence)/parse_compare(Max,Sentence)

Compares active parsers on Sentence. In the binary format, Max is an integer indicating the maximum amount of msec.

8.49. generate_compare(Lf)/generate_compare(Max,Lf)

Compares active generators on Lf. In the binary format, Max is an integer indicating the maximum amount of msec.

8.50. compile_user_clause[(Module)]

This predicate will construct Module:user_clause/2 definitions based on the available Module:clause/2 clauses (if no Module is specified, user is assumed). In the body of these clauses feature constraints are expanded out. The user_clause predicate is used for graphical display of predicates defined in the grammar. So you have to add a (typically multifile) predicate user:user_clause(A,B) :- Module:user_clause(A,B) for each Module.

contents index next