1% =================================================================== 2% File 'logicmoo_util_strings.pl' 3% Purpose: Common Logicmoo library Functions for Strings 4% Maintainers: Douglas Miles/Annie Ogborn/Kino Coursey 5% Contact: $Author: logicmoo@gmail.com; 6% Version: 'logicmoo_util_strings.pl' 1.0.0 7% Revision: $Revision: 1.7 $ 8% Revised At: $Date: 2021/07/11 21:57:28 $ 9% =================================================================== 10 11% File: /opt/PrologMUD/pack/logicmoo_base/prolog/logicmoo/util/logicmoo_util_strings.pl 12 13:- module(logicmoo_util_strings, 14 [ addSpaceBeforeSym/2, 15 all_upper_atom/1, 16 isSlot/1, 17 any_to_atom/2, 18 any_to_string/2, 19 any_to_string1/2, 20 any_to_string_or_var/2, 21 append_ci/3, 22 append_ci0/3, 23 any_to_charlist/2, 24 as_atom/2, 25 as_nc_str/2, 26 atomSplit/2, 27 atomSplit/3, 28 get_text_restore_pred/2, 29 atomSplit2_unused/3, 30 atomSplitEasy_unused/2, 31 atom_contains/2, 32 atom_subst/4, 33 atomic_concat/4, 34 atomic_list_concat_catch/3, 35 atomic_list_concat_safe/2, 36 atomic_list_concat_safe/3, 37 atomsSameCI/2, 38 atoms_of/2, 39 both_empty/2, 40 breaked_codes/2, 41 camelSplitters/1, 42 capitalized/1, 43 catch_read_term_from_atom/3, 44 char_type_this/2, 45 clean_codes/2, 46 clean_out_atom/2, 47 concat_atom_safe/2, 48 concat_atom_safe/3, 49 convert_members/3, 50 convert_to_string/2, 51 convert_to_cycString/2, 52 convert_to_s_string/2, 53 convert_to_sel_string/5, 54 is_s_string/1, 55 delistify_single_element/2, 56 ctype_continue/3, 57 ctype_switch/2, 58 ctype_switcher/1, 59 destringify/2, 60 dehyphenize_const/2, 61 divide_list/3, 62 either_empty/2, 63 either_starts_with_icase/2, 64 empty_str/1, 65 empty_string/1, 66 ends_with_icase/2, 67 equals_icase/2, 68 escapeCodes/4, 69 escapeString/2, 70 first_char_to_lower/2, 71 first_char_to_upper/2, 72 hide_char_type/1, 73 interleave/3, 74 isWhitespace/1, 75 is_charlist/1, 76 is_codelist/1, 77 is_ending/1, 78 is_ftString2/1, 79 is_simple_split/1, 80 list_replace/4, 81 longest_string/3, 82 ltrim/2, 83 map_tree_to_list/3, 84 must_assign/1, 85 must_assign/2, 86 any_to_codelist/2, 87 member_ci/2, 88 merge_vars/3, 89 must_nonvar/1, 90 noCaseChange/1, 91 non_empty/1, 92 ommitable/1, 93 quoteAtomString/2, 94 read_stream_to_arglist/2, 95 rejoined/3, 96 remove_predupes/2, 97 replace_in_string/3, 98 replace_in_string/4, 99 replace_in_string/5, 100 replace_periods/2, 101 replace_periods_string_list/2, 102 sort_by_strlen/2, 103 starts_or_ends_with_icase/2, 104 convert_to_string_list/2, 105 convert_to_atoms_list/2, 106 107 starts_with_icase/2, 108 str_contains_all/2, 109 str_contains_all0/2, 110 stringToCodelist/2, 111 stringToCodelist2/2, 112 stringToList/2, 113 string_ci/2, 114 string_dedupe/2, 115 string_equal_ci/2, 116 string_equal_ci0/2, 117 string_equal_ci1/2, 118 string_to_atom_safe/2, 119 text_to_string_safe/2, 120 toCamelcase/2, 121 toCase/3, 122 toCaseSplit/4, 123 toLowercase/2, 124 toPropercase/2, 125 toUppercase/2, 126 to_case_breaks/2, 127 to_case_break_atoms/2, 128 to_case_breaks/5, 129 to_first_break/2, 130 to_first_break/5, 131 to_first_break_w/6, 132 to_list_of_sents/2, 133 to_titlecase/2, 134 to_word_list/2, 135 unused_to_word_list_0/2, 136 unused_to_word_list_2/2, 137 trim/2, 138 trim2/2, 139 unCamelcase/2, 140 unquoteAtom/2, 141 vars_to_ucase/2, 142 vars_to_ucase_0/2 143 ]).
149% autoloading user:portray_clause_pi/2 from /opt/PrologMUD/pack/logicmoo_base/prolog/logicmoo/util/logicmoo_util_first 150:- multifile 151 double_quotes_was_strings/1, 152 %string_predicate/1, 153 to_string_hook/3. 154:- meta_predicate 155 map_tree_to_list( , , ), 156 toCase( , , ), 157 toCaseSplit( , , , ). 158:- module_transparent % (module_transparent) :- 159 addSpaceBeforeSym/2, 160 all_upper_atom/1, 161 any_to_atom/2, 162 any_to_string/2, 163 any_to_string1/2, 164 any_to_string_or_var/2, 165 append_ci/3, 166 append_ci0/3, 167 as_atom/2, 168 as_nc_str/2, 169 atomSplit/2, 170 atomSplit/3, 171 atomSplit2_unused/3, 172 atomSplitEasy_unused/2, 173 atom_contains/2, 174 atom_subst/4, 175 atomic_concat/4, 176 atomic_list_concat_catch/3, 177 atomic_list_concat_safe/2, 178 atomic_list_concat_safe/3, 179 atomsSameCI/2, 180 atoms_of/2, 181 both_empty/2, 182 breaked_codes/2, 183 camelSplitters/1, 184 capitalized/1, 185 catch_read_term_from_atom/3, 186 char_type_this/2, 187 clean_codes/2, 188 clean_out_atom/2, 189 concat_atom_safe/2, 190 concat_atom_safe/3, 191 convert_to_string/2, 192 ctype_continue/3, 193 ctype_switch/2, 194 ctype_switcher/1, 195 destringify/2, 196 divide_list/3, 197 double_quotes_was_strings/1, 198 either_empty/2, 199 either_starts_with_icase/2, 200 empty_str/1, 201 empty_string/1, 202 ends_with_icase/2, 203 equals_icase/2, 204 escapeCodes/4, 205 escapeString/2, 206 first_char_to_lower/2, 207 first_char_to_upper/2, 208 hide_char_type/1, 209 interleave/3, 210 isWhitespace/1, 211 is_charlist/1, 212 is_codelist/1, 213 is_ending/1, 214 is_ftString2/1, 215 is_simple_split/1, 216 list_replace/4, 217 longest_string/3, 218 ltrim/2, 219 member_ci/2, 220 merge_vars/3, 221 must_nonvar/1, 222 noCaseChange/1, 223 non_empty/1, 224 ommitable/1, 225 quoteAtomString/2, 226 read_stream_to_arglist/2, 227 rejoined/3, 228 remove_predupes/2, 229 replace_in_string/4, 230 replace_in_string/5, 231 replace_periods/2, 232 replace_periods_string_list/2, 233 sort_by_strlen/2, 234 splt_words/3, 235 splt_words_0/3, 236 splt_words_0_atom/3, 237 starts_or_ends_with_icase/2, 238 starts_with_icase/2, 239 str_contains_all/2, 240 str_contains_all0/2, 241 stringToCodelist/2, 242 stringToCodelist2/2, 243 stringToList/2, 244 string_ci/2, 245 string_dedupe/2, 246 string_equal_ci/2, 247 string_equal_ci0/2, 248 string_equal_ci1/2, 249 string_to_atom_safe/2, 250 text_to_string_safe/2, 251 toCamelcase/2, 252 toLowercase/2, 253 toPropercase/2, 254 toUppercase/2, 255 to_case_breaks/2, 256 to_case_breaks/5, 257 to_first_break/2, 258 to_first_break/5, 259 to_first_break_w/6, 260 to_list_of_sents/2, 261 to_string_hook/3, 262 to_titlecase/2, 263 to_word_list/2, 264 unused_to_word_list_0/2, 265 unused_to_word_list_2/2, 266 trim/2, 267 trim2/2, 268 unCamelcase/2, 269 unquoteAtom/2, 270 vars_to_ucase/2, 271 vars_to_ucase_0/2. 272 273:- dynamic % (dynamic) :- 274 275 double_quotes_was_strings/1, 276 to_string_hook/3. 277 278 279%:- user:use_module(library('file_scope')). 280 281 282:- meta_predicate toCase( , , ). 283:- meta_predicate toCaseSplit( , , , ). 284 285:- set_module(class(library)). 286:- autoload(library(memfile),[memory_file_to_atom/2,atom_to_memory_file/2,open_memory_file/3]). 287 288% % % OFF :- system:use_module(library(apply)). 289% % % OFF :- system:use_module(library(check)). 290% % % OFF :- system:use_module(library(must_sanity)). 291% % % OFF :- use_module(library(check),[check:string_predicate/1]). 292 293% this is a backwards compatablity block for SWI-Prolog 6.6.6 294:- multifile(double_quotes_was_strings/1). 295:- dynamic(double_quotes_was_strings/1). 296:- current_prolog_flag(double_quotes,WAS),asserta(double_quotes_was_strings(WAS)). 297:- retract(double_quotes_was_strings(WAS)),set_prolog_flag(double_quotes,WAS). 298:- current_prolog_flag(double_quotes,WAS),asserta(double_quotes_was_strings(WAS)). 299:- set_prolog_flag(double_quotes,string). 300 301% :-import(must/1). 302 303 304atom_concat_or_rtrace(X,Y,Z):- tracing->atom_concat(X,Y,Z);catch(atom_concat(X,Y,Z),_,break). 305:- export(atom_concat_or_rtrace/3). 306%:- reexport(library(logicmoo/pretty_clauses)). 307 308get_text_restore_pred(Text,any_to_string):- string(Text),!. 309get_text_restore_pred(Text, any_to_atom):- atom(Text),!. 310get_text_restore_pred(Text,any_to_charlist):- is_charlist(Text),!. 311get_text_restore_pred(Text,any_to_codelist):- is_codelist(Text),!. 312get_text_restore_pred(Text,any_to_codelist):- Text==[],!. 313get_text_restore_pred(_,any_to_string). 314 315%=
321any_to_string(Atom,String):- any_to_string1(Atom,StringS),!,StringS=String. 322% any_to_string(Atom,String):- with_err_to_pred(nop, (must(any_to_string1(Atom,StringS)),!,must(StringS=String))),!. 323 324maybe_keep_postion(Stream,Goal):- 325 setup_call_cleanup( 326 stream_property(Stream,position(Pos)), 327 Goal, 328 (stream_property(Stream,reposition(true))->set_stream_position(Stream,Pos);true)). 329 330%=
336any_to_string1(Atom,String):- atomic(Atom),is_stream(Stream), 337 stream_property(Stream,reposition(true)),!, 338 maybe_keep_postion(Stream,read_stream_to_codes(Stream,Codes)),!,any_to_string1(Codes,String). 339any_to_string1(Atom,String):- atomic(Atom),is_stream(Stream), maybe_keep_postion(Stream,read_stream_to_codes(Stream,Codes)),!,any_to_string1(Codes,String). 340any_to_string1(Atom,String):- var(Atom),show_call((term_string(Atom,String))),!. 341any_to_string1(Atom,String):- var(Atom),!,=(Atom,String). 342any_to_string1(Atom,String):- string(Atom),!,Atom=String. 343any_to_string1(Atom,String):- is_s_string(Atom),!,convert_to_string(Atom,String). 344%any_to_string1(_,_):- stack_depth(X),X>2000,!,sanity(fail),fail. 345any_to_string1(s(Atom),String):- !, any_to_string1(Atom,String). 346% any_to_string1(Atom,String):- is_string(Atom),!,text_to_string(String). 347 348any_to_string1(Atom,String):- number(Atom),!,number_string(Atom,String). 349any_to_string1(Atom,String):- atomic(Atom),!,convert_to_string(Atom,String),!. 350any_to_string1(Empty,""):- empty_str(Empty),!. 351 352any_to_string1(string(Atom),String):- !, any_to_string1(Atom,String). 353any_to_string1(atom(Atom),String):- !, any_to_string1(Atom,String). 354any_to_string1(text(Atom),String):- !, any_to_string1(Atom,String). 355any_to_string1(fmt(Fmt,Args),String):-!,must(sformat(String,Fmt,Args)). 356any_to_string1(txtFormatFn(Fmt,Args),String):-!,must(sformat(String,Fmt,Args)). 357% any_to_string1([Atom],String):- !, any_to_string1(Atom,String). 358any_to_string1(List,String):- text_to_string_safe(List,String),!. 359any_to_string1(List,String):- is_list(List),!,must_maplist(any_to_string1,List,StringList), 360 must(atomics_to_string(StringList, ' ', String)),!. 361any_to_string1(List,String):- on_x_debug(format(string(String),'~w',[List])). 362 363 364/* 365any_to_string1(Term,String):- show_call(on_x_debug(term_string(Term,String))). 366any_to_string1(List,String):- on_x_debug(format(string(String),'~p',[List])). 367any_to_string1(List,String):- format(string(String),'~q',[List]). 368*/ 369/* 370list_to_atomics_list0(Var,A):-var(Var),!,any_to_string(Var,A),!. 371list_to_atomics_list0([E|EnglishF],[A|EnglishA]):- 372 any_to_string(E,A), 373 list_to_atomics_list0(EnglishF,EnglishA),!. 374list_to_atomics_list0([],[]):-!. 375*/ 376 377maplist_atom_string(M,O):- notrace(catch(maplist(any_to_string,M,O),_,fail)). 378 379text_to_uq_atom(A,InOut):- (atom_concat('"',R,A),atom_concat(Sub,'"',R))->Sub=InOut;A=InOut. 380 381will_mws(Wff0):- atomic(Wff0),atom_length(Wff0,L),L>2,atom_contains(Wff0,' '). 382 383is_s_string(I):-compound(I),functor(I,s,_),!. 384 385:- thread_local(t_l:no_cycstrings/0). 386 387convert_to_cycString(I,O):- t_l:no_cycstrings,!,any_to_string(I,O). 388%convert_to_cycString(I,O):- is_s_string(I),!,O=I. 389convert_to_cycString(I,O):- convert_to_string_list(I,M),delistify_single_element(M,O). 390 391 392convert_to_s_string(I,O):- convert_to_sel_string(fail,=,sl,I,O). 393 394/* 395 "Hi there" 396 s("Hi",there). 397 s('Hi',there). 398 s(['Hi',there]). 399 400 401 convert_to_sel_string(=,a,=,"Hi there",O). 402 [hi,there] 403 convert_to_sel_string(=,a,=,["Hi"],O). 404 405 convert_to_sel_string(fail,=,s,"Hi there",O). 406 407 s(hi). 408 s([hi]). 409 410 s(hi,there). 411 s([hi,there]). 412 413 414*/ 415 416convert_to_sel_string(_,_,_,I,O):- notrace(is_ftVar(I)),!,O=I. 417convert_to_sel_string(S,a,L,I,O):- !, quietly(must((convert_to_atoms_list(I,M),must_maplist(any_to_atom,M,MM),to_sel_string(S,a,L,MM,O)))),!. 418convert_to_sel_string(S,s,L,I,O):- !, quietly(must((convert_to_string_list(I,M),must_maplist(any_to_string,M,MM),to_sel_string(S,s,L,MM,O)))),!. 419convert_to_sel_string(S,E,L,I,O):- quietly((convert_to_atoms_list(I,SL),must_maplist(E,SL,M),to_sel_string(S,E,L,M,O))),!. 420 421 422to_sel_1e_string(sf,M,s(O)):-!,M=O. 423to_sel_1e_string(l,M,[O]):-!,M=O. 424to_sel_1e_string(sl,M,s([O])):-!,M=O. 425to_sel_1e_string(=,M,O):-!,M=O. 426to_sel_1e_string(U,M,O):- must(call(call,U,M,O)). 427 428to_sel_string(S,a,_,[],O):- !,to_sel_1e_string(S,'',O),!. 429to_sel_string(S,s,_,[],O):- !,to_sel_1e_string(S,"",O),!. 430to_sel_string(S,_,_,[],O):- S\==fail,!, M=[], to_sel_1e_string(S,M,O). 431to_sel_string(S,_,_,[M],O):- S\==fail,!, to_sel_1e_string(S,M,O). 432to_sel_string(_,_,sf,M,O):-!,must((O=..[s|M])). 433to_sel_string(_,_,l,M,O):- !,M=O. 434to_sel_string(_,_,sl,M,s(O)):- !,M=O. 435to_sel_string(_,_,L,M,O):- must(call(call,L,M,O)). 436 437 438convert_to_string(I,O):- string(I),!,O=I. 439convert_to_string(I,O):- catch((convert_to_atoms_list(I,M),joined_string(M,O)),_,fail),!. 440convert_to_string(I,O):- sformat(O,'~w',[I]). 441 442 443convert_to_string_list(I,O):-string(I),(atom_contains(I,'\n');atom_contains(I,'*')),!,O=[I]. 444convert_to_string_list(I,O):-convert_to_atoms_list(I,M),maplist_atom_string(M,O),!. 445 446convert_to_atoms_list(A,B):- is_ftVar(A),!,A=B. 447convert_to_atoms_list(I,O):- is_s_string(I),I=..[s,E|M],!,must_maplist(convert_to_string,[E|M],O),!. 448convert_to_atoms_list([A|AA],B):- []==AA,!,convert_to_atoms_list(A,B),!. 449convert_to_atoms_list(A,B):- convert_to_string_m(A,M),!,listify(M,B),!. 450convert_to_atoms_list(A,B):- listify(A,B),nop(dmsg(convert_to_atoms_list(A,B))),!. 451 452convert_to_string_m([A|AA],O):- []==AA,!,convert_to_string_m(A,B),break_string(B,O),!. 453convert_to_string_m(A,O):- catch(text_to_string(A,M),_,fail),!,break_string(M,O),!. 454convert_to_string_m(A,O):- is_list(A),catch(atomics_to_string(A," ",B),_,fail),!,break_string(B,O),!. 455convert_to_string_m(A,B):- catch(atom_length(A,L),_,fail),convert_to_atoms_by_len(A,L,B),!. 456convert_to_string_m(A,B):- break_string(A,B),!. 457convert_to_string_m(M,M). 458 459% >- do_renames(textCached([']'], [txt, s(a,b,c)]),O). 460 461 462break_string(A,O):- is_ftVar(A),!,A=O. 463break_string(A,O):- is_list(A),!,A=O. 464break_string(A,O):- atomic(A),catch(atomics_to_string(O," ",A),_,fail),!. 465break_string(A,O):- atomic(A),catch(atomic_list_concat(O," ",A),_,fail),!. 466break_string(A,O):- catch(atom_length(A,L),_,fail),convert_to_atoms_by_len(A,L,O),!. 467break_string(A,O):- listify(A,O),!. 468 469joined_string(A,O):- is_ftVar(A),!,A=O. 470joined_string(A,O):- string(A),!,A=O. 471joined_string(A,O):- atomic(A),!,A=O. 472joined_string(I,O):- is_s_string(I),I=..[s,E|M],!,joined_string([E|M],B),O=s(B),!. 473joined_string(A,O):- sanity(is_list(A)),catch(atomics_to_string(A," ",O),_,fail),!. 474joined_string(A,O):- sanity(is_list(A)),catch(atomic_list_concat(A," ",O),_,fail),!. 475 476 477is_upcased(U):- \+ downcase_atom(U,U), upcase_atom(U,U). 478 479 480is_guid_text(A):-atom_length(A,36),atomic_list_concat(List,'-',A),List=[L8,_,_,_,L12],atom_length(L8,8),atom_length(L12,12),!. 481 482convert_to_atoms_by_len(_,0,['']):-!. 483convert_to_atoms_by_len(A,L,[A]):- L<3,!. 484convert_to_atoms_by_len(A,36,[B]):- is_guid_text(A),string_to_atom(A,B),!. 485convert_to_atoms_by_len(A,L,B):- tokenize_atom(A,T),!,convert_to_atoms_by_len(A,L,T,B). 486 487convert_to_atoms_by_len(A,_,[],[A]):-!. 488convert_to_atoms_by_len(_,_,[A],[A]):-!. 489% convert_to_atoms_by_len(A,L,B,B):- L>3, \+ atom_contains(A,' '), \+ atom_contains(A,"'"),!. 490convert_to_atoms_by_len(_,_,List,M):-convert_to_atoms_list_list(List,M). 491 492% convert_to_atoms_list_list(T,P) 493convert_to_atoms_list_list([],[]):-!. 494convert_to_atoms_list_list([T,J,P|List],B):-arg(_,v('_','-'),J),is_upcased(T),is_upcased(P),atomic_list_concat([T,P],J,TP),!,convert_to_atoms_list_list([TP|List],B). 495convert_to_atoms_list_list(['\'',T|List],B):-member(T,['t','s','m','re','ll','d','ve']),atom_concat('\'',T,TP),!,convert_to_atoms_list_list([TP|List],B). 496convert_to_atoms_list_list([T,P|List],B):-member(T,['#','~','#$']),atom_concat(T,P,TP),!,convert_to_atoms_list_list([TP|List],B). 497convert_to_atoms_list_list([P|List],[P|BList]):-convert_to_atoms_list_list(List,BList). 498convert_to_atoms_list_list([P|List],[P|BList]):-convert_to_atoms_list_list(List,BList). 499 500delistify_single_element([M],M):-sanity(nonvar(M)),!. 501delistify_single_element(M,M). 502 503 504 505dehyphenize_const(PM,PMO):- atom(PM), atomic_list_concat(List,'-',PM),dehyphenize_const(PM,List,PMO),!. 506 507% \\000 508%dehyphenize_const(PM,List,PMO):- tokenize_atom(PM,[_,T1|Toks]),member(E,[T1|Toks]),number(E),E<0,!,atomic_list_concat(List,'_',PMO),!. 509dehyphenize_const(P,[P],P):-!. 510dehyphenize_const(_,[P,F|List],PMO):-must_maplist(toPropercase_hyphenize_number,[F|List],ListO),atomic_list_concat([P|ListO],PMO),!. 511 512toPropercase_hyphenize_number('','_'). 513toPropercase_hyphenize_number(N,O):-sub_atom(N, 0, 1, _, S),char_type(S,digit),!,atom_concat('_',N,O). 514toPropercase_hyphenize_number(I,O):- string_codes(I,[C|Odes]),to_upper(C,U),atom_codes(O,[U|Odes]). 515 516local_sanity_test:- sanity(dehyphenize_const('a-b','aB')). 517local_sanity_test:- must(dehyphenize_const('a-2b','a_2b')). 518local_sanity_test:- must(dehyphenize_const('uitype-ProductDescriptionTemplate','uitypeProductDescriptionTemplate')). 519 520%=
526string_to_atom_safe(ISO,LISTO):-LISTO==[],!,string_to_atom(ISO,''). 527string_to_atom_safe(ISO,LISTO):- string_to_atom(ISO,LISTO). 528 529/* 530string_chars(S,C):-atom_chars(S,C). 531text_to_string(T,S):- string_to_atom(S,T). 532string_upper(M,U):-toUppercase(M,U). 533string_lower(M,U):-toLowercase(M,U). 534*/ 535 536% :- ensure_loaded(logicmoo_util_bugger). 537:- meta_predicate map_tree_to_list( , , ). 538 539 540% = :- meta_predicate(camelSplitters(+)). 541 542% = :- meta_predicate(to_string_hook(-,-,+)). 543:- multifile(to_string_hook/3). 544:- dynamic(to_string_hook/3). 545 546 547%=
553camelSplitters(V):-arg(_,v(' ','-','_',':' /*,'mt','doom','Mt','Doom'*/ ),V). 554 555 556 557%=
563concat_atom_safe(I,O):-concat_atom_safe(I,'',O). 564 565 566%=
572concat_atom_safe(A,B,C):- atom(C),!,atomic_list_concat_safe(A,B,C). 573concat_atom_safe(A,B,C):- atomic_list_concat_safe(A,B,C). 574 575concat_atom_safe([],_,O):-nonvar(O),!,O==''. 576concat_atom_safe(L,_,''):-nonvar(L),!,L==[]. 577concat_atom_safe(A,B,C):-concat_atom(A,B,C). 578 579%================================================================ 580% Atom / String functions 581%================================================================ 582 583%=
589atomsSameCI(Name1,Name1):-!. 590atomsSameCI(Name1,Name2):-atom(Name1),atom(Name2),downcase_atom(Name1,D1),downcase_atom(Name2,D2),!,D1=D2. 591 592 593%=
599clean_codes(X,Y):-trim(X,Y),!. % actually cyc:trim/2 600clean_codes(X,X). 601 602%clean_out_atom(X,Y):-atomSplit(X,C),delete(C,'',O),concat_atom_safe(C,' ',Y). 603 604%=
610clean_out_atom(X,Y):-atom_codes(X,C),clean_codes(C,D),!,atom_codes(X,D),!,Y=X. 611 612%%atomSplit(A,B):-token_stream_of(A,AA),findall(B0,arg(1,AA,B),B). 613 614 615%=
621all_upper_atom(X):-toUppercase(X,N),!,N=X. 622 623 624%=
631atom_contains(F,X):- atomic(F),F\==[],on_x_debug(sub_string(F,_,_,_,X)). 632% atom_contains(F0,C0):- must((any_to_atom(F0,F),!,any_to_atom(C0,C))),!,sub_string(F,_,_,_,C).
641any_to_atom(Any,A):- any_to_string(Any,T), format(atom(A),'~w',[T]). 642% any_to_atom(A,A):- any_to_string(A,T), format(atom(A),'~w',[T]). 643 644 645%=
651any_to_string_or_var(StringO,String):- notrace(((var(StringO);var(String)),!,String=StringO)),!. 652any_to_string_or_var(StringO,String):- notrace((any_to_string(StringO,StringOS1),any_to_string(String,StringOS2),!,StringOS1=StringOS2)). 653 654 655%=
661atomic_list_concat_safe(List,V):- (V=='';V==""),!,List=[]. 662atomic_list_concat_safe(List,StringO):- ground(List),!,atomics_to_string(List,String),any_to_string_or_var(StringO,String),!. 663atomic_list_concat_safe([Atom,A2|Bonus],V):-atomic(Atom),atomic(A2),string_or_atom_concat(Atom,A2,A3),!,atomic_list_concat_safe([A3|Bonus],V),!. 664atomic_list_concat_safe([Atom|Bonus],V):-atomic(Atom),atomic(V),string_or_atom_concat(Atom,NV,V),!,atomic_list_concat_safe(Bonus,NV),!. 665atomic_list_concat_safe([D1,Atom|Bonus],V):-var(D1),atomic(Atom),sub_string_or_atom(V, NBefore, _Len, _NumAfter, Atom), 666 sub_string_or_atom(V, 0, NBefore, _, D1), atomic_list_concat_safe([D1,Atom|Bonus],V),!. 667atomic_list_concat_safe([V],V):-!. 668 669string_or_atom_concat(A,B,C):- \+ string(A),\+ string(B),\+ string(C),!, atom_concat(A,B,C). 670string_or_atom_concat(A,B,C):- string_concat(A,B,C). 671 672sub_string_or_atom(V, NBefore, Len, NumAfter, Atom):- (atom(V);atom(Atom)),!,sub_atom(V, NBefore, Len, NumAfter, Atom). 673sub_string_or_atom(V, NBefore, Len, NumAfter, Atom):- assertion(string(V);string(Atom)),sub_string(V, NBefore, Len, NumAfter, Atom). 674 675 676%=
682atomic_list_concat_safe(List,Sep,StringO):- (Sep==[];Sep=='';Sep==""),!,atomic_list_concat_safe(List,StringO). 683atomic_list_concat_safe(List,_,V):- (V=='';V==""),!,List=[]. 684atomic_list_concat_safe(List,_,V):- List==[],!,any_to_string_or_var('',V). 685atomic_list_concat_safe(List,Sep,Str):- ground(Sep:Str), !, atomic_list_concat(List1,Sep,Str),!,maplist(any_to_string_or_var,List,List1). 686atomic_list_concat_safe(List,Sep,StringO):- ground(List:Sep),!,atomics_to_string(List,Sep,String),any_to_string_or_var(StringO,String). 687%atomic_list_concat_safe(List,Sep,V):- maplist(unify_atomics,['',''],List). 688atomic_list_concat_safe([Atom,A2|Bonus],Sep,V):-atomic(Atom),atomic(A2),atomic_list_concat_safe([Atom,Sep,A2],A3),atomic_list_concat_safe([A3|Bonus],Sep,V),!. 689atomic_list_concat_safe([Atom|Bonus],Sep,V):- atomic(Atom),atomic(V),atomic_list_concat_safe([Atom,Sep,NV],V),!,atomic_list_concat_safe(Bonus,NV). 690atomic_list_concat_safe([D1,PostAtom|Bonus],Sep,V):-var(D1),atomic(V),atomic(Sep), 691 string_concat(Sep,PostAtom,Atom), 692 % We calc D1 693 sub_string(V, NBefore, _Len, NumAfter, Atom),sub_string(V, 0, NBefore, _, D1O), 694 sub_string(V,_,NumAfter,0,NewV),atomic_list_concat_safe(Bonus,Sep,NewV),!, 695 any_to_string_or_var(D1,D1O). 696atomic_list_concat_safe([D1|Bonus],AtomSep,V):-var(D1),atomic(AtomSep), 697 % We calc D1 698 sub_string(V, NBefore, _Len, NumAfter, AtomSep),sub_string(V, 0, NBefore, _, D1O),!, 699 sub_string(V,_,NumAfter,0,NewV),atomic_list_concat_safe(Bonus,AtomSep,NewV),!, 700 any_to_string_or_var(D1,D1O). 701atomic_list_concat_safe([V],_Sep,V):-!. 702 703 704 705 706 707 708% convert any ftTerm to 'atom' string 709 710%=
716/* 717convert_to_string(I,ISO):- 718 logicmoo_util_first:term_to_string(I,IS),!, 719 string_to_list(IS,LIST),!, 720 list_replace(LIST,92,[92,92],LISTM), 721 list_replace(LISTM,34,[92,34],LISTO),!, 722 text_to_string(LISTO,ISO). % string_to_atom_safe(ISO,LISTO),!. 723*/ 724 725%=
731list_replace(List,Char,Replace,NewList):- 732 append(Left,[Char|Right],List), 733 append(Left,Replace,NewLeft), 734 list_replace(Right,Char,Replace,NewRight), 735 append(NewLeft,NewRight,NewList),!. 736list_replace(List,_Char,_Replace,List):-!. 737 738 739% :- export(atomic_concat/3). 740 741%=
747atomic_concat(A,B,C,Out):-atomic_list_concat_safe([A,B,C],Out). 748 749% :-atomic_list_concat_safe([A,'/',C],'','foo/bar/baz'). 750% =========================================================== 751% CASE CHANGE 752% =========================================================== 753 754isSlot(V):- is_ftVar(V). 755 756 757%=
763noCaseChange(VAR):- is_ftVar(VAR),!. 764% noCaseChange(VAR):- if_defined(isSlot(VAR)),!. 765noCaseChange([]):-!. 766noCaseChange(MiXed):-number(MiXed),!. 767noCaseChange(MiXed):-atom(MiXed),atom_concat('#$',_,MiXed),!. 768noCaseChange(c(_)):-!. 769 770 771%=
777first_char_to_upper(CX,Y):- name(CX,[S|SS]),char_type(S,to_lower(NA)),name(NA,[N]),name(Y,[N|SS]),!. 778 779%=
785first_char_to_lower(CX,Y):- name(CX,[S|SS]),char_type(S,to_upper(NA)),name(NA,[N]),name(Y,[N|SS]),!. 786 787%=
793to_titlecase(CX,Y):- sub_string(CX,1,_,0,Z),string_lower(Z,L), name(CX,[S|_]),char_type(S,to_lower(NA)),atom_concat(NA,L,Y),!. 794to_titlecase('',''):-!. 795to_titlecase(CX,Y):- first_char_to_upper(CX,Y). 796 797 798%=
804text_to_string_safe(Expr,Forms):- notrace(on_x_fail(text_to_string(Expr,Forms))). 805 806 807 808%=
814toLowercase(I,O):-integer(I),!,to_lower(I,O). 815toLowercase(I,O):-toCase(downcase_atom,I,O). 816 817 818%=
824toUppercase(I,O):-integer(I),!,to_upper(I,O). 825toUppercase(I,O):-toCase(upcase_atom,I,O). 826 827 828%=
834toCamelcase(I,O):-toCaseSplit('',first_char_to_upper,I,O). 835 836 837%=
844%unCamelcase(I,O):- \+ string(I),any_to_string(I,S), 845%unCamelcase(I,O):- upcase_atom(I,O),downcase_atom(I,O),!. 846unCamelcase(I,O):-toCaseSplit('_',first_char_to_lower,I,O). 847 848 849%=
855toPropercase(I,O):-toCaseSplit(_Same,to_titlecase,I,O). 856 857 858 859%=
865toCase(_Pred,MiXed,MiXed):-noCaseChange(MiXed),!. 866toCase(_Pred,95,45):-!. 867toCase(_Pred,N,N):-integer(N),!. 868toCase( Pred,MiXed,CASED):-atom(MiXed),!,call(Pred,MiXed,CASED),!. 869toCase( Pred,D3,DD3):- text_to_string_safe(D3,S),!,string_to_atom(S,A3),toCase(Pred,A3,DD3). 870toCase( Pred,D3,DD3):- is_list(D3),catch(atomic_list_concat(D3,' ',Str),_,fail),maplist(toCase( Pred),Str,DD3),!. 871toCase( Pred,D3,DD3):- is_list(D3),!,must_maplist(toCase( Pred),D3,DD3). 872toCase( Pred,MiXed,CASED):-compound(MiXed),MiXed=..MList, 873 must_maplist(toCase(Pred),MList,UList),!, 874 CASED=..UList. 875 876 877 878 879%=
885toCaseSplit(_,_,[Empty],[]):-nonvar(Empty), (empty_str(Empty);camelSplitters(Empty)),!. 886toCaseSplit(_,_,Empty,''):- (empty_str(Empty);camelSplitters(Empty)),!. 887 888toCaseSplit(_,_,MiXed,MiXed):-noCaseChange(MiXed),!. 889toCaseSplit(Rejoin,Pred,D3,DD3):-atom(D3),!, 890 ((camelSplitters(V),concat_atom([L,I|ST],V,D3))-> 891 (maplist(Pred,[L,I|ST],LIST2),rejoined(Rejoin,V,VV),concat_atom(LIST2,VV,DD3)); 892 toCase(Pred,D3,DD3)). 893toCaseSplit(Rejoin,Pred,D3,DD3):-text_to_string_safe(D3,S),!,string_to_atom(S,A3),toCaseSplit(Rejoin,Pred,A3,DD3). 894toCaseSplit(Rejoin,Pred,LI,OUT):-is_list(LI),!,maplist(toCaseSplit(Rejoin,Pred),LI,LO),ignore(VV=Rejoin),ignore(VV=''),concat_atom(LO,VV,OUT). 895toCaseSplit(Rejoin,Pred,[CX|Y],[D3|YY]):-!,toCaseSplit(Rejoin,Pred,CX,D3),toCaseSplit(Rejoin,Pred,Y,YY). 896toCaseSplit(_ ,Pred,MiXed,UPPER):-must((compound(MiXed),MiXed=..MList, 897 %toCaseSplit(' ',Pred,MList,UList),!, 898 maplist(toCaseSplit(' ',Pred),MList,UList),!, 899 UPPER=..UList)). 900 901 902%=
908rejoined(Rejoin,V,VV):-ignore(Rejoin=VV),ignore(V=VV),!. 909 910 911 912%=
918empty_str(E):-nonvar(E),memberchk(E,[``,"",'']). 919 920 921 922% =========================================================== 923% CHECK CASE 924% =========================================================== 925:- export(capitalized/1). 926 927 928%=
934capitalized(Type):- string_codes(Type,[S|_]),char_type(S,upper),must(char_type(S,alpha)). 935 936% =========================================================== 937% BREAKING ON CASE CHANGE 938% =========================================================== 939:- export(to_case_breaks/2). 940 941%=
947to_case_breaks(Text,New):- string_codes(Text,[C|Codes]), char_type_this(C,WillBe),!, 948 to_case_breaks(Codes,WillBe,[C],WillBe,New). 949 950to_case_break_atoms(I,O):- any_to_atom(I,A),to_case_breaks(A,M),maplist(arg(1),M,L),maplist(any_to_atom,L,O). 951 952%=
958char_type_this(C,Lower):- notrace((ctype_switcher(Lower),char_type(C,Lower))),!. 959 960 961%=
ctype_switcher(digit)
.
968ctype_switcher(punct). 969ctype_switcher(digit). 970ctype_switcher(white). 971ctype_switcher(lower). 972ctype_switcher(upper). 973 974 975%=
981breaked_codes(S,C):- notrace(nonvar(S)),notrace(catch((number_codes(_,C),string_codes(S,C)),_,fail)),!. 982breaked_codes(S,C0):- notrace(nonvar(S)),on_x_fail(write_to_codes(S,C)),!,C=C0. 983breaked_codes(S,C):- 984 (string_codes(S,C)->true; 985 (atom_codes(S,C)->true; 986 string_equal_ci(S,C))),!. 987 988 989%=
995ctype_continue([_],upper,lower). 996ctype_continue(_ ,X,X):-ctype_switcher(X). 997 998 999%=
1005ctype_switch(upper,upper). 1006ctype_switch(T1,T2):-ctype_switcher(T1),ctype_switcher(T2),T1\=T2. 1007 1008 1009 1010%=
hide_char_type(white)
.
1017hide_char_type(red). 1018%hide_char_type(punct). 1019 1020% to_case_breaks(+Codes,+SoFarC,+Lower,List) 1021 1022%=
1028to_case_breaks([C2|Codes],_,[C],WillBe,[xti(Left,WillBe)|New]):- C2\==C, WillBe==punct, !, text_to_string([C],Left),to_case_breaks([C2|Codes],New). 1029to_case_breaks([ ],_WillBe, [],_, []):-!. 1030to_case_breaks([ ],WillBe,SoFar,_NewType,[xti(Left,WillBe)]):-breaked_codes(Left,SoFar),!. 1031to_case_breaks([C|Codes],WillBe,SoFar,Upper,New):- ctype_continue(SoFar,Upper,Lower), 1032 char_type_this(C,Lower),append(SoFar,[C],SoFarC),!, 1033 to_case_breaks(Codes,WillBe,SoFarC,Lower,New). 1034 1035to_case_breaks(C___Codes,WillBe,SoFar,Upper,OUT):- is_list(OUT),OUT=[xti(Left,WillBe),xti(New,RType)],!, 1036 to_first_break_w(C___Codes,SoFar,Upper,Left,New,RType). 1037 1038 1039to_case_breaks([C|Codes],WillBe,SoFar,Upper,OUT):- ctype_switch(Upper,Digit), char_type_this(C,Digit),!, 1040 breaked_codes(Left,SoFar), to_case_breaks(Codes,Digit,[C],Digit,New),!, 1041 (hide_char_type(WillBe)->OUT=New;OUT=[xti(Left,WillBe)|New]). 1042 1043to_case_breaks([C|Codes],WillBe,SoFar,Upper,New):- append(SoFar,[C],SoFarC),to_case_breaks(Codes,WillBe,SoFarC,Upper,New). 1044 1045:- export(to_first_break/2). 1046 1047%=
1053to_first_break(Text,Left):-to_first_break(Text,_LeftType,Left,_Right,_NextType). 1054:- export(to_first_break/5). 1055 1056%=
1062to_first_break(Text,LType,Left,Right,RType):- string_codes(Text,[C|Codes]), char_type_this(C,LType),!, 1063 to_first_break_w(Codes,[C],LType,Left,Right,RType). 1064to_first_break(Text,LType,Left,Right,RType):- string_codes(Text,[C|Codes]), !,to_first_break_w(Codes,[C],LType,Left,Right,RType). 1065 1066 1067%=
1073to_first_break_w([], [] ,empty,'',[],empty):-!. 1074to_first_break_w([], SoFar,_Some,Left,[],empty):-breaked_codes(Left,SoFar),!. 1075to_first_break_w([C|Codes],SoFar,Upper,Left,Rest,RType):- ctype_continue(SoFar,Upper,Lower), char_type_this(C,Lower),append(SoFar,[C],SoFarC),!,to_first_break_w(Codes,SoFarC,Lower,Left,Rest,RType). 1076to_first_break_w([C|Codes],SoFar,Lower,Left,Rest,Upper):- ctype_switch(Lower,Upper), char_type_this(C,Upper), breaked_codes(Left,SoFar),!,breaked_codes(Rest,[C|Codes]). 1077to_first_break_w([C|Codes],SoFar,Lower,Left,Rest,RType):- append(SoFar,[C],SoFarC),to_first_break_w(Codes,SoFarC,Lower,Left,Rest,RType). 1078 1079% =========================================================== 1080% Quote-Unquote 1081% =========================================================== 1082 1083 1084%=
1090quoteAtomString([34|T],Out):-name(Out,[34|T]),!. 1091quoteAtomString([H|T],Out):-!,append([34,H|T],[34],Quote),name(Out,Quote). 1092quoteAtomString(QU,QU):-concat_atom_safe(['"'|_],QU),!. 1093quoteAtomString(UQ,QU):-concat_atom_safe(['"',UQ,'"'],QU),!. 1094 1095 1096%=
1102unquoteAtom(Atom,New):-concat_atom_safe(LIST,'"',Atom),concat_atom_safe(LIST,'',New),!. 1103 1104% =========================================================== 1105% string/chars/codes 1106% =========================================================== 1107 1108 1109%=
1115is_charlist(L):- ground(L), L\==[], is_list(L),!,maplist(is_charlist_char,L). 1116 1117:- export(is_charlist_char/1). 1118is_charlist_char(C):- atom(C), atom_length(C,1), name(C,[Code]),swish_render_codes_charset_code(_,Code). 1119 1120any_to_charlist(A,C):- is_charlist(A),!,A=C. 1121any_to_charlist(A,C):- any_to_string(A,S),atom_chars(S,C). 1122 1123 1124%=
1130is_codelist(L):- ground(L), L\==[], is_list(L),!,maplist(is_codelist_code,L). 1131 1132:- export(is_codelist_code/1). 1133is_codelist_code(H):- \+ integer(H),!,fail. 1134is_codelist_code(H):- H<32,!,fail. 1135is_codelist_code(H):- H>=128,!,fail. 1136is_codelist_code(H):- integer(H), swish_render_codes_charset_code(_,H),!. 1137 1138swish_render_codes_charset_code(_,9). 1139swish_render_codes_charset_code(_,10). 1140swish_render_codes_charset_code(_,13). 1141swish_render_codes_charset_code(_,27). 1142swish_render_codes_charset_code(ascii, C) :- 1143 between(32, 126, C). 1144swish_render_codes_charset_code(iso_latin_1, C) :- 1145 ( between(32, 126, C) 1146 ; between(160, 255, C) 1147 ). 1148 1149 1150 1151any_to_codelist(A,C):- is_codelist(A),!,A=C. 1152any_to_codelist(A,C):- any_to_string(A,S),atom_codes(S,C). 1153 1154%=
1160is_ftString2(X):- atom(X),!,atom_length(X,L),L>1,atom_concat('"',_,X),atom_concat(_,'"',X),!. 1161is_ftString2(X):- var(X),!,fail. 1162is_ftString2(string(_)):-!. 1163is_ftString2(""). 1164is_ftString2(X):- string(X),!. 1165is_ftString2(L):-is_charlist(L),!. 1166is_ftString2(L):-is_codelist(L),!. 1167 1168 1169 1170%=
1176isWhitespace(32). 1177isWhitespace(N):-N<33;N>128. 1178 1179 1180% =========================================================== 1181% escapeString/Codes/Chars 1182% =========================================================== 1183 1184 1185%=
1191escapeString(R,RS):- (string(R);is_list(R)) ,string_to_atom(R,A),atom_codes(A,Codes),escapeCodes([34,92],92,Codes,RS),!. 1192 1193 1194%=
1200escapeCodes(_Escaped,_EscapeChar,[],[]):-!. 1201escapeCodes(Escaped,EscapeChar,[EscapeChar,Skip|Source],[EscapeChar,Skip|New]):-!, 1202 escapeCodes(Escaped,EscapeChar,Source,New),!. 1203escapeCodes(Escaped,EscapeChar,[Char|Source],[EscapeChar,Char|New]):-member(Char,Escaped),!, 1204 escapeCodes(Escaped,EscapeChar,Source,New),!. 1205escapeCodes(Escaped,EscapeChar,[Skipped|Source],[Skipped|New]):- 1206 escapeCodes(Escaped,EscapeChar,Source,New),!. 1207 1208 1209% =========================================================== 1210% [d|r]estringify/Codes/Chars 1211% =========================================================== 1212 1213 1214 1215%=
1221destringify(X,X):-(var(X);number(X)),!. 1222destringify('$VAR'(S),'$VAR'(S)):-!. 1223destringify(string(S),string(S)):-is_ftVar(S),!. 1224destringify([],[]):-!. 1225destringify('[]','[]'):-!. 1226destringify(T,A):- notrace(on_x_fail(call((text_to_string(T,S),!,maybe_notrace(atom_string(A,S)))))),!. 1227destringify(X,S):-is_ftString2(X),stringToCodelist(X,CL),name(S,CL),!. 1228destringify([H|T],[HH|TT]):-!,destringify(H,HH),destringify(T,TT),!. 1229destringify(X,P):- compound(X),X=..LIST,maplist(destringify,LIST,DL),P=..DL,!. 1230destringify(B,A):- (atom(A),atom_concat('#$',A,B))->true;A=B. 1231 1232%stringToList(X,Y):-writeq(string_to_list(X,Y)),nl,fail. 1233 1234%=
1240stringToList(X,Y):-var(X),!,string_to_list(X,Y). 1241stringToList([],[]). 1242stringToList("",[]). 1243stringToList(X,Y):-atom(X),atom_codes(X,Codes),!,stringToList(Codes,Y),!. 1244stringToList(X,Y):- string(X),string_to_atom(X,M),!,stringToList(M,Y). 1245stringToList(X,Y):- string(X),!,string_to_list(X,Y). 1246stringToList(X,Y):-is_ftString2(X),!,string_to_list(X,Y). 1247stringToList([X|XX],Y):-concat_atom_safe([X|XX],' ',XXX),!,string_to_list(XXX,Y). 1248%prologPredToCyc(Predicate):-arity(PredicateHead) 1249 1250 1251%=
1257stringToCodelist(S,CL):- stringToCodelist2(S,SL),!,escapeString(SL,CS),!,stringToList(CL,CS),!. 1258 1259 1260%=
1266stringToCodelist2(S,_Codes):-var(S),!,fail. 1267stringToCodelist2(string(S),Codes):-!,stringToCodelist2(S,Codes). 1268stringToCodelist2([],[]):-!. 1269stringToCodelist2([[]],[]):-!. 1270stringToCodelist2([''],[]):-!. 1271stringToCodelist2([X|T],[X|T]):-is_codelist([X|T]),!. 1272stringToCodelist2([X|T],Codes):-atom(X),is_charlist([X|T]),!,stringToList([X|T],Codes),!. 1273stringToCodelist2(String,Codes):- string(String),!,string_to_atom(String,Atom),atom_codes(Atom,Codes),!. 1274stringToCodelist2(Atom,Codes):-atom(Atom),atom_codes(Atom,Codes),!. 1275stringToCodelist2(A,Codes):- to_string_hook(A,_,L),atom_codes(L,Codes),!. 1276stringToCodelist2(Term,Codes):-sformat(Codes,'~q',[Term]),true. 1277 1278 1279%=================================================================== 1280% Removes Leading and Trailing whitespaces and non ANSI charsets. 1281%==================================================================== 1282:- assert(show_this_hide(trim,2)). 1283:- current_prolog_flag(double_quotes,X),asserta(double_quotes_string_was(X)). 1284:- set_prolog_flag(double_quotes,codes). 1285 1286 1287%=
1293trim(S,Y):-flatten(S,S2),trim2(S2,Y). 1294 1295 1296%=
1302trim2(S,Y):- 1303 ground(S),%true, 1304 stringToList(S,X), 1305 ltrim(X,R),lists:reverse(R,Rvs), 1306 addSpaceBeforeSym(Rvs,Rv), 1307 ltrim(Rv,RY),lists:reverse(RY,Y),!. 1308 1309 1310%=
1316addSpaceBeforeSym([H|T],[H,32|T]):-member(H,"?.!"),!. 1317addSpaceBeforeSym(H,H). 1318 1319:- retract(double_quotes_string_was(X)),set_prolog_flag(double_quotes,X). 1320:- set_prolog_flag(double_quotes,string). 1321 1322 1323%=
1329ltrim([],[]):-!. 1330ltrim([32,32,32,32,32,32,32|String],Out) :-trim(String,Out),!. 1331ltrim([32,32,32,32,32|String],Out) :-trim(String,Out),!. 1332ltrim([32,32,32|String],Out) :- trim(String,Out),!. 1333ltrim([32,32|String],Out) :- trim(String,Out),!. 1334ltrim([P|X],Y):- (isWhitespace(P); \+ (number(P));P<33;P>128),trim(X,Y),!. 1335ltrim(X,X). 1336 1337 1338 1339:- export(atomic_list_concat_catch/3). 1340 1341%=
1347atomic_list_concat_catch(List,Sep,Atom):-catch(atomic_list_concat_safe(List,Sep,Atom),E,(dumpST,dmsg(E:atomic_list_concat_safe(List,Sep,Atom)),!,fail)). 1348 1349 1350 1351%=
1357catch_read_term_from_atom(Sub,Term,NewOnes):- 1358 on_x_fail(read_term_from_atom(Sub,Term,[module(user),variable_names(NewOnes)])),Term\==end_of_file. 1359 1360/* 1361:- export(splt_words/3). 1362 1363%= 1364 1365%% splt_words( ?Atom, ?Terms, ?Var) is semidet. 1366% 1367% Splt Words. 1368% 1369splt_words(Atom,Terms,Var):- on_x_fail((quietly(once(splt_words_0(Atom,Terms,Var))))),!. 1370splt_words(Atom,Words1,[]):- on_x_fail(atomic_list_concat_safe(Words1,' ',Atom)),!. 1371 1372 1373%= 1374 1375%% splt_words_0( ?S, ?Terms, ?Var) is semidet. 1376% 1377% splt words Primary Helper. 1378% 1379splt_words_0(S,Terms,Var):-any_to_atom(S,Atom),!,splt_words_0_atom(Atom,Terms,Var),!. 1380 1381 1382%= 1383 1384%% splt_words_0_atom( ?Atom, :TermTerm, ?Vars) is semidet. 1385% 1386% splt words Primary Helper atom. 1387% 1388splt_words_0_atom('',[],[]):-!. 1389splt_words_0_atom(Atom,[Term|List],Vars):- atom(Atom),atom_length(Atom,To),between(0,To,X), 1390 sub_atom(Atom,0,Len,X,Sub),Len>0, 1391 catch_read_term_from_atom(Sub,Term,NewOnes), 1392 (compound(Term)->sub_atom(Sub,_,1,0,')');true), 1393 sub_atom(Atom,Len,_,0,Next), 1394 splt_words_0_atom(Next,List,NewVars), 1395 merge_vars(NewVars,NewOnes,Vars),!. 1396splt_words_0_atom(Atom,[L0|ListO],Vars):-atomic_list_concat([L0,L1|List],' ',Atom),atomic_list_concat([L1|List],' ',Atom2),!, 1397 splt_words_0_atom(Atom2,ListO,Vars),!. 1398 1399*/ 1400 1401 1402%=
1408merge_vars(NewVars,[],NewVars). 1409merge_vars([],NewVars,NewVars). 1410merge_vars([X=Y|More],OldVars,NewVars):-member(X=Y,OldVars),!, 1411 merge_vars(More,OldVars,NewVars). 1412merge_vars([X=Y|More],OldVars,[X=Y|NewVars]):- 1413 merge_vars(More,OldVars,NewVars). 1414 1415 1416%=
1422vars_to_ucase(_,List):-ground(List),!. 1423vars_to_ucase(Vars,[L|List]):- var(L),!,vars_to_ucase_0(Vars,[L|List]),!. 1424vars_to_ucase(Vars,[_|List]):- vars_to_ucase(Vars,List). 1425 1426 1427%=
1433vars_to_ucase_0([],_). 1434vars_to_ucase_0([N=V|Vars],List):- 1435 ignore(N=V), 1436 vars_to_ucase_0(Vars,List). 1437 1438 1439%=
1445atomSplit(In,List):- convert_to_cycString(In,M),listify(M,List). 1446atomSplit_old(In,List):- quietly(( ground(In), 1447 any_to_string(In,String), 1448 splt_words(String,List,Vars),vars_to_ucase(Vars,List))),!. 1449 1450%atomSplit(Atom,WordsO):-atomSplitEasy_unused(Atom,WordsO),!. 1451 1452:- export(atomSplitEasy_unused/2). 1453 1454%=
1460atomSplitEasy_unused(Atom,WordsO):- 1461 quietly((atomSplit(Atom,WordsO,[' ','\t','\n','\v','\f','\r',' ','!','"','#','$','%','&','\'', 1462 '(',')','*','+',',','-','.','/',':',';','<', 1463 '=','>','?','@','[',\,']','^','_', 1464 '`','{','|','}','~'] 1465 ))). 1466 1467%%atomSplit(Atom,WordsO):- atomSplit(Atom,WordsO,[' ','\'',';',',','"','`',':','?','!','.','\n','\t','\r','\\','*','%','(',')','#']),!. 1468 1469 1470%=
1476atomSplit(S,WordsO,List):- quietly(( atomic(S),atomic_list_concat_safe(Words1,' ',S),!, atomSplit2_unused(Words1,Words,List),!, Words=WordsO )). 1477atomSplit(Atom,WordsO,List):- quietly(( atom(Atom), atomic_list_concat_safe(Words1,' ',Atom),!, atomSplit2_unused(Words1,Words,List),!, Words=WordsO )). 1478atomSplit(Atom,Words,[Space|AtomO]):-quietly((var(Atom),ground(Words),!,atomic_list_concat_safe(Words,Space,AtomO),!,Atom=AtomO)). 1479 1480 1481 1482%=
1488atomSplit2_unused([],[],_List):-!. 1489atomSplit2_unused([Mark|S],[Mark|Words],List):- member(Mark,List),!,atomSplit2_unused(S,Words,List),!. 1490atomSplit2_unused([W|S],[A,Mark|Words],List):- member(Mark,List),atom_concat(A,Mark,W),!,atomSplit2_unused(S,Words,List),!. 1491atomSplit2_unused([W|S],[Mark,A|Words],List):- member(Mark,List),atom_concat(Mark,A,W),!,atomSplit2_unused(S,Words,List),!. 1492atomSplit2_unused([Word|S],Words,List):- member(Space,List),Atoms=[_,_|_],atomic_list_concat_safe(Atoms,Space,Word),!, 1493 interleave(Atoms,Space,Left), 1494 atomSplit2_unused(S,Right,List),append(Left,Right,WordsM),!,atomSplit2_unused(WordsM,Words,List),!. 1495atomSplit2_unused([W|S],[W|Words],List):-atomSplit2_unused(S,Words,List),!. 1496 1497 1498%=
1504interleave([''],Space,[Space]):-!. 1505interleave([Atom],_Space,[Atom]):-!. 1506interleave([''|More],Space,[Space|Result]):-interleave(More,Space,Result),!. 1507interleave([Atom|More],Space,[Atom,Space|Result]):-interleave(More,Space,Result),!. 1508 1509 1510 1511%================================================================ 1512% decends tree 1513%================================================================
1521must_assign(From=To):-must_assign(From,To). 1522 1523%=
1529must_assign(From,To):-To=From,!. 1530must_assign(From,To):- tlbugger:skipMust,!,ignore(To=From),!. 1531must_assign(From,To):-dmsg(From),dmsg(=),dmsg(From),dmsg(must_assign),!,dtrace,To=From.
1540map_tree_to_list(_,PATTERN,Output):- (var(PATTERN);number(PATTERN)),!,must_assign([PATTERN],Output). 1541map_tree_to_list(_,[],OUT):-!,must_assign([],OUT). 1542map_tree_to_list(Pred,IN,Output):- once(call(Pred,IN,MID)),must((MID=IN -> flatten([MID],OUT) ; map_tree_to_list(Pred,MID,OUT))),!,must_assign(OUT=Output). 1543map_tree_to_list(Pred,[I|IN],Output):-!,with_each(on_f_debug((map_tree_to_list(Pred,I,O1),map_tree_to_list(Pred,IN,O2),!,append(O1,O2,OUT)))),!,must_assign(OUT=Output). 1544map_tree_to_list(Pred,IN,Output):-atom(IN),!,must((atomSplit(IN,MID),!,map_tree_to_list(Pred,MID,OUT))),!,must_assign(OUT=Output). 1545map_tree_to_list(Pred,IN,Output):- 1546 must((compound(IN), IN=..INP, append(Left,[Last],INP), map_tree_to_list(Pred,Last,UT),!, 1547 append(Left,[UT],OUTP),!, OUT =.. OUTP)),must_assign([OUT],Output). 1548map_tree_to_list(_,IN,IN):- dtrace,must_assign([IN],IN). 1549 1550 1551%=
1557non_empty(A):-must_det( \+ (empty_string(A))). 1558 1559%=
1565must_nonvar(A):-one_must(nonvar(A),trace_or_throw(must_nonvar(A))). 1566 1567 1568 1569%=
1575both_empty(A,B):-empty_string(A),!,empty_string(B),nop(dmsg(both_empty(A,B))). 1576 1577%=
1583either_empty(A,B):- (empty_string(B);empty_string(A)),!,nop(dmsg(either_empty(A,B))). 1584 1585 1586%=
1592equals_icase(A,B):-either_empty(A,B),!,fail. 1593equals_icase(A,B):- string_ci(A,U),string_ci(B,U). 1594 1595%=
1601starts_with_icase(A,B):-either_empty(A,B),!,fail. 1602starts_with_icase(A,B):- string_ci(A,UA),string_ci(B,UB),non_empty(UB),atom_concat(UB,_,UA). 1603starts_with_icase(A,B):-both_empty(A,B),dmsg(warn(equals_icase(A,B))). 1604 1605%=
1611either_starts_with_icase(A,B):-either_empty(A,B),!,fail. 1612either_starts_with_icase(A,B):- string_ci(A,UA),string_ci(B,UB),non_empty(UA),non_empty(UB),(atom_concat(UB,_,UA);atom_concat(UA,_,UB)). 1613 1614%=
1620starts_or_ends_with_icase(A,B):-either_empty(A,B),!,fail. 1621starts_or_ends_with_icase(A,B):- string_ci(A,UA),string_ci(B,UB),non_empty(UA),non_empty(UB),(atom_concat(UB,_,UA);atom_concat(_,UA,UB)). 1622 1623%=
1629ends_with_icase(A,B):-either_empty(A,B),!,fail. 1630ends_with_icase(A,B):- string_ci(A,UA),string_ci(B,UB),non_empty(UB),atom_concat(_,UB,UA). 1631 1632 1633%=
1639string_dedupe(StringI,StringO):- to_word_list(StringI,Words),remove_predupes(Words,StringO). 1640 1641 1642 1643%=
1649remove_predupes([],[]). 1650remove_predupes(ListI,ListO):- member(L0,["",[],"",'',[32],' ']),member(L0,ListI),delete(ListI,L0,ListM),!,remove_predupes(ListM,ListO),!. 1651remove_predupes([L|ListI], ListO):- (member_ci(L,ListI) -> remove_predupes(ListI,ListO) ; (remove_predupes(ListI,ListM),[L|ListM]=ListO)),!. 1652 1653 1654%=
1660member_ci(L,[List|I]):-!,member(LL2,[List|I]),string_equal_ci(LL2,L). 1661member_ci(W,WL):-to_word_list(WL,ListI),member(LL2,ListI),string_equal_ci(LL2,W). 1662 1663 1664%=
1670string_ci(A,LIC):-ground(string_ci(A,LIC)),!,string_ci(A,LIC1),string_ci(LIC,LIC2),LIC1=LIC2. 1671string_ci(A,LIC):-quietly((must(nonvar(A)),non_empty(A),any_to_string(A,S),!,text_to_string(S,SS), 1672 string_lower(SS,SL), 1673 atomics_to_string(SLIC,'_',SL), 1674 atomics_to_string(SLIC,' ',LIC))),!. 1675 1676:- export(append_ci/3). 1677 1678%=
1684append_ci(A1,A2,A3):-to_word_list(A1,L1),to_word_list(A2,L2),to_word_list(A3,L3),!, append_ci0(L1,L2,L3),!. 1685 1686 1687%=
1693append_ci0([],L1,L2):- string_equal_ci(L1,L2),!. 1694append_ci0(L,L2,R):-divide_list(L,H1,L1),divide_list(R,H2,L3),string_equal_ci(H1,H2),!,append_ci0(L1,L2,L3). 1695 1696 1697%=
1703divide_list(L,L0,LT):-is_list(L),!,length(L,X),X1 is X-1,between(1,X1,RS),length(LT,RS),append(L0,LT,L). 1704divide_list(L,L0,LT):-append(L0,LT,L). 1705 1706 1707%=
1713string_equal_ci(L0,L1):- 1714 notrace((to_word_list(L0,WL0),WL0\==[],to_word_list(L1,WL1)->WL1\==[],!, 1715 string_equal_ci0(WL0,WL1))),!. 1716 % (string_equal_ci0(WL0,WL1);(var(L1),freeze(L1,string_equal_ci0(WL0,WL1)))). 1717 1718 1719%=
1725string_equal_ci0([],_):-!,fail. 1726%string_equal_ci0(_,[]):-!,fail. 1727string_equal_ci0(L0,R0):- string_equal_ci1(L0,R0),!. 1728string_equal_ci0(L,R):-divide_list(L,L0,LT),divide_list(R,R0,RT),string_equal_ci1(L0,R0),!,string_equal_ci0(LT,RT). 1729 1730 1731%=
1737string_equal_ci1(A0,A0):-!. 1738string_equal_ci1([],_):-!,fail. 1739string_equal_ci1(_,[]):-!,fail. 1740string_equal_ci1(A0,B0):-as_nc_str(A0,AR),as_nc_str(B0,BR),!, AR = BR. 1741 1742 1743 1744%=
1750as_nc_str([A0,'\'',B0],AS):-atomic_list_concat_safe([A0,'\'',B0],'',AO),as_nc_str(AO,AS). 1751as_nc_str([A0,'\'',B0],AS):-as_nc_str([A0,B0],AS). 1752as_nc_str([A0,Ommitable,B0],AS):- once(ommitable(Ommitable)), as_nc_str([A0,B0],AS). 1753as_nc_str([Ommitable,B0],AS):- once(ommitable(Ommitable)), as_nc_str([B0],AS). 1754as_nc_str([A0,B0],AS):-atom_concat(A0,B0,AO),as_nc_str(AO,AS). 1755as_nc_str(A0,ASL):-any_to_string(A0,AS),string_lower(AS,ASL). 1756% as_nc_str(A0,A0). 1757 1758 1759%=
1765ommitable(O):-empty_string(O). 1766ommitable(O):- string_to_atom(O,A),atom_length(A,L),!,L<2. 1767 1768 1769%=
1775atom_subst(A,F,R,KA):-replace_in_string(F,R,A,K),!,string_to_atom(K,KA),!. 1776 1777 1778 1779%=
1786empty_string(A):-var(A),!,fail. 1787empty_string([A]):-!,nonvar(A),empty_string0(A). 1788empty_string(A):-empty_string0(A). 1789empty_string0([]). 1790empty_string0(''). 1791empty_string0(``). 1792empty_string0(""). 1793 1794 1795 1796% Meta-Interp that appends the arguments to the calls 1797:- meta_predicate convert_members( , , ). 1798 1799%=
1805convert_members(Pred, InOut,InOut):- Pred==[],!. 1806convert_members([A,!|B], In,Out):- !, convert_members(A,In,M),!,convert_members(B,M,Out). 1807convert_members([A|B], In,Out):- !, convert_members(A,In,M),convert_members(B,M,Out). 1808convert_members(once(Call), In,Out):- !, convert_members(Call, In,Out),!. 1809convert_members(ht(Call), In,Out):- !, Call=..[P|MID],CallOut=..[P,In|MID],call(CallOut,Out). 1810convert_members(ico(In,Call,Out), In,Out):- Call=..[P|MID],CallOut=..[P,In|MID],call(CallOut,Out). 1811convert_members(cio(In,Call,Out), In,Out):- call(Call,In,Out). 1812convert_members(ic(InOut,Call), InOut,InOut):- call(Call). 1813convert_members(call(Call), InOut,InOut):- call(Call). 1814convert_members(Call, In,Out):- call(call,Call,In,Out). 1815 1816 1817%=
1823replace_in_string(SepChars, PadChars,Repl, A,C):- split_string(A,SepChars,PadChars,B),atomics_to_string(B,Repl,C). 1824 1825 1826%=
1833replace_in_string(F,R,OriginalString,K):-atom(OriginalString),!,atom_string(OriginalString,S),replace_in_string(F,R,S,ModifiedString),atom_string(K,ModifiedString). 1834replace_in_string(Find,Repl,OriginalString,ModifiedString):- atomic_list_concat(List,Find,OriginalString),atomics_to_string(List,Repl,ModifiedString). 1835 1836replace_in_string([KV|FR],OriginalString,O):-!, 1837 compound(KV),arg(1,KV,F),arg(2,KV,R), 1838 replace_in_string(F,R,OriginalString,M), 1839 replace_in_string(FR,M,O). 1840replace_in_string([],O,O). 1841 1842 1843%=
1849replace_periods(A,S):- 1850 convert_members([ 1851 % white space 1852 replace_in_string('\r',' ' ), 1853 replace_in_string('\n',' '), 1854 % replace_in_string('\s',' '), 1855 replace_in_string('\'',' apostraphyMARK '), 1856 replace_in_string('\t',' '), 1857 % only remove leading and trailing white space 1858 % at(split_string('', '\s\t\n')), 1859 % respace the spaces 1860 replace_in_string(' ', ' ', ' '), 1861 % add a space on the end 1862 ht(string_concat(' ')), 1863 replace_in_string('?',' ? '), 1864 replace_in_string('!',' ! '), 1865 replace_in_string('.',' . '), 1866 % replace periods 1867 replace_in_string('. ',' periodMARK ') 1868 ],A,S). 1869 1870% ?- replace_periods("hi there bub. how are you.",X),to_list_of_sents(X,L). 1871% X = [hi, there, bub, '.', how, are, you, '.'], 1872% L = [[hi, there, bub, '.'], [how, are, you, '.']] . 1873% 1874% ?- replace_periods_string_list("hi there bub! how are you?",X),to_list_of_sents(X,L). 1875% X = [hi, there, bub, !, how, are, you, ?], 1876% L = [[hi, there, bub, !], [how, are, you, ?]] . 1877 1878 1879%=
1885to_list_of_sents([],[]). 1886to_list_of_sents(WList,[sent(FirstSent)|Groups]):-append(Left,[Last|Rest],WList),member(Last,['.','?','!']),!,append(Left,[Last],FirstSent),!,to_list_of_sents(Rest,Groups). 1887to_list_of_sents(WList,[sent(WList)]). 1888 1889 1890%=
1896replace_periods_string_list(A,S):-replace_periods(A,AR),to_word_list(AR,WL),replace_subst4(WL,periodMARK,'.',WLS),replace_subst4(WLS,apostraphyMARK,'\'',S). 1897 1898 1899replace_subst4( T1, S1, S2, T2 ) :- 1900 segment_subst4( T1, Pre, S1, Post ), 1901 append_subst4( S2, Post, S2_plus_Post ), 1902 append_subst4( Pre, S2_plus_Post, T2 ). 1903segment_subst4( T, Pre, S, Post ) :- 1904 segment_1_subst4( S, T, Pre, Post ). 1905segment_1_subst4( [], L, [], L ) :- !. 1906segment_1_subst4( [H|T_], [H|T], [], Post ) :- 1907 segment_1_subst4( T_, T, [], Post ), 1908 !. 1909segment_1_subst4( S, [H|T], [H|U], Post ) :- 1910 segment_1_subst4( S, T, U, Post ). 1911append_subst4( [], L, L ). 1912append_subst4( [H|T], L, [H|T1] ) :- 1913 append_subst4( T, L, T1 ). 1914 1915%=
1921to_word_list(A,SL):-var(A),!,A=SL. 1922to_word_list([],[]):-!. 1923to_word_list([I|L],List):-L==[],!,to_word_list(I,List). 1924to_word_list(I,List):- must((convert_to_cycString(I,M),listify(M,List))). 1925/* 1926to_word_list(A,SL):-once(quietly((unused_to_word_list_0(A,S0),(is_list(S0)->delete(S0,'',S);S=S0)))), 1927 maplist(as_atom,S,SSL),!, 1928 must(SSL=SL),!. 1929*/ 1930 1931% as_atom(A,A):-atom(A),!. 1932% 1933 1934%=
1940as_atom(A,A):-atom(A),!. 1941as_atom(T,A):- compound(T), \+ is_list(T),arg(_,T,M),atomic(M),as_atom(M,A),!. 1942as_atom(S,A):- catch(string_to_atom(S,A),_,fail),!. 1943as_atom(T,A):- term_to_atom(T,A). 1944 1945:- export(unused_to_word_list_0/2). 1946 1947%=
1953unused_to_word_list_0(V,V):-var(V),!. 1954unused_to_word_list_0([A],[A]):-number(A),!. 1955unused_to_word_list_0(E,[]):-empty_str(E),!. 1956unused_to_word_list_0([A|C],[A|C]):- string(A),!. 1957%unused_to_word_list_0(A,WList):- string(A),Final=` (period) `,replace_periods(A,Final,S), \+ (A=S),!,unused_to_word_list_0(S,WList),!. 1958%unused_to_word_list_0([A|C],[A|C]):- (atomic(A);catch((text_to_string([A|C],_),fail),_,true)),!. 1959unused_to_word_list_0(A,WList):- must(any_to_string(A,String)),!,must(text_to_string(String,Atom)),unused_to_word_list_2(Atom,WList),!. 1960 1961 1962 1963%=
1969read_stream_to_arglist(Input,[]):- at_end_of_stream(Input),!. 1970read_stream_to_arglist(Input,[]):- on_x_fail((once(wait_for_input([Input], Inputs, 0.01)),Inputs=[])),!. 1971read_stream_to_arglist(Input,[H|T]):-show_call(why,if_defined(lisp_read_from_input(Input,H))),!,(is_ending(H)->T=[];read_stream_to_arglist(Input,T)),!. 1972 1973 1974%=
1980is_ending(List):-nonvar(List),(is_list(List)->last(List,whitepace("\n"));List==whitepace("\n")). 1981 1982 1983%=
1989is_simple_split(S):-text_to_string(S,SS),split_string(SS,`().!\"\'`,`()`,O),!,O=[SS]. 1990 1991 1992%=
1998unused_to_word_list_2(Input,WList):-is_simple_split(Input),split_string(Input,' ',' ',WList),!. 1999unused_to_word_list_2(A,S):-atomSplit(A,S),!. 2000unused_to_word_list_2(Atom,WList):- atom_to_memory_file(Atom,File),open_memory_file(File,read,Stream),read_stream_to_arglist(Stream,WList). 2001unused_to_word_list_2(Input,WList):- open_string(Input,Stream),read_stream_to_arglist(Stream,WList). 2002unused_to_word_list_2(Input,Input). 2003 2004 2005%=
2011str_contains_all([],String):- dtrace(wdmsg(str_contains_all([],String))). 2012str_contains_all(A,String):- empty_string(String), dtrace(str_contains_all(A,String)). 2013str_contains_all(A,SL):- string_ci(SL,SLIC),SL\=SLIC,!,str_contains_all(A,SLIC). 2014str_contains_all(List,String):-str_contains_all0(List,String). 2015 2016 2017%=
2023str_contains_all0([],_). 2024str_contains_all0([A|Atoms],String):- 2025 string_ci(A,L), 2026 sub_string(String,_,_,Aft,L), 2027 sub_string(String,Aft,_,0,SubString),!, 2028 str_contains_all0(Atoms,SubString). 2029 2030 2031 2032%=
2038atoms_of(Var,[]):- (var(Var);Var==[]),!. 2039atoms_of(':',[]). 2040atoms_of('moo',[]). 2041atoms_of('xti',[]). 2042atoms_of('xxxxxxxxt',[]). 2043atoms_of(',',[]). 2044atoms_of(':-',[]). 2045atoms_of('$VAR',[]):-!. 2046atoms_of(Atom,[]):-number(Atom),!. 2047atoms_of(Atom,[Atom]):-atomic(Atom),!. 2048atoms_of([H|T],L):-!,atoms_of(H,HL),atoms_of(T,TL),append(HL,TL,L),!. 2049atoms_of(C,L):-C=..CL,atoms_of(CL,L),!. 2050 2051 2052%=
2058sort_by_strlen(List,Sorted):-predsort(longest_string,List,Sorted). 2059 2060% longest_string(?Order, @Term1, @Term2) 2061 2062%=
2068longest_string(Order,TStr1,TStr2):- 2069 text_to_string(TStr1,Str1),string_length(Str1,L1), 2070 text_to_string(TStr2,Str2),string_length(Str2,L2), 2071 compare(Order,L2-Str2,L1-Str1). 2072 2073 2074% this is a backwards compatablity block for SWI-Prolog 6.6.6 2075:- retract(double_quotes_was_strings(WAS)),set_prolog_flag(double_quotes,WAS). 2076 2077:- system:use_module(library(logicmoo_startup)). 2078 2079:- logicmoo_util_strings:fixup_exports. 2080 2081cfunctor31(A,B,C):- compound(A)->compound_name_arity(A,B,C);functor(A,B,C). 2082:- ignore((source_location(S,_),prolog_load_context(module,M),module_property(M,class(library)), 2083 forall(source_file(M:H,S), 2084 ignore((cfunctor31(H,F,A), 2085 ignore(((atom(F),\+ atom_concat('$',_,F),(export(F/A) , current_predicate(system:F/A)->true; system:import(M:F/A))))), 2086 ignore(((\+ predicate_property(M:H,transparent), module_transparent(M:F/A), \+ atom_concat('__aux',_,F),debug(modules,'~N:- module_transparent((~q)/~q).~n',[F,A]))))))))).
Utility LOGICMOO_UTIL_STRINGS
This module introduces string replacements for find replacement in strings, capitalization, etc for text normalization. @author Douglas R. Miles @license LGPL */