43 using std::placeholders::_1;
71 if (isnil(arg)) arg =
Cmdline (
"normaliseID extractID removeTerm countPred");
73 if (contains (arg,
"normaliseID")) check_normaliseID();
74 if (contains (arg,
"extractID" )) check_extractID ();
75 if (contains (arg,
"removeTerm" )) check_removeTerm ();
76 if (contains (arg,
"countPred" )) check_countPred ();
85 Cmdline tokens (
"a A AA dufte 1a _1 A_A BÄH");
86 tokens.push_back (
"");
87 tokens.push_back (
" White \t space ");
88 tokens.push_back (
"§&Ω%€GΩ%€ar ☠☠☠ baäääääge!!!!! ");
90 cout <<
"..original : "<<tokens<<
" :"<<endl;
94 cout <<
"normalised : "<<tokens<<
" :"<<endl;
103 CHECK (
"tok" ==
extractID (
"pred",
"pred(tok)." ));
104 CHECK (
"tok" ==
extractID (
"pred",
" pred( tok )" ));
105 CHECK (
"tok" ==
extractID (
"pred",
"pred(tok), pred(tux)." ));
106 CHECK (
"tok" ==
extractID (
"pred",
"other(xyz) pred(tok) pred(tux)" ));
107 CHECK (
"tok" ==
extractID (
"pred",
"some( pred(tok)" ));
109 CHECK (isnil (
extractID (
"pred",
"pred (tok)")));
110 CHECK (isnil (
extractID (
"pred",
"pred tok)" )));
111 CHECK (isnil (
extractID (
"pred",
"pred(tok " )));
121 CHECK_removeTerm (
"pred",
"pred(tok).",
"pred(tok)",
"." );
122 CHECK_removeTerm (
"pred",
" pred( tok )",
"pred(tok)",
" " );
123 CHECK_removeTerm (
"pred",
"pred(tok), pred(tux).",
"pred(tok)",
"pred(tux)." );
124 CHECK_removeTerm (
"pred",
"other(xyz) pred(tok) pred(tux)",
"pred(tok)",
"other(xyz) pred(tux)" );
125 CHECK_removeTerm (
"pred",
"some( pred(tok)",
"pred(tok)",
"some( " );
128 CHECK_removeTerm (
"pred",
"pred (tok",
"",
"pred (tok" );
129 CHECK_removeTerm (
"pred",
"pred tok)",
"",
"pred tok)" );
130 CHECK_removeTerm (
"pred",
"pred(tok",
"",
"pred(tok" );
134 CHECK_removeTerm (
Symbol sym,
string input,
string extracted,
string modified)
137 CHECK (modified == input);
148 for (uint i=1; i <= 30; ++i)
Utilities to support working with predicate queries.
uint countPred(const string &q)
count the top-level predicates in the query string.
void normaliseID(string &id)
ensure standard format for a given id string.
Implementation namespace for support and library code.
string extractID(Symbol sym, const string &termString)
(preliminary) helper: instead of really parsing and evaluating the terms, just do a regular expressio...
Token or Atom with distinct identity.
Class to encapsulate the typical C-style commandline definition.
string garbage_query(int degree=0)
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
string removeTerm(Symbol sym, string &queryString)
(preliminary) helper: cut a term with the given symbol.
diagnostic helpers to support test related to predicate queries
void for_each(CON const &elements, FUN function, P1 &&bind1, ARGS &&...args)
Accept binding for arbitrary function arguments.
Perform operations "for each element" of a collection.
Abstraction of the usual int argc, int** argv-Commandline, to be able to treat it as a vector of stri...
bool contains(SEQ const &cont, typename SEQ::const_reference val)
shortcut for brute-force containment test in any sequential container