34 using std::placeholders::_1;
62 if (isnil(arg)) arg =
Cmdline (
"normaliseID extractID removeTerm countPred");
64 if (contains (arg,
"normaliseID")) check_normaliseID();
65 if (contains (arg,
"extractID" )) check_extractID ();
66 if (contains (arg,
"removeTerm" )) check_removeTerm ();
67 if (contains (arg,
"countPred" )) check_countPred ();
76 Cmdline tokens (
"a A AA dufte 1a _1 A_A BÄH");
77 tokens.push_back (
"");
78 tokens.push_back (
" White \t space ");
79 tokens.push_back (
"§&Ω%€GΩ%€ar ☠☠☠ baäääääge!!!!! ");
81 cout <<
"..original : "<<tokens<<
" :"<<endl;
85 cout <<
"normalised : "<<tokens<<
" :"<<endl;
94 CHECK (
"tok" ==
extractID (
"pred",
"pred(tok)." ));
95 CHECK (
"tok" ==
extractID (
"pred",
" pred( tok )" ));
96 CHECK (
"tok" ==
extractID (
"pred",
"pred(tok), pred(tux)." ));
97 CHECK (
"tok" ==
extractID (
"pred",
"other(xyz) pred(tok) pred(tux)" ));
98 CHECK (
"tok" ==
extractID (
"pred",
"some( pred(tok)" ));
100 CHECK (isnil (
extractID (
"pred",
"pred (tok)")));
101 CHECK (isnil (
extractID (
"pred",
"pred tok)" )));
102 CHECK (isnil (
extractID (
"pred",
"pred(tok " )));
112 CHECK_removeTerm (
"pred",
"pred(tok).",
"pred(tok)",
"." );
113 CHECK_removeTerm (
"pred",
" pred( tok )",
"pred(tok)",
" " );
114 CHECK_removeTerm (
"pred",
"pred(tok), pred(tux).",
"pred(tok)",
"pred(tux)." );
115 CHECK_removeTerm (
"pred",
"other(xyz) pred(tok) pred(tux)",
"pred(tok)",
"other(xyz) pred(tux)" );
116 CHECK_removeTerm (
"pred",
"some( pred(tok)",
"pred(tok)",
"some( " );
119 CHECK_removeTerm (
"pred",
"pred (tok",
"",
"pred (tok" );
120 CHECK_removeTerm (
"pred",
"pred tok)",
"",
"pred tok)" );
121 CHECK_removeTerm (
"pred",
"pred(tok",
"",
"pred(tok" );
125 CHECK_removeTerm (
Symbol sym,
string input,
string extracted,
string modified)
128 CHECK (modified == input);
139 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)
Simplistic 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