#] #] ********************* #] "$d_Qtest"'symbols flatliner derivations/symbols translate- develop.txt' - # www.BillHowell.ca 04Apr2018 initial # view this file in a text editor, with [constant width font, tab = 3 spaces], no line-wrap # 06Jul2018 general instructions for symbol [extract,translate] see : "$d_PROJECTS"'Lucas - Universal Force/3 Instructions - symbols extractions and translations.txt' # 24************************24 # Table of Contents : # $ grep "^#]" "$d_Qtest"'symbols flatliner derivations/symbols translate- develop.txt' | sed 's/^#\]/ /' ********************* "$d_Qtest"'symbols flatliner derivations/symbols translate- develop.txt' - 04May2018 symTranslate_expressions IS OP str_in - searches str_in for strings in transExpr_table 13Apr2018cold reboot, qnial loads OK, but 15Apr2018 symTranslate_string - renaming of translate_string and upgrades 15Apr2018 sed_prep_string 14Apr2018 remove these operators to keep the code simple find_expression_test IS - test correctness of results using known results symTranslate_file_test 11May2018 log file of output 18May2018 Change translations to pick the [right trans-table, TransExpre_tables] 20May2018 08:11 YIKES!!! I need to get rid of this, as flag_strProtected is no longer useful!! 20May2018 I have a problem with substitutions WITHIN symbols (YIKES!!!!) 20May2018 RESTART on : I have a problem with substitutions WITHIN symbols (YIKES!!!!) 22May2018 15:48 Re-ran full set of tests except [symTranslate_file_test] via symTranslate_alltest 22May2018 Now [test,edit] cycle symTranslate_file_test 24May2018 Code No longer used 24May2018 Test again after many code changes 24May2018 Now to run symTranslate_alltest, which now includes symExtract_alltest 26May2018 code changes to replace chrs_before_after_str_i by chrStr_get 31May2018 stupid wild-goose chase errors with find : 26Jun2018 symExpr_sub revamped to simply convert str to chrList, get rid of chrStr_get 28Jun2018 10: tests AFTER replacing chrStr_get_test with str_to_unicodeList 03Jul2018 11:02 symExpr_sub 03Jul2018 Now try symTranslate_string_test 03Jul2018 symTranslate_string_test - remaining FAILED 07Jul2018 symbols_compare_Lucas - producing symDiff files of "leftover symbols" 24Jul2018 Get rid of these - better to use general operators [readfile_list,readfile_table,writefile_table] 30Aug2018 13:31 Re-run symTranslate_alltest of "symbols translate- tests.ndf" 30Aug2018 15:13 xprs_ExtractTranslate IS OP str 30Aug2018 15:13 xprs_ExtractTranslate IS OP str 19Nov2018 Fix strOfType_extractFindTrans_symExpr 20Nov2018 I need more tests : 20Nov2018 strOfType_trn_symListsInnTrn - don't use string_sub for Parns!!!! 27Nov2018 after changing strStd_extract_symParnPosn, 29Nov2018 strOfType_extTranSub_symGenl failures 29Nov2018 strStdForm_extractTranslate_symGenl_test failures 29Nov2018 List of remaining problem examples after fixing 30Nov2018 Tackle strOfType_extTranSub_symGenl_test example 1 30Nov2018 strOfType_extTranSub_symGenl - need to better handle translations! 01Dec2018 removed - because of new [strOfType_extract_exprs, strOfType_translate_symGenl] 18Mar2019 It seems that I did a re-naming of operators as per : 20Mar2019 Run symbols [extract, translate] tests using new code 24************************24 # 08********08 # transLucas is no longer used, see instead "/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf" # To run : # 1. below, create a "trans IS " sequence, specifying filepaths (see transLucas example) # 2. qnial> loaddefs link d_Qnial_mine 'symbols translate.ndf' # 3. qnial> "trans" # 4. manually edit pname_out (usually required as notations are relatively [incomplete, ambiguous]) # # transLucas IS - for project : Lucas Universal force # 16Apr2018 I don't use this anymore - see "/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf" symTrans_Lucas IS { LOCAL d_work fname_inn fname_trn fname_bad ; NONLOCAL d_Qnial_temp ; % ; IF (file_exists '-d' '/media/bill/PROJECTS/Lucas - Universal Force/') THEN d_work := '/media/bill/PROJECTS/Lucas - Universal Force/' ; ELSEIF (file_exists '-d' '/media/bill/SWAPPER/Lucas - Universal Force/') THEN d_work := '/media/bill/SWAPPER/Lucas - Universal Force/' ; ELSE write 'transLucas ERROR : d_Lucas not found' ; ENDIF ; % ; pname_inn := link d_work 'symbols translate inn.txt' ; pname_out := link d_work 'symbols translate out.txt' ; p_symbols := link d_work 'symbols translate Lucas.ndf' ; loaddefs p_symbols ; % ; translate_file pname_inn pname_out ; } # transLucas # 08********08 # symTranslate IS OP symbol - returns translation of a given symbol, or the symbol itself # 09Apr2018 - need to specify translation "dictionaries"! (not just use default names!) # 02May2018 keep [spaces,tabs] outside of symbols, standard form within symTranslate IS OP symbol { LOCAL symNew ; NONLOCAL sym_chrs trans_old trans_new trans_msg trans_rows ; %write_debug find_Howell symbol trans_old ; symNew := (find_Howell symbol trans_old) choose trans_new ; % this returns a SINGLE (not a solitary!) ; %write_debug trans_new@(find_Howell symbol trans_old) ; IF (isfault symNew) THEN symNew := symbol ; ELSEIF (= null (gage shape symNew)) THEN symNew := first symNew ; ENDIF ; symNew } # don't need special conditions that return null : ELSEIF (= symbol symNew) THEN null ; ELSE symNew := fault '?symTranslate - no translation' ; qnial> symTranslate_test # symTranslate_test example 1 : OK - result matches standard t_input, t_standard, t_result = Rocs(POIo) Rocs(POIo) Rocs(POIo) # symTranslate_test example 2 : OK - result matches standard t_input, t_standard, t_result = Rocs Rocs Rocs # symTranslate_test example 3 : OK - result matches standard t_input, t_standard, t_result = Ei(ro - vo*t,t) Ei(ro - vo*t,t) Ei(ro - vo*t,t) # symTranslate_test example 4 : OK - result matches standard t_input, t_standard, t_result = dp[dt : |Ei(ro - vo*t,t)|] dp[dt : |Ei(ro - vo*t,t)|] dp[dt : |Ei(ro - vo*t,t)|] # symTranslate_test example 5 : OK - result matches standard t_input, t_standard, t_result = dp ∂ ∂ # symTranslate_test example 6 : OK - result matches standard t_input, t_standard, t_result = Ei EIodv EIodv # symTranslate_test example 7 : OK - result matches standard t_input, t_standard, t_result = Rocs(POIo) Rocs(POIo) Rocs(POIo) # symTranslate_test example 8 : OK - result matches standard t_input, t_standard, t_result = - has too many "c"'s - has too many "c"'s - has too many "c"'s # symTranslate_test example 9 : OK - result matches standard t_input, t_standard, t_result = - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. >> OK - all results are good >> symTranslate expects a "standard form" single symbol to translate. This symbol must match on in the trans_table in order for it to be changed. # 08********08 #] 04May2018 symTranslate_expressions IS OP str_in - searches str_in for strings in transExpr_table # and produces a list of found strings a list of their translations # 03May2018 initial # 03May2018 - the current version expects the format of the string (eg [spaces,tabs,caps,etc]) to match the "dictionary" symTranslate_expressions IS OP str_in { LOCAL i str_no_parens xprList_raw trnList_xpr ; NONLOCAL transExpr_old transExpr_new transExpr_msg transExpr_rows ; % ; xprList_raw trnList_xpr := null null ; FOR i WITH tell transExpr_rows DO % note that escapes must be removed to be able to recognize the expressions in the text ; write_debug (str_no_parens := sed '''s/\\//g''' transExpr_old@i) ; IF (string_in transExpr_old@i str_no_parens) THEN xprList_raw := link xprList_raw (solitary transExpr_old@i) ; trnList_xpr := link trnList_xpr (solitary transExpr_new@i) ; ENDIF ; ENDFOR ; EACH write_debug '[xprList_raw trnList_xpr]= ' xprList_raw trnList_xpr ; % ; xprList_raw trnList_xpr } symTranslate_expressions_test IS { LOCAL sed_expr stringer t_input t_standard t_result ; % ; t_name := '# symTranslate_expressions_test example 6' ; t_input := ' + 1/Rocs(POIo)/c*dp[dt : | Ei(ro - vo*t,t) |] ] ' ; t_standard := ' + 1/Rocs(POIo)/c*∂[∂t : | EIodv(POIp(t),t) |] ] ' ; t_result := symTranslate_expressions t_input ; test_comment t_name t_input t_standard t_result ; } 04May2018 10:51 qnial> symTranslate_expressions_test cat: /media/ramdisk/QNial string_in.txt: No such file or directory cat: /media/ramdisk/QNial string_in.txt: No such file or directory cat: /media/ramdisk/QNial string_in.txt: No such file or directory cat: /media/ramdisk/QNial string_in.txt: No such file or directory cat: /media/ramdisk/QNial string_in.txt: No such file or directory cat: /media/ramdisk/QNial string_in.txt: No such file or directory cat: /media/ramdisk/QNial string_in.txt: No such file or directory cat: /media/ramdisk/QNial string_in.txt: No such file or directory cat: /media/ramdisk/QNial string_in.txt: No such file or directory cat: /media/ramdisk/QNial string_in.txt: No such file or directory cat: /media/ramdisk/QNial string_in.txt: No such file or directory # symTranslate_expressions_test example 6 : FAILED - result does NOT match standard t_input, t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : | Ei(ro - vo*t,t) |] ] + 1/Rocs(POIo)/c*∂[∂t : | EIodv(POIp(t),t) |] ] +------------------------------------------------------------------------------------------------------------- |+---------------+------------------+--------------+------------+--------------+------------+-----------+----- |||EIodv(POIo,t)|||Ei(ro - vo\*t,t)|||rov - vov\*t|||ro - vo\*t|||ros - vos\*t||ros - vos\*t|rov - vo\*t|rov - |+---------------+------------------+--------------+------------+--------------+------------+-----------+----- +------------------------------------------------------------------------------------------------------------- --------------------------------------+----------------------------------------------------------------------- -------+----------+--------+---------+|+-------------+----------------+----------+----------+----------+------ vov\*t|ro - vo\*t|ro - vot|vovrpv|||EIods(POIo,t)|EIods(POIp(t),t)|Rpcs(POIp)|Rpcs(POIp)|Rpcs(POIp)|Rpcs(P -------+----------+--------+---------+|+-------------+----------------+----------+----------+----------+------ --------------------------------------+----------------------------------------------------------------------- ----------------------------------------------------------------+ ----+----------+----------+----------+----------+--------------+| OIp)|Rpcv(POIp)|Rpcv(POIp)|Rpcv(POIp)|Rpcv(POIp)|???Vonv_X_Rpcv|| ----+----------+----------+----------+----------+--------------+| ----------------------------------------------------------------+ >> Works well, but why the "cat: /media/ramdisk/QNial string_in.txt: No such file or directory" ? strings.ndf : string_in_strList IS OP Substr Str_list { LOCAL f_name fot grepper ; IF (~= null f_name := '/media/ramdisk/QNial string_in.txt' ; fot := open f_name "w ; fot EACHRIGHT writefile Str_list ; close fot ; grepper := host link 'cat "' f_name '" | grep -i "' Substr '"' ; IF (= null grepper) THEN o ELSE l ENDIF } >> may the strings are empty? Seems to be so A couple of simple fixes and : qnial> symTranslate_expressions_test # symTranslate_expressions_test example 6 : OK - result matches standard t_input, t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : | Ei(ro - vo*t,t) |] ] +------------------------------------------------------------------------------------------------------------- |+---------------+------------------+--------------+------------+--------------+------------+-----------+----- |||EIodv(POIo,t)|||Ei(ro - vo\*t,t)|||rov - vov\*t|||ro - vo\*t|||ros - vos\*t||ros - vos\*t|rov - vo\*t|rov - |+---------------+------------------+--------------+------------+--------------+------------+-----------+----- +------------------------------------------------------------------------------------------------------------- --------------------------------------+----------------------------------------------------------------------- -------+----------+--------+---------+|+-------------+----------------+----------+----------+----------+------ vov\*t|ro - vo\*t|ro - vot|vovrpv|||EIods(POIo,t)|EIods(POIp(t),t)|Rpcs(POIp)|Rpcs(POIp)|Rpcs(POIp)|Rpcs(P -------+----------+--------+---------+|+-------------+----------------+----------+----------+----------+------ --------------------------------------+----------------------------------------------------------------------- ----------------------------------------------------------------+ ----+----------+----------+----------+----------+--------------+| OIp)|Rpcv(POIp)|Rpcv(POIp)|Rpcv(POIp)|Rpcv(POIp)|???Vonv_X_Rpcv|| ----+----------+----------+----------+----------+--------------+| ----------------------------------------------------------------+ +------------------------------------------------------------------------------------------------------------- |+---------------+------------------+--------------+------------+--------------+------------+-----------+----- |||EIodv(POIo,t)|||Ei(ro - vo\*t,t)|||rov - vov\*t|||ro - vo\*t|||ros - vos\*t||ros - vos\*t|rov - vo\*t|rov - |+---------------+------------------+--------------+------------+--------------+------------+-----------+----- +------------------------------------------------------------------------------------------------------------- --------------------------------------+----------------------------------------------------------------------- -------+----------+--------+---------+|+-------------+----------------+----------+----------+----------+------ vov\*t|ro - vo\*t|ro - vot|vovrpv|||EIods(POIo,t)|EIods(POIp(t),t)|Rpcs(POIp)|Rpcs(POIp)|Rpcs(POIp)|Rpcs(P -------+----------+--------+---------+|+-------------+----------------+----------+----------+----------+------ --------------------------------------+----------------------------------------------------------------------- ----------------------------------------------------------------+ ----+----------+----------+----------+----------+--------------+| OIp)|Rpcv(POIp)|Rpcv(POIp)|Rpcv(POIp)|Rpcv(POIp)|???Vonv_X_Rpcv|| ----+----------+----------+----------+----------+--------------+| ----------------------------------------------------------------+ YIKES! string_instrList always returns true!! # 04May2018 after a greeat deal of time to fix string_in qnial> symTranslate_expressions_test # symTranslate_expressions_test example 1 : OK - result matches standard t_input, t_standard, t_result = - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) +++ ||| +++ +++ ||| +++ >> This is fine, as there are NO expressions in transExpr_table sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected >> What is the problem here? # symTranslate_expressions_test example 2 : OK - result matches standard t_input, t_standard, t_result = - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. +++ ||| +++ +++ ||| +++ >> WRONG! "|ro - vo*t|" is in transExpr_table, so there should be one hit rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory # symTranslate_expressions_test example 3 : OK - result matches standard t_input, t_standard, t_result = - I have NO real idea of why the (ros*cosOo - vos*t) pops up anyways, and why the cos term all of a sudden (sp herical coords does not explain this!) +++ ||| +++ +++ ||| +++ >> This is fine, as there are NO expressions in transExpr_table # symTranslate_expressions_test example 4 : OK - result matches standard t_input, t_standard, t_result = - has too many "c"'s +++ ||| +++ +++ ||| +++ >> This is fine, as there are NO expressions in transExpr_table # symTranslate_expressions_test example 5 : OK - result matches standard t_input, t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] +++ ||| +++ +++ ||| +++ >> WRONG! "|Ei(ro - vo*t,t)|" is in transExpr_table, so there should be one hit # symTranslate_expressions_test example 6 : OK - result matches standard t_input, t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : | Ei(ro - vo*t,t) |] ] +++ ||| +++ +++ ||| +++ >> SORT-OF WRONG! "| Ei(ro - vo*t,t) |" is NOT in transExpr_table >> but I need to find these legimate hits? (... sometime in the future) # symTranslate_expressions_test example 7 : OK - result matches standard t_input, t_standard, t_result = = vos/c*Rocs(POIo)*sinOo*q/|rov - vo*t|^3*Pph +++ ||| +++ +++ ||| +++ >> OK "|rov - vo*t|" is NOT in transExpr_table, but I just added it # symTranslate_expressions_test example 8 : OK - result matches standard t_input, t_standard, t_result = = vos/c*Rocs(POIo)/|rov - vo*t|*sinOo*Pph +++ ||| +++ +++ ||| +++ >> WRONG! "|rov - vo*t|" is in transExpr_table, so there should be one hit # symTranslate_expressions_test example 9 : FAILED - result does NOT match standard t_input, t_standard, t_result = HLFN = q/c*(vovrpv)/rps^2 + vov/cEi(rp,tp) +++ ||| +++ +-----------+----------------+ |+---------+|+--------------+| ||vovrpv|||???Vonv_X_Rpcv|| |+---------+|+--------------+| +-----------+----------------+ >> OK, this is correct, I just have to set t_standard 04May2018 16:52 Ah Hah!! Because string_in has the normal problem with '$.*/[\]^' characters, so the escape should NOT be removed by transExpr_no_esc := sed '''s/\\//g''' transExpr_old@i ; qnial> string_in 'rov - vo*t' '= vos/c*Rocs(POIo)*sinOo*q/|rov - vo*t|^3*Pph ' o qnial> string_in 'rov - vo\*t' '= vos/c*Rocs(POIo)*sinOo*q/|rov - vo*t|^3*Pph ' l Try in_string : qnial> in_string 'rov - vo*t' '= vos/c*Rocs(POIo)*sinOo*q/|rov - vo*t|^3*Pph ' l qnial> in_string 'rov - vo\*t' '= vos/c*Rocs(POIo)*sinOo*q/|rov - vo*t|^3*Pph ' o # symTranslate_expressions_test example 7 : OK - result matches standard t_input, t_standard, t_result = = vos/c*Rocs(POIo)*sinOo*q/|rov - vo*t|^3*Pph +---------------------------+-----------------------+ |+-------------+-----------+|+----------+----------+| |||rov - vo\*t||rov - vo\*t|||Rpcs(POIp)|Rpcv(POIp)|| |+-------------+-----------+|+----------+----------+| +---------------------------+-----------------------+ +---------------------------+-----------------------+ |+-------------+-----------+|+----------+----------+| |||rov - vo\*t||rov - vo\*t|||Rpcs(POIp)|Rpcv(POIp)|| |+-------------+-----------+|+----------+----------+| +---------------------------+-----------------------+ # 04May2018 17:12 qnial> symTranslate_expressions_test # symTranslate_expressions_test example 1 : OK - result matches standard t_input, t_standard, t_result = - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) +++ ||| +++ +++ ||| +++ sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected # symTranslate_expressions_test example 2 : OK - result matches standard t_input, t_standard, t_result = - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. +++ ||| +++ +++ ||| +++ rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory # symTranslate_expressions_test example 3 : OK - result matches standard t_input, t_standard, t_result = - I have NO real idea of why the (ros*cosOo - vos*t) pops up anyways, and why the cos term all of a sudden (sp herical coords does not explain this!) +++ ||| +++ +++ ||| +++ # symTranslate_expressions_test example 4 : OK - result matches standard t_input, t_standard, t_result = - has too many "c"'s +++ ||| +++ +++ ||| +++ # symTranslate_expressions_test example 5 : OK - result matches standard t_input, t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] +-------------------------------+-----------------------------+ |+------------------+----------+|+----------------+----------+| |||Ei(ro - vo\*t,t)||ro - vo\*t|||EIods(POIp(t),t)|Rpcv(POIp)|| |+------------------+----------+|+----------------+----------+| +-------------------------------+-----------------------------+ +-------------------------------+-----------------------------+ |+------------------+----------+|+----------------+----------+| |||Ei(ro - vo\*t,t)||ro - vo\*t|||EIods(POIp(t),t)|Rpcv(POIp)|| |+------------------+----------+|+----------------+----------+| +-------------------------------+-----------------------------+ # symTranslate_expressions_test example 6 : OK - result matches standard t_input, t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : | Ei(ro - vo*t,t) |] ] +------------+------------+ |+----------+|+----------+| ||ro - vo\*t|||Rpcv(POIp)|| |+----------+|+----------+| +------------+------------+ +------------+------------+ |+----------+|+----------+| ||ro - vo\*t|||Rpcv(POIp)|| |+----------+|+----------+| +------------+------------+ # symTranslate_expressions_test example 7 : OK - result matches standard t_input, t_standard, t_result = = vos/c*Rocs(POIo)*sinOo*q/|rov - vo*t|^3*Pph +---------------------------+-----------------------+ |+-------------+-----------+|+----------+----------+| |||rov - vo\*t||rov - vo\*t|||Rpcs(POIp)|Rpcv(POIp)|| |+-------------+-----------+|+----------+----------+| +---------------------------+-----------------------+ +---------------------------+-----------------------+ |+-------------+-----------+|+----------+----------+| |||rov - vo\*t||rov - vo\*t|||Rpcs(POIp)|Rpcv(POIp)|| |+-------------+-----------+|+----------+----------+| +---------------------------+-----------------------+ # symTranslate_expressions_test example 8 : OK - result matches standard t_input, t_standard, t_result = = vos/c*Rocs(POIo)/|rov - vo*t|*sinOo*Pph +---------------------------+-----------------------+ |+-------------+-----------+|+----------+----------+| |||rov - vo\*t||rov - vo\*t|||Rpcs(POIp)|Rpcv(POIp)|| |+-------------+-----------+|+----------+----------+| +---------------------------+-----------------------+ +---------------------------+-----------------------+ |+-------------+-----------+|+----------+----------+| |||rov - vo\*t||rov - vo\*t|||Rpcs(POIp)|Rpcv(POIp)|| |+-------------+-----------+|+----------+----------+| +---------------------------+-----------------------+ # symTranslate_expressions_test example 9 : OK - result matches standard t_input, t_standard, t_result = HLFN = q/c*(vovrpv)/rps^2 + vov/cEi(rp,tp) +-----------+----------------+ |+---------+|+--------------+| ||vovrpv|||???Vonv_X_Rpcv|| |+---------+|+--------------+| +-----------+----------------+ +-----------+----------------+ |+---------+|+--------------+| ||vovrpv|||???Vonv_X_Rpcv|| |+---------+|+--------------+| +-----------+----------------+ >> OK - all of the examples work well!! strange issue is stdout : sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory >> I'll worry about that some other time... 05May2018 re-tested to make sure no corription : >> I had since introduced mistakes with t_standard for 3 or 4 tests (probably copy-over of old set of "full tests" for #5) >> Once fixed, eveything works as before >> KEY problem arises with example 2, likely due to quotes : sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory ... Looking at problem parising with example 2, likely due to quotes : sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory >> The "rm" error is not really a problem per se, but it will be messy when trying to follow high-order operators Check "string_in transExpr_old@i str_in" for example 2 >> I made the "rm" conditional : IF (file_exists p_name) THEN host link 'rm "' p_name '" ' ; ENDIF ; >> has a grep : host link 'echo "' str_in '" | grep -i "' substr '" >"' p_name '" ' ; I modified to catch "rm" and empty output : string_in IS OPERATION substr str_in { LOCAL fin flag_inString p_name ; p_name := link d_Qnial_temp 'string_in results.txt' ; flag_inString := fault 'string_in' ; IF (file_exists p_name) THEN host link 'rm "' p_name '" ' ; ENDIF ; host link 'echo "' str_in '" | grep -i "' substr '" >"' p_name '" ' ; IF (file_exists p_name) THEN fin := open p_name "r ; flag_inString := readfile fin ; close fin ; ENDIF ; %write 'flag_instring= ' flag_instring ; IF (isfault flag_inString) THEN o ELSE l ENDIF } qnial> symTranslate_expressions_test sh: 1: Syntax error: "(" unexpected sh: 1: Syntax error: "(" unexpected ... 13 line-repeated >> so I have eliminated the error : rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory >> but now to fix the parenthesis error I changed the quotes around str_in to apostrophes : cmd := link 'echo ''' str_in ''' | grep -i "' substr '" >"' p_name '" ' ; >> now it seems to work! Re-test all : >> now example #3 doesn't work!!! I need to pretreat str_in OR use a bash script OR use in_string -> much simpler Try in_string first The problem is transExpr_table which has the escape character needed by sed, but poison to QNial I created a copy table without escape characters qnial> symTranslate_expressions_test >> all are OK # 08********08 # translate_string IS OP stringer # original from 02Jan2018 initial - problem of corruption of normal text with simple character sequences that aren't part of expressions translate_string IS OP stringer { LOCAL i textnew ; NONLOCAL trans_old trans_new trans_msg trans_rows ; textnew := stringer ; FOR i WITH tell trans_rows DO textnew := regexp_substitute trans_old@i trans_new@i textnew ; ENDFOR ; textnew } # tests # regexp_substitute 'AOpc(POIo,t)' '***check***' ' = Vons(particle)^2/c*sin(AOpc(POIo,t))^2*cos(AOpc(POIo,t))*Rodh(Vonv_X_Rpcv(POIo(t),t))' # >> OK, that worked # regexp_substitute 'turkey' '***check***' ' = Vons(particle)^2/c*sin(AOpc(POIo,t))^2*cos(AOpc(POIo,t))*Rodh(Vonv_X_Rpcv(POIo(t),t))' # 04Apr2018 new version using sed # g - at end of "s" expression, denote find all occurrences # 07Apr2018 must escape [*,"[" in the expressions to be replaced!! What about "|"? ; # see "symbols translate Lucas.ndf" - easiest to do this in the translation tables for now # YIKES - must do in code, as many "illegal-for-sed" characters are in the files!!! # see "strings.ndf" for : escape_sed_illegals IS OP string # Use sed_prep_string to properly setup the string for translation via dictionary # this isn't much help as you manually have to prepare the string!! # maybe easier to simply edit a temp file! # 09Apr2018 see "sed" in "/media/bill/PROJECTS/Qnial/MY_NDFS/strings.ndf" # to use a single sed_expr to process a string # 08Apr2018 15:53 textnew := link '"' (sed sed_expr textnew) '"' ; # translate_string ' = Vons(particle)^2/c*sin(AOpc(POIo,t))^2*cos(AOpc(POIo,t))*Rodh(Vonv_X_Rpcv(POIo))' # translate_string '" = Vons(particle)^2/c*sin(AOpc(POIo,t))^2*cos(AOpc(POIo,t))*Rodh(Vonv_X_Rpcv(POIo(t),t))"' >> OK # the following tests done AFTER "escape_sed_illegals" was introduced # translate_string '#------> (4-16) 'E,B for symmetry point charge @v_const ' ' ?undefined identifier: translate_string '#------> (4-16) ' E <***> , B FOR >> error as expected above, but why didn't escape_sed_illegals help? - "\" not right solution here, need double apostrophe! >> test with : # translate_string '#------> (4-16) \'E,B for symmetry point charge @v_const \' ' >> as expected, same problem # translate_string '#------> (4-16) ''E,B for symmetry point charge @v_const ''' # translate_string '- I have NO real idea of why the (ros*cosOo - vos*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!)' # old tests stringer := '- has the term "(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|" in the first term in parenthesis. ' ; qnial> translate_string_test rm: cannot remove ‘/media/bill/RaspPi_ext4_32Gb/temp/sed_temp.txt’: No such file or directory string_in= '- has the term \"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' textnew= '''- has the term \\"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\\" in the first term in parenthesis. ''' sh: 1: Syntax error: "(" unexpected ^C >> I had to exit qnial >> translate_string comment out : %textnew := sed_prep_string stringer ; >> I need a "translate" version of sed, that DOESN'T double-apply sed_prep_string, allowing the modifications and allows string to be an argument! >> see translate_sed above qnial> translate_string_test no stdout?!! >> OOPS, remove ";" to get return value ?op_parameter >> Nuts, no what? translate_string IS OP string_in, take out sed_expr qnial> translate_string_test ^C >> had to rebot - activate one of the write statements >> OOps "bus error - RapsPi locked up with Thunderbird email!! all write textnew return empty, must be a problem with stringer? qnial> translate_string_test '- has the term \"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' sed: -e expression #1, char 65: Unmatched ( or \( (... 2 empty lines ...) sed: -e expression #1, char 69: Unmatched ( or \( >> activate writes in translate_string ..same problem... '- has the term \"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' sed: -e expression #1, char 65: Unmatched ( or \( '- has the term \"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' sed: -e expression #1, char 65: Unmatched ( or \( qnial> translate_string_test rm: cannot remove ‘/media/bill/RaspPi_ext4_32Gb/temp/sed_temp.txt’: No such file or directory sed: -e expression #1, char 69: Unmatched ( or \( (... 2 empty lines ...) sed: -e expression #1, char 69: Unmatched ( or \( >> char 65 in string_in is just after # Manually change : stringer := '- has the term \"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' ; qnial> translate_string_test - has the term \"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\" in the first term in parenthesis. '- has the term \\"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\\" in the first term in parenthesis. ' sh: 1: Syntax error: "(" unexpected ^C >> Better, but still not there yet. >> translate_string remove : textnew := sed_prep_string string_in ; >> put in : textnew := string_in ; qnial> translate_string_test - has the term \"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\" in the first term in parenthesis. - has the term \"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\" in the first term in parenthesis. rm: cannot remove ‘/media/bill/RaspPi_ext4_32Gb/temp/sed_temp.txt’: No such file or directory sed: -e expression #1, char 65: Unmatched ( or \( ( ... 2 empty lines ...) sed: -e expression #1, char 69: Unmatched ( or \( >> Now runs through entire list of trans_new, but results are all null >> Add [start, end] apos!!! to translate_sed : textnew := link `' string_in `' ; qnial> translate_string_test '- has the term \\"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\\" in the first term in parenthesis. ' sh: 1: Syntax error: "(" unexpected ^C >> Closer - now have too many "\". Remove from stringer! # stringer := '- has the term "(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|" in the first term in parenthesis. ' ; qnial> translate_string_test can't load log file >> I had to close qnial window and relaunch qnial qnial> translate_string_test '- has the term \\"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\\" in the first term in parenthesis. ' sh: 1: Syntax error: "(" unexpected ^C >> too many "\" ? qnial> translate_string_test '- has the term \"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' sed: -e expression #1, char 65: Unmatched ( or \( '' '''''''''' sed: -e expression #1, char 69: Unmatched ( or \( '' '''''''''' '''''''''''''''''''''''''' failed to open log file >> back to previous problem, close terminal, open another start qnial >> backslash all quotes in translate_string_test, add only [start,end] apos qnial> translate_string_test >> same problem of apos-only output >> translate_string change textnew := sed_prep_string translate_sed sed_expr textnew ; >> to : textnew := translate_sed sed_expr textnew ; qnial> translate_string_test '- has the term \"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' sed: -e expression #1, char 65: Unmatched ( or \( ... '' sed: -e expression #1, char 69: Unmatched ( or \( ... '' '''' '''''' '''''''' >> Neat - pyramid growth of apos, no problem of log file... >> Initial textnew is correct, but gives error "sed: -e expression #1..." >> Insert another write to find out exactly where problem occurs, In translate_string : write link (string i) ' ' textnew ; qnial> translate_string_test '- has the term \"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' 0 '- has the term \"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' sed: -e expression #1, char 65: Unmatched ( or \( ... 1 '' 2 '' sed: -e expression #1, char 69: Unmatched ( or \( ... 3 '' 4 '' '''' 5 '''' '''''' >> similar to before, but now I know error occurred during 1st sed >> that initial augmented textnew is the SAME as the one that works in sed_test : sed_test '- has the term \"(ros*cosOo - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' translate_string'- has the term \"(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' >> but the first "translate_sed sed_expr textnew ; " fails. Why? # stringer := '- has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. ' ; >> Put sed_prep_string in the FOR loop!! : textnew := sed_prep_string textnew ; qnial> translate_string_test 0 a ' ?no_value ' ^C >> YIKES - something really wrong. Before FOR loop, I was missing : textnew := string_in ; qnial> translate_string_test 0a '- has the term \"(ros*cosOo - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' rm: cannot remove ‘/media/bill/RaspPi_ext4_32Gb/temp/sed_temp.txt’: No such file or directory sed: -e expression #1, char 65: Unmatched ( or \( 0b 1a '' 1b '''' 2a '''''''''' sed: -e expression #1, char 69: Unmatched ( or \( 2b 3a '' 3b '''' 4a '''''''''' 4b '''''''''''' 5a '''''''''''''''''''''''''' 5b '''''''''''''''''''''''''''' 6a '''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 6b '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 7a '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''' 7b ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''' >> NUTS again. At least 0a textnew is OK >> take away [start, end] apos in translate_sed : %textnew := link `' string_in `' ; qnial> translate_string_test sed_expr= "s/\([^A-Za-z0-9θφ]\)\(d\(dt :\)\([^A-Za-z0-9θφ]\)/\1d[dt:\3/g" 0a '- has the term \"(ros*cosOo - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' ^C >> qnial freezes with translate_sed >> In translate_sed replace : s_out := null ; WHILE (~= ??eof (line_in := readfile fin)) DO s_out := link s_out (solitary line_in) ; ENDWHILE ; IF (~= ??eof s_out) THEN s_out := (null EACHRIGHT unequal s_out) sublist s_out ; IF (= 1 (gage shape s_out)) THEN s_out := first s_out ; ENDIF ; ENDIF ; >> with : s_out := readfile fin ; qnial> translate_string_test sed_expr= "s/\([^A-Za-z0-9θφ]\)\(d\(dt :\)\([^A-Za-z0-9θφ]\)/\1d[dt:\3/g" 0a '- has the term \"(ros*cosOo - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' rm: cannot remove ‘/media/bill/RaspPi_ext4_32Gb/temp/sed_temp.txt’: No such file or directory ^C >> again, qnial freezes with translate_sed # stringer := '- has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. ' ; >> in translate_sed change : host link ' echo "' textnew '" | sed ' sed_expr ' >"' p_sed '" ' ; >> to : host link ' echo ' string_in ' | sed ' sed_expr ' >"' p_sed '" ' ; qnial> translate_string_test sed_expr= "s/\([^A-Za-z0-9θφ]\)\(d\(dt :\)\([^A-Za-z0-9θφ]\)/\1d[dt:\3/g" 0a '- has the term \"(ros*cosOo - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' rm: cannot remove ‘/media/bill/RaspPi_ext4_32Gb/temp/sed_temp.txt’: No such file or directory sed: -e expression #1, char 65: Unmatched ( or \( 0 b ?eof sed_expr= "s/\([^A-Za-z0-9θφ]\)\(dp\[dt:\)\([^A-Za-z0-9θφ]\)/\1∂[∂t:\3/g" 1 a ' ?eof ' 1 b ?arg must be file port sed_expr= "s/\([^A-Za-z0-9θφ]\)\(dp\(dt:\)\([^A-Za-z0-9θφ]\)/\1∂[∂t:\3/g" 2 a ' ?arg must be file port ' rm: cannot remove ‘/media/bill/RaspPi_ext4_32Gb/temp/sed_temp.txt’: No such file or directory 2 b ?arg must be file port sed_expr= "s/\([^A-Za-z0-9θφ]\)\(Bi(rov - vov\*t,t)\)\([^A-Za-z0-9θφ]\)/\1BIodv(POIo,t)\3/g" 3 a ' ?arg must be file port ' rm: cannot remove ‘/media/bill/RaspPi_ext4_32Gb/temp/sed_temp.txt’: No such file or directory 3 b ?arg must be file port sed_expr= "s/\([^A-Za-z0-9θφ]\)\(Bi(ro - vo\*t,t)\)\([^A-Za-z0-9θφ]\)/\1BIodv(POIo,t)\3/g" 4 a ' ?arg must be file port ' rm: cannot remove ‘/media/bill/RaspPi_ext4_32Gb/temp/sed_temp.txt’: No such file or directory 4 b ?arg must be file port >> Progress, of a sort # 10Apr2018 coming back, after fixing sed_file >> translate_file comment out : %sed_prep_file pname_inn pname_prep ; >> translate_file change : fin := open pname_prep "r ; >> to : fin := open pname_inn "r ; qnial> test_translate_file 1a /media/bill/PROJECTS/Lucas - Universal Force/translate inn.txt sed: -e expression #1, char 65: Unmatched ( or \( 1 4 6 b ?eof 147a sed: -e expression #1, char 65: Unmatched ( or \( 1 4 6 b ?eof 147a - has too many "c"'s sed: -e expression #1, char 65: Unmatched ( or \( 1 4 6 b ?eof 147a - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. sed: -e expression #1, char 65: Unmatched ( or \( 1 4 6 b ?eof 147a - I have NO real idea of why the (ros*cosOo - vos*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!) sed: -e expression #1, char 65: Unmatched ( or \( 1 4 6 b ?eof 147a sed: -e expression #1, char 65: Unmatched ( or \( 1 4 6 b ?eof >> same problems as before # >> I had fixed a BIG omission - that of the index "i" as required by : sed_expr := link '"s/\([^' sym_chars ']\)\(' trans_old@i '\)\([^' sym_chars ']\)/\1' trans_new@i '\3/g"' ; >> no I have a mix-up between I for WHILE and i for FOR qnial> test_translate_file 0a /media/bill/PROJECTS/Lucas - Universal Force/translate inn.txt sed: -e expression #1, char 65: Unmatched ( or \( 0 b ?eof 1a sed: -e expression #1, char 65: Unmatched ( or \( 1 b ?eof 2a - has too many "c"'s sed: -e expression #1, char 65: Unmatched ( or \( 2 b ?eof 3a - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. sed: -e expression #1, char 65: Unmatched ( or \( 3 b ?eof >> now about the error: sed: -e expression #1, char 65: Unmatched ( or \( >> this is the sed_expr, first two letters of : ']\)/\1' trans_new@i >> write sed_expr to see qnial> test_translate_file "s/\([^A-Za-z0-9θφ]\)\(Rpdv(POIo,t)\)\([^A-Za-z0-9θφ]\)/\1Rpdv(POIo(t),t)\3/g": "s/\([^A-Za-z0-9θφ]\)\(R pdv(POIo,t)\)\([^A-Za-z0-9θφ]\)/\1Rpdv(POIo(t),t)\3/g" 1 5 b ?eof >> It seems that the colon is causing a problem? >> reactivate illegal_chars in sed_prep_string >> OR, for now, insert escapes in "symbols translate Lucas.ndf" >> 11Aug2018 NYET - was due to misplaced apo, change to : write link 'sed_expr : ' sed_expr ; qnial> test_translate_file >> 12Apr2018 Try copy-pasting file content to new file (stray special characters?). test9 ?undefined identifier: % ; test99 ?undefined identifier: 'trans_file_out.txt' ; TRANSLATE_FILE <***> PNAME_INN PNAME_PREP ?undefined identifier: % ; ?undefined identifier: 'trans_long_out.txt' ; TRANSLATE_FILE_LONG <***> PNAME_DIFF PNAME_INN ?undefined identifier: 'translate symsCheck Lucas.txt' ; TRANSLATE_FILE <***> FNAME_INN >>>>> loading "symbols translate Lucas.ndf" <<<<< done loading "symbols translate Lucas.ndf" <<<<< done loading symbols translate.ndf errors found: 5 >> NOPE, that didn't help #] 13Apr2018cold reboot, qnial loads OK, but qnial> loaddefs link d_Qnial_mine 'symbols translate.ndf' >>>>> loading symbols translate.ndf test9 ?undefined identifier: % ; test99 ?undefined identifier: 'trans_file_out.txt' ; TRANSLATE_FILE <***> PNAME_INN PNAME_PREP ?undefined identifier: % ; ?undefined identifier: 'trans_long_out.txt' ; TRANSLATE_FILE_LONG <***> PNAME_DIFF PNAME_INN ?undefined identifier: 'translate symsCheck Lucas.txt' ; TRANSLATE_FILE <***> FNAME_INN <<<<< done loading symbols translate.ndf errors found: 5 >> same old problem!!! 14Apr2018 now What!?!?!? In strings.ndf : # 10Apr2018 no longer used sed_prep_file IS OP pname_inn pname_prep { LOCAL fin fot i stringer_new ; % ; fin := open pname_inn "r ; fot := open pname_prep "w ; WHILE (??eof <> (str_in := readfile fin)) DO s_out := string `' ; s_len := gage shape str_in ; FOR i WITH tell s_len DO IF (= `' str_in@i) THEN s_out := s_out link `\ ; ENDIF ; IF (= `" str_in@i) THEN s_out := s_out link `\ ; ENDIF ; s_out := s_out link str_in@i ; ENDFOR ; s_out := s_out link `' ; writefile fot s_out ; ENDWHILE ; EACH close fin fot ; } BUT - this is still used in "symbols translate.ndf"!! so uncomment above & reload qnial> loaddefs link d_Qnial_mine 'symbols translate.ndf' qnial> lq_strings loading : strings.ndf qnial> qnial> loaddefs link d_Qnial_mine 'symbols translate.ndf' >>>>> loading symbols translate.ndf >> loading translate_file >> loading translate_file_test >> loading translate_file_long >> loading translate_file_long_test ?SCAN - missing ' at end of string: ' ; ?undefined identifier: TRANSLUCAS <***> <<<<< done loading symbols translate.ndf errors found: 2 o >> SUCCESS!! arrrggghhh! what a blind idiot! 15Apr2018 after code changes qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf' /media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf Sun Apr 15 09:13:19 2018 ?undefined identifier: SED_FILE SED_EXPR STR_INN <***> } ?undefined identifier: TRANSLATE_STRING_TEST <***> ^C >> oops, I modified & beefed up examples for translate_string_test # translate_string_test example 4 : OK - result matches standard t_input= - has too many "c"'s t_standard, t_result_trimmed = - has too many "c"'s - has too many "c"'s ^C >> translate_string_test - [examples [1,2,3] FAILED, example 4 OK >> translate_file_test - infinite loop, see below for its changes >> check sed tests to see if it was corrupted : >>>> sed_prep_string_test - all examples OK >>>> sed_test - only example 1 FAILEd (as before - strange failure!) >>>> sed_file_test - OK +-----+ /media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf Sun Apr 15 09:28:02 2018 # translate_string_test example 1 : FAILED - result does NOT match standard t_input= - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) t_standard, t_result = - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(cos(Aθoc(POIo))) # translate_string_test example 2 : FAILED - result does NOT match standard t_input= - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. t_standard, t_result = - has the term "(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|" in the first term in parenthesis. - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. # translate_string_test example 3 : FAILED - result does NOT match standard t_input= - I have NO real idea of why the (ros*cosOo - vos*t) pops up anyways, and why the cos term all of a sudden (sp herical coords does not explain this!) t_standard, t_result = - I have NO real idea of why the (ros*cos(Aθoc(POIo)) - vos*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!) - I have NO real idea of why the (ros*cosOo - vos*t) pops up anyways, and why the cos term all of a sudden (sp herical coords does not explain this!) # translate_string_test example 4 : OK - result matches standard t_input= - has too many "c"'s t_standard, t_result_trimmed = - has too many "c"'s - has too many "c"'s +-----+ >> example 1 is weird - solve later (how does cos double-substitute?) >> example [2, 3] - substitutions not made for [ros, cosOo, vos*t, |ro - vo*t|] - WHY? >> I need a FOR loop! - Actually, there is a FOR loop! >> translate_string_test - comment out all except example 2, activate write_debugs qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf' /media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf Sun Apr 15 10:21:50 2018 # translate_string_test example 2 : FAILED - result does NOT match standard t_input= - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. t_standard, t_result = - has the term "(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|" in the first term in parenthesis. - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. >> WHAT? - only tries one because it calls sed - I need to call qnial> trans_rows unassigned >> trans_table isn't loaded! - this was a problem of a trailing apce in the file name! >> I changed to translate_string : t_result := translate_string sed_expr t_input ; >> It is only doing one string (last example) : 146 : - has too many "c"'s qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf' /media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf Sun Apr 15 10:46:41 2018 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+---------+------------------------------------------------------------------- |t|e|x|t|n|e|w| |s|t|a|r|t| |=| |?no_value|- has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+---------+------------------------------------------------------------------- -----------------+ in parenthesis. | -----------------+ s e d _ e x p r = " s / \ ( [ ^ ?no_value ] \ ) \ ( R p d v ( P O I o , t ) \ ) \ ( [ ^ ?no_value ] \ ) / \ 1 R p d v ( P O I o ( t ) , t ) \ 3 / g " 146 : - has too many "c"'s # translate_string_test example 2 : FAILED - result does NOT match standard t_input= - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. t_standard, t_result = - has the term "(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|" in the first term in parenthesis. - has too many "c"'s >> OOPS, had sed_expr as argument, change line to : t_result := translate_string t_input ; >> changed "sym_chars" to "sym_chrs" qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf' /media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf Sun Apr 15 10:56:47 2018 textnew start = - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. sed_expr= "s/\([^A-Za-z0-9θφ]\)\(d(dt :\)\([^A-Za-z0-9θφ]\)/\1d[dt:\3/g" 0 : - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. sed_expr= "s/\([^A-Za-z0-9θφ]\)\(dp[dt:\)\([^A-Za-z0-9θφ]\)/\1∂[∂t:\3/g" sed: -e expression #1, char 68: invalid reference \3 on `s' command's RHS 1 : sed_expr= "s/\([^A-Za-z0-9θφ]\)\(dp(dt:\)\([^A-Za-z0-9θφ]\)/\1∂[∂t:\3/g" 2 : >> Now there's a problem with characters - but I hadn't seen this with sed? >> use sed to debug this NOW - keeping work in this file >> 15Apr2018 I added sed_test t_name := '# sed_test example 5' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(dp[dt\)\([^' sym_chrs ']\)/\1∂[∂t\3/g"' ; t_input := ' - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_standard := ' - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) ' ; t_result := sed sed_expr t_input ; test_comment t_name t_input t_standard t_result ; qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/strings- tests.ndf' sed: -e expression #1, char 66: invalid reference \3 on `s' command's RHS # sed_test example 5 : FAILED - result does NOT match standard t_input= - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) t_standard, t_result = - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) >> In "/media/bill/PROJECTS/Lucas - Universal Force/symbols translate Lucas.ndf" : >> try escaping trans_olds : example dp\[dt 'd(dt' 'd[dt' (solitary msg_Lucas) 'dp\[dt' '∂[∂t' (solitary msg_Lucas) 'dp(dt' '∂[∂t' (solitary msg_Lucas) 'd(dt:' 'd[dt:' (solitary msg_Lucas) 'dp\[dt:' '∂[∂t:' (solitary msg_Lucas) 'dp(dt:' '∂[∂t:' (solitary msg_Lucas) >> trans_table is irrelevant to sed_test as sed_expr must be supplied >> in "strings- tests.ndf" sed_test IS { LOCAL t_name t_input t_standard t_result ; EACH write ' ' ' ' '#+-----+' ; % ; t_name := '# sed_test example 5' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(dp[dt\)\([^' sym_chrs ']\)/\1∂[∂t\3/g"' ; t_input := ' - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_standard := ' - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) ' ; t_result := sed sed_expr t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# sed_test example 6' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(dp\[dt\)\([^' sym_chrs ']\)/\1∂[∂t\3/g"' ; write_debug link 'sed_expr= ' sed_expr ; t_input := ' - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_standard := ' - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) ' ; t_result := sed sed_expr t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# sed_test example 7' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(dp[dt\)\([^' sym_chrs ']\)/\1∂\[∂t\3/g"' ; write_debug link 'sed_expr= ' sed_expr ; t_input := ' - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_standard := ' - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) ' ; t_result := sed sed_expr t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# sed_test example 8' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(dp(dt\)\([^' sym_chrs ']\)/\1∂[∂t\3/g"' ; write_debug link 'sed_expr= ' sed_expr ; t_input := ' - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_standard := ' - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) ' ; t_result := sed sed_expr t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# sed_test example 9' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(dp\(dt\)\([^' sym_chrs ']\)/\1∂[∂t\3/g"' ; write_debug link 'sed_expr= ' sed_expr ; t_input := ' - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_standard := ' - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) ' ; t_result := sed sed_expr t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# sed_test example 10' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(dp(dt\)\([^' sym_chrs ']\)/\1∂\[∂t\3/g"' ; t_input := ' - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_standard := ' - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) ' ; t_result := sed sed_expr t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# sed_test example 11' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(dp\[dt\)\([^' sym_chrs ']\)/\1∂[∂t\3/g"' ; write_debug link 'sed_expr= ' sed_expr ; t_input := ' - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_standard := ' - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) ' ; %t_result := sed sed_expr t_input ; %test_comment t_name t_input t_standard t_result ; % ; t_name := '# sed_test example 12' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(dp[dt\)\([^' sym_chrs ']\)/\1∂\[∂t\3/g"' ; write_debug link 'sed_expr= ' sed_expr ; t_input := ' - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_standard := ' - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) ' ; %t_result := sed sed_expr t_input ; %test_comment t_name t_input t_standard t_result ; % ; t_name := '# sed_test example 13' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(dp\[dt\)\([^' sym_chrs ']\)/\1∂\[∂t\3/g"' ; write_debug link 'sed_expr= ' sed_expr ; t_input := ' - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_standard := ' - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) ' ; %t_result := sed sed_expr t_input ; %test_comment t_name t_input t_standard t_result ; } qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/strings- tests.ndf' +-----+ /media/bill/PROJECTS/Qnial/code tests/strings- tests.ndf Sun Apr 15 12:04:33 2018 sed: -e expression #1, char 66: invalid reference \3 on `s' command's RHS # sed_test example 5 : FAILED - result does NOT match standard t_input= - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) t_standard, t_result = - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) sed_expr= "s/\([^A-Za-z0-9θφ]\)\(dp\[dt\)\([^A-Za-z0-9θφ]\)/\1∂[∂t\3/g" # sed_test example 6 : FAILED - result does NOT match standard t_input= - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) t_standard, t_result = - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) sed_expr= "s/\([^A-Za-z0-9θφ]\)\(dp[dt\)\([^A-Za-z0-9θφ]\)/\1∂\[∂t\3/g" sed: -e expression #1, char 67: invalid reference \3 on `s' command's RHS # sed_test example 7 : FAILED - result does NOT match standard t_input= - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) t_standard, t_result = - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) sed_expr= "s/\([^A-Za-z0-9θφ]\)\(dp(dt\)\([^A-Za-z0-9θφ]\)/\1∂[∂t\3/g" # sed_test example 8 : FAILED - result does NOT match standard t_input= - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) t_standard, t_result = - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) sed_expr= "s/\([^A-Za-z0-9θφ]\)\(dp\(dt\)\([^A-Za-z0-9θφ]\)/\1∂[∂t\3/g" sed: -e expression #1, char 67: Unmatched ( or \( # sed_test example 9 : FAILED - result does NOT match standard t_input= - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) t_standard, t_result = - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) # sed_test example 10 : FAILED - result does NOT match standard t_input= - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) t_standard, t_result = - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) sed_expr= "s/\([^A-Za-z0-9θφ]\)\(dp\[dt\)\([^A-Za-z0-9θφ]\)/\1∂[∂t\3/g" sed_expr= "s/\([^A-Za-z0-9θφ]\)\(dp[dt\)\([^A-Za-z0-9θφ]\)/\1∂\[∂t\3/g" sed_expr= "s/\([^A-Za-z0-9θφ]\)\(dp\[dt\)\([^A-Za-z0-9θφ]\)/\1∂\[∂t\3/g" +-----+ >> All 6 "live" tests failed, >> no result [5,7,9] {dp[dt ∂[∂t, dp[dt ∂\[∂t, dp\(dt ∂[∂t} >> result produced [6,8,10] {dp\[dt ∂[∂t, dp(dt ∂[∂t , dp(dt ∂\[∂t} >> CONCLUSIONS find pattern : escape "[" don't escape "(" (this makes sense as it is an important sed "code") replace pattern : escape ???, don't escape "[" sed_test IS { LOCAL t_name t_input t_standard t_result ; EACH write ' ' ' ' '#+-----+' ; % ; t_name := '# sed_test example 6' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(dp\[dt\)\([^' sym_chrs ']\)/\1∂[∂t\3/g"' ; write_debug link 'sed_expr= ' sed_expr ; t_input := ' - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_standard := ' - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_result := sed sed_expr t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# sed_test example 8' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(dp(dt\)\([^' sym_chrs ']\)/\1∂[∂t\3/g"' ; write_debug link 'sed_expr= ' sed_expr ; t_input := ' - dp(dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_standard := ' - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_result := sed sed_expr t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# sed_test example 10' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(dp(dt\)\([^' sym_chrs ']\)/\1∂\[∂t\3/g"' ; t_input := ' - dp(dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_standard := ' - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_result := sed sed_expr t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# sed_test example 11' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(|Ei(rov - vov*t,t)|\)\([^' sym_chrs ']\)/\1EIods(POIp(t),t)\3/g"' ; write_debug link 'sed_expr= ' sed_expr ; t_input := ' + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] ' ; t_standard := ' + 1/Rocs(POIo)/c*dp[dt : EIods(POIp(t),t)] ] ' ; t_result := sed sed_expr t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# sed_test example 12' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(\|Ei(rov - vov*t,t)\|\)\([^' sym_chrs ']\)/\1EIods(POIp(t),t)\3/g"' ; write_debug link 'sed_expr= ' sed_expr ; t_input := ' + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] ' ; t_standard := ' + 1/Rocs(POIo)/c*dp[dt : EIods(POIp(t),t)] ] ' ; t_result := sed sed_expr t_input ; test_comment t_name t_input t_standard t_result ; } qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/strings- tests.ndf' /media/bill/PROJECTS/Qnial/code tests/strings- tests.ndf Sun Apr 15 12:38:01 2018 sed_expr= "s/\([^A-Za-z0-9θφ]\)\(dp\[dt\)\([^A-Za-z0-9θφ]\)/\1∂[∂t\3/g" # sed_test example 6 : OK - result matches standard t_input= - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) t_standard, t_result_trimmed = - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) sed_expr= "s/\([^A-Za-z0-9θφ]\)\(dp(dt\)\([^A-Za-z0-9θφ]\)/\1∂[∂t\3/g" # sed_test example 8 : OK - result matches standard t_input= - dp(dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) t_standard, t_result_trimmed = - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) # sed_test example 10 : OK - result matches standard t_input= - dp(dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) t_standard, t_result_trimmed = - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) sed_expr= "s/\([^A-Za-z0-9θφ]\)\(|Ei(rov - vov*t,t)|\)\([^A-Za-z0-9θφ]\)/\1EIods(POIp(t),t)\3/g" # sed_test example 11 : FAILED - result does NOT match standard t_input= + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : EIods(POIp(t),t)] ] + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] sed_expr= "s/\([^A-Za-z0-9θφ]\)\(\|Ei(rov - vov*t,t)\|\)\([^A-Za-z0-9θφ]\)/\1EIods(POIp(t),t)\3/g" # sed_test example 12 : FAILED - result does NOT match standard t_input= + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : EIods(POIp(t),t)] ] EIods(POIp(t),t) EIods(POIp(t),t) EIods(POIp(t),t) EIods(POIp(t),t) EIods(POIp(t),t)+ 1/Rocs(POIo)EIods(PO Ip(t),t)/c*dp[dt EIods(POIp(t),t): EIods(POIp(t),t)|Ei(ro EIods(POIp(t),t)- vo*t,t)EIods(POIp(t),t)|]EIods(POI p(t),t) ]EIods(POIp(t),t) >> Oops - should have |Ei(rov - vo*t,t)| , retry >> 15Apr2018 sed CONCLUSIONS update find pattern : escape "[" don't escape "(" (this makes sense as it is an important sed "code") don't escape "|" - weird things happen, but sed won't replace |Ei(rov - vo*t,t)| replace pattern : escape - may not help, but may not hurt? don't escape "[" ??? sed_test IS { LOCAL t_name t_input t_standard t_result ; EACH write ' ' ' ' '#+-----+' ; % ; t_name := '# sed_test example 14' ; sed_expr := link '"s/\([^' sym_chrs ']\)\([|]Ei(rov - vo*t,t)[|]\)\([^' sym_chrs ']\)/\1EIods(POIp(t),t)\3/g"' ; write_debug link 'sed_expr= ' sed_expr ; t_input := ' + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] ' ; t_standard := ' + 1/Rocs(POIo)/c*dp[dt : EIods(POIp(t),t)] ] ' ; t_result := sed sed_expr t_input ; test_comment t_name t_input t_standard t_result ; } qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/strings- tests.ndf' /media/bill/PROJECTS/Qnial/code tests/strings- tests.ndf Sun Apr 15 13:52:57 2018 sed_expr= "s/\([^A-Za-z0-9θφ]\)\([|]Ei(rov - vo*t,t)[|]\)\([^A-Za-z0-9θφ]\)/\1EIods(POIp(t),t)\3/g" # sed_test example 14 : FAILED - result does NOT match standard t_input= + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : EIods(POIp(t),t)] ] + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] sed_test IS { LOCAL t_name t_input t_standard t_result ; EACH write ' ' ' ' '#+-----+' ; % ; t_name := '# sed_test example 15' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(|Ei(rov - vo\*t,t)|\)\([^' sym_chrs ']\)/\1EIods(POIp(t),t)\3/g"' ; write_debug link 'sed_expr= ' sed_expr ; t_input := ' + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] ' ; t_standard := ' + 1/Rocs(POIo)/c*dp[dt : EIods(POIp(t),t)] ] ' ; t_result := sed sed_expr t_input ; test_comment t_name t_input t_standard t_result ; } qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/strings- tests.ndf' /media/bill/PROJECTS/Qnial/code tests/strings- tests.ndf Sun Apr 15 14:00:48 2018 sed_expr= "s/\([^A-Za-z0-9θφ]\)\(|Ei(rov - vo\*t,t)|\)\([^A-Za-z0-9θφ]\)/\1EIods(POIp(t),t)\3/g" # sed_test example 15 : FAILED - result does NOT match standard t_input= + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : EIods(POIp(t),t)] ] + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] sed_test IS { LOCAL t_name t_input t_standard t_result ; EACH write ' ' ' ' '#+-----+' ; % ; t_name := '# sed_test example 16' ; sed_expr := link '"s/\([^' sym_chrs ']\)\(\|Ei(rov - vo\*t,t)\|\)\([^' sym_chrs ']\)/\1EIods(POIp(t),t)\3/g"' ; write_debug link 'sed_expr= ' sed_expr ; t_input := ' + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] ' ; t_standard := ' + 1/Rocs(POIo)/c*dp[dt : EIods(POIp(t),t)] ] ' ; t_result := sed sed_expr t_input ; test_comment t_name t_input t_standard t_result ; } qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/strings- tests.ndf' /media/bill/PROJECTS/Qnial/code tests/strings- tests.ndf Sun Apr 15 14:11:25 2018 sed_expr= "s/\([^A-Za-z0-9θφ]\)\(\|Ei(rov - vo\*t,t)\|\)\([^A-Za-z0-9θφ]\)/\1EIods(POIp(t),t)\3/g" # sed_test example 16 : FAILED - result does NOT match standard t_input= + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : EIods(POIp(t),t)] ] EIods(POIp(t),t) EIods(POIp(t),t) EIods(POIp(t),t) EIods(POIp(t),t) EIods(POIp(t),t)+ 1/Rocs(POIo)EIods(PO Ip(t),t)/c*dp[dt EIods(POIp(t),t): EIods(POIp(t),t)|Ei(ro EIods(POIp(t),t)- vo*t,t)EIods(POIp(t),t)|]EIods(POI p(t),t) ]EIods(POIp(t),t) 15Aug2018 For now, I give up on "|" - come back to it later, just remove "|" from patterns Retry translate_string - see "/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf" translate_string_test IS { LOCAL sed_expr stringer t_input t_standard t_result ; % ; t_name := '# translate_string_test example 1' ; t_input := ' - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) ' ; t_standard := ' - ∂[∂t : EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) ' ; t_result := translate_string t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# translate_string_test example 2' ; t_input := '- has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. ' ; t_standard := '- has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/|Rpcs(POIp)|" in the first term in parenthesis. ' ; t_result := translate_string t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# translate_string_test example 3' ; t_input := '- I have NO real idea of why the (ros*cosOo - vos*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!)' ; t_standard := '- I have NO real idea of why the (Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!)' ; t_result := translate_string t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# translate_string_test example 4' ; t_input := link '- has too many ' `" 'c' `" `' 's' ; t_standard := '- has too many "c"''s' ; t_result := translate_string t_input ; test_comment t_name t_input t_standard t_result ; } qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf' /media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf Sun Apr 15 14:36:40 2018 # translate_string_test example 1 : OK - result matches standard t_input= - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) t_standard, t_result_trimmed = - ∂[∂t : EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) - ∂[∂t : EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) # translate_string_test example 2 : OK - result matches standard t_input= - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. t_standard, t_result_trimmed = - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/|Rpcs(POIp)|" in the first term in parenthesis. - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/|Rpcs(POIp)|" in the first term in parenthesis. # translate_string_test example 3 : OK - result matches standard t_input= - I have NO real idea of why the (ros*cosOo - vos*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!) t_standard, t_result_trimmed = - I have NO real idea of why the (Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!) - I have NO real idea of why the (Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!) # translate_string_test example 4 : OK - result matches standard t_input= - has too many "c"'s t_standard, t_result_trimmed = - has too many "c"'s - has too many "c"'s translate_string_test IS { LOCAL sed_expr stringer t_input t_standard t_result ; % ; t_name := '# translate_string_test example 5' ; t_input := ' + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] ' ; t_standard := ' + 1/Rocs(POIo)/c*dp[dt : EIods(POIp(t),t)] ] ' ; t_result := translate_string t_input ; test_comment t_name t_input t_standard t_result ; } qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf' /media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf Sun Apr 15 14:53:33 2018 # translate_string_test example 5 : FAILED - result does NOT match standard t_input= + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : EIods(POIp(t),t)] ] + 1/Rocs(POIo)/c*∂[∂t : |EIodv(POIp(t),t)|] ] # translate_string_test example 5 >> GREAT FAILURE! Two intersting parts : >> 1) I haven't been able to include "|" in the patterns >> 2) |Ei(ro - vo*t,t)| becomes EIodv(POIp(t),t), which IS WRONG!! >> I need to remove "|" from patterns, to make sure the proper vector expression comes out >> and is enclosed by "|" >> Actually, almost all that was done - I just had to update t_standard translate_string_test IS { LOCAL sed_expr stringer t_input t_standard t_result ; % ; t_name := '# translate_string_test example 5' ; t_input := ' + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] ' ; t_standard := ' + 1/Rocs(POIo)/c*∂[∂t : |EIodv(POIp(t),t)|] ] ' ; t_result := translate_string t_input ; test_comment t_name t_input t_standard t_result ; } qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf' /media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf Sun Apr 15 15:07:26 2018 # translate_string_test example 5 : OK - result matches standard t_input= + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] t_standard, t_result_trimmed = + 1/Rocs(POIo)/c*∂[∂t : |EIodv(POIp(t),t)|] ] + 1/Rocs(POIo)/c*∂[∂t : |EIodv(POIp(t),t)|] ] >> perfect! 15Apr2018 20:30 first pass of : qnial> translate_file_test d_Lucas := '/media/bill/PROJECTS/Lucas - Universal Force/' ; pname_diff := link d_QNial_temp 'trans_file_diff.txt' ; pname_inn := link d_Lucas 'Howell - math of Lucas Universal Force.txt' ; pname_out := link d_QNial_temp 'trans_file_out.txt' ; >> [pname_out, renamed] to d_Lucas : Howell - math z2 of Lucas Universal Force.txt >> main "missing" translations are just before a "/" in translate_inn >> pname_out was full of "# Lucas := ". Why, and was the processing terminated early because of a [pattern,replacement]? >> many, many "undone" translations # 08********08 #] 15Apr2018 symTranslate_string - renaming of translate_string and upgrades 15Apr2018 after code changes (from "translate_string" comments above) qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf' ... /C >> translate_string_test - [examples [1,2,3] FAILED, example 4 OK >> translate_file_test - infinite loop Old version of symTranslate_string is above NEW version of symTranslate_string uses symTranslate (a more efficient search is needed!) symTranslate IS OP symbol { LOCAL symNew ; NONLOCAL sym_chrs trans_old trans_new trans_msg trans_rows ; symNew := (find_Howell symbol trans_old) find trans_new ; IF (isfault symNew) THEN symNew := symbol ; ENDIF ; symNew } symTranslate_string IS OP str_in { LOCAL i sed_expr textnew ; NONLOCAL sym_chrs trans_old trans_new trans_msg trans_rows ; % ; textnew := str_in ; %write_debug link 'textnew start = ' textnew ; IF (= `$ str_in@0) THEN textnew := str_in ; ELSE symList_raw := symExtract_string textnew ; symList_std := EACH sym_stdForm symList_raw ; tranList := EACH symTranslate symList_std ; FOR i WITH tell gage shape symList DO sed_expr := link '"s/\([^' sym_chrs ']\)\(' symList_raw@i '\)\([^' sym_chrs ']\)/\1' tranList@i '\3/g"' ; %write_debug link 'sed_expr= ' sed_expr ; textnew := sed sed_expr textnew ; %write_debug link (string i) ' : ' textnew ; ENDFOR ; ENDIF ; textnew } Run "symTranslate_string_test" : >> After working at it for several hours (simplified operators), : qnial> symTranslate_string_test # symTranslate_string_test example 1 : OK - result matches standard t_input, t_standard, t_result = - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) - ∂[∂t : EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) - ∂[∂t : EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) # symTranslate_string_test example 2 : FAILED - result does NOT match standard t_input, t_standard, t_result = - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/|Rpcv(POIp)|" in the first term in parenthesis. - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/|Rocv(POIo) - Vonv(particle)*t|" in the first term in parenthesis. >> OUCH! substitution out of the blue... "ro - vo*t" should be "Rpcv(POIp)" -> can't work with "|" yet... >> 'ro - vo\*t' -> 'Rpcv(POIp)'. Instead - direct substitution for ro then vo\*t BEFORE >> I changed in "/media/bill/PROJECTS/Lucas - Universal Force/symbols badList Lucas.ndf" 'rov - vo\*t' 'rov - vo*t' 'needs explanation' 'rov - vo\*t' 'Rpcv(POIp)' 'needs explanation' # symTranslate_string_test example 3 : OK - result matches standard t_input, t_standard, t_result = - I have NO real idea of why the (ros*cosOo - vos*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!) - I have NO real idea of why the (Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!) - I have NO real idea of why the (Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!) # symTranslate_string_test example 4 : FAILED - result does NOT match standard t_input, t_standard, t_result = - has too many "c"'s - has too many "c"'s - has to o many "c"'s >> Interesting!! the simple English words will always cause some problems... # symTranslate_string_test example 5 : FAILED - result does NOT match standard t_input, t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] + 1/Rocs(POIo)/c*∂[∂t : |EIodv(POIp(t),t)|] ] + 1/Rocs(POIo)/c*∂[∂t : |EIodv(POIo,t)(Rocv(POIo) - Vonv(particle)*t,t)|] ] >> WHY the substitution? I can see EIodv(POIo,t), but why (Rocv(POIo) - Vonv(particle)*t,t)? 'Ei(ro - vo\*t,t)' 'EIodv(POIp(t),t)' (solitary msg_Lucas) >> should have worked, why not? - copy of 'Ei(ro - vo\*t,t)' PRECEDED other symbols in trans_table! >> 03May2018 still important to know how the result was obtained - weird Ei -> EIodv(POIo,t) (ro - vo*t,t) -> (Rocv(POIo) - Vonv(particle)*t,t) >> Ah Hah, that's it. Safer to put all Lucas notation lower than HFLN From "symTranslate_string_test example 4", keywords [from, to, over] must only be changed by sym_stdForm if surrounded by chrs_symbols_HFLN characters sym_stdForm_keyWd -> modified to sym_stdForm_keyWd IS OP str_trgt str_in { LOCAL sed_expr ; NONLOCAL chrs_blank chrs_stop_paren chrs_strt_paren chrs_symbols_HFLN ; sed_expr := link ' ''s/[' chrs_symbols_HFLN ']^\(' str_trgt '\)[' chrs_symbols_HFLN ']/\1' str_trgt '\2/g'' ' ; sed sed_expr str_in } 03Mar2018 Try it now : examples [2,4,5] STILL failed!! # 03May2018 these won't work, as only the components are extracted as symbols 'rov - vo\*t' 'Rpcv(POIp)' 'needs explanation' 'rov - vov\*t' 'Rpcv(POIp)' msg_Lucas_sol 'ro - vo\*t' 'Rpcv(POIp)' msg_Lucas_sol 'ros - vos\*t' 'Rpcv(POIp)' msg_Lucas_sol 'ro - vot' 'Rpcv(POIp)' msg_Lucas_sol However, this should have worked for [#2,#5]!!?? 'Ei(ro - vo\*t,t)' 'EIodv(POIp(t),t)' msg_Lucas_sol 'ro - vo\*t' 'Rpcv(POIp)' msg_Lucas_sol >> NO!!! only sub-symbols are extracted. Except I think #5 should still have worked. For example #4, I was missing a "^" Just focus on #5 with write_debug = l Ei(ro - vo*t,t) was not translated!! Why? Put spaces around and re-try >> no change. What is going wrong? Do ANY of the "compound symbol" expressions translate properly? MUST escape [*,etc] BEFORE sed -> use I added line : ELSEIF (in stringer@i '$.*/[\]^') THEN s_out := s_out link `\ ; to : sed_prep_string IS OP stringer { LOCAL i s_len s_out ; s_len := gage shape stringer ; s_out := `' ; FOR i WITH tell s_len DO IF (= `' stringer@i) THEN s_out := s_out link `' ; ELSEIF (in stringer@i '$.*/[\]^') THEN s_out := s_out link `\ ; ENDIF ; s_out := s_out link stringer@i ; ENDFOR ; s_out := link s_out `' ; %write_debug s_out ; s_out } >> NYET!!! This screwed up everything! Revert sed_prep_string to original. In "/symbols badList Lucas.ndf", I added transExpr_table := '|EIodv(POIo,t)|' 'EIods(POIo,t)' (msg_Lucas msg_abs) '|Ei(ro - vo*t,t)|' 'EIods(POIo,t)' (msg_Lucas msg_abs) '|rov - vov*t|' 'Rpcs(POIo(t),t)' (msg_Lucas msg_abs) '|ro - vo*t|' 'Rpcs(POIp)' (msg_Lucas msg_abs) '|ros - vos*t|' 'Rpcs(POIp)' (msg_Lucas msg_abs) 'rov - vo\*t' 'Rpcv(POIp)' msg_Lucas_sol 'rov - vov\*t' 'Rpcv(POIp)' msg_Lucas_sol 'ro - vo\*t' 'Rpcv(POIp)' msg_Lucas_sol 'ros - vos\*t' 'Rpcs(POIp)' msg_Lucas_sol 'ro - vot' 'Rpcv(POIp)' msg_Lucas_sol 'vovrpv' 'Vons(particle)Rpcv(POIp)' msg_Lucas_sol ; And modified "symTranslate_string" with addition : %first translate "compound symbol" expressions ; FOR i WITH tell transExpr_rows DO sed_expr := link '"s/\(' transExpr_old@i '\)/' transExpr_new@i '/g"' ; %write_debug link 'sed_expr= ' sed_expr ; textnew := sed sed_expr textnew ; %write_debug link (string i) ' : ' textnew ; ENDFOR ; # Try now... >> almost OK. I got : |Rpcv(POIp)|^3 instead of : Rpcs(POIp) >> "|" character problem again ... leave that problem for another time Re-test OK - examples [1,3] Fail - examples [2,4-9] : 2 - interesting 4 - "has to o many c's" -> still a failure!! (arrrggghhh! - probably due to "^" placement? [^' chrs_symbols_HFLN '] - should go at start of [^...] ) 5 - simply put in wrong translation in table, also changes by transExpr_table aren't caught by symTranslate_string 6 - challenging, as it is a mix of old & new symbols. It did what it was supposed to. fix operators later? actually 7 - |Rpcv(POIp)| wasn't converted to Rpcs(POIo(t),t) 8 - looks good, fix standard 9 - I put in the wrong translation Actions : 1. don't "overtranslate" Ei only to EIodv, etc 'Bi' 'BIodv' 'needs explanation' 'Eip' 'EIpdv' 'needs explanation' 'Ei' 'EIodv' 'needs explanation' I modified part of symTranslate_string to : symList_raw := symExtract_string -1 symExtract_2D textnew ; FOR i WITH tell gage shape symExpr_old DO row_new := find_HOWELL symExpr_new@i symList_raw ; symList_raw@row_new := symExpr_old@i ; ENDFOR ; symList_std := EACH sym_stdForm symList_raw ; qnial> symTranslate_string_test sed: -e expression #1, char 353: invalid reference \2 on `s' command's RHS sed: -e expression #1, char 349: invalid reference \2 on `s' command's RHS sed: -e expression #1, char 353: invalid reference \2 on `s' command's RHS >> Ouch. Rework a bit - especially [sym_stdForm_keyWd,symTranslate_string] Re-test OK - examples [1,3,5] Fail - examples [2,4,6-9] : 2 - What? seems to use t_results from example #1??? 4 - "has to o many c's" -> still a failure!! (arrrggghhh!) as I have lost apostrophes - has too many "c"'s - has too many c's 6 - what gives??? - substitutions are strange. Challenging, as it is a mix of old & new symbols. 7 - OK, but problem with "|" prevents |Rpcv(POIp)| from being converted to Rpcs(POIo(t),t) 8 - looks good - I can't see any difference between [t_standard,t_result]!!! 9 - OK when I corrected t_standard Example 2 - quotation marks are causing a problem? (it uses t_result from last example run!) put backslash and see what happens >> nyet try double-quotes >> almost - enclose quote - eg '"' # symTranslate_string_test example 2 : FAILED - result does NOT match standard t_input, t_standard, t_result = - has the term ""(ros*cosOo - vos*t)/|ro - vo*t|"" in the first term in parenthesis. - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/Rpcs(POIp)" in the first term in parenthesis. - has the term (Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/Rpcs(POIp) in the first term in parenthesis. >> aweful close!! >> I need to handle quotation marks, as they are important in the text!! look at sed_prep_string in strings.ndf I addeded : FOR i WITH tell s_len DO IF (= `' stringer@i) THEN s_out := s_out link `' ; ELSEIF (= `" stringer@i) THEN s_out := s_out link `" ; ENDIF ; s_out := s_out link stringer@i ; ENDFOR ; Number of quotes inserted : 1 - # symTranslate_string_test example 2 : FAILED - result does NOT match standard t_input, t_standard, t_result = - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/Rpcs(POIp)" in the first term in parenthesis. - has the term (Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/Rpcs(POIp) in the first term in parenthesis. 2 - # symTranslate_string_test example 2 : FAILED - result does NOT match standard t_input, t_standard, t_result = - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/Rpcs(POIp)" in the first term in parenthesis. - has the term (Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/Rpcs(POIp) in the first term in parenthesis. Try in sed_prep_string : FOR i WITH tell s_len DO IF (= `' stringer@i) THEN s_out := s_out link `' `' ; ELSEIF (= `" stringer@i) THEN s_out := s_out link `\ `" ; ELSE s_out := s_out link stringer@i ; ENDIF ; ENDFOR ; # symTranslate_string_test example 2 : OK - result matches standard t_input, t_standard, t_result = - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/Rpcs(POIp)" in the first term in parenthesis. - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/Rpcs(POIp)" in the first term in parenthesis. >> It worked!! Example #4 - given example #2 solution, it might work here as well? # symTranslate_string_test example 4 : OK - result matches standard t_input, t_standard, t_result = - has too many "c"'s - has too many "c"'s - has too many "c"'s >> OK - that's great Example #6 t_name := '# symTranslate_string_test example 6' ; t_input := ' + 1/Rocs(POIo)/c*dp[dt : | Ei(ro - vo*t,t) |] ] ' ; t_standard := ' + 1/Rocs(POIo)/c*∂[∂t : | EIodv(POIp(t),t) |] ] ' ; t_result := symTranslate_string t_input ; test_comment t_name t_input t_standard t_result ; [str_in,textnew,symList_raw,symList_std,tranList,symList_chg,tranList_chg]= + 1/Rocs(POIo)/c*dp[dt : | Ei(ro - vo*t,t) |] ] + 1/Rocs(POIo)/c*dp[dt : | Ei(Rpcv(POIp),t) |] ] +-+----------+-+-----------------------------+----+----+--+--+----------------+--+---------+-+----+----+ |1|Rocs(POIo)|c|dp[dt : | Ei(Rpcv(POIp),t) |]|Rocs|POIo|dp|dt|Ei(Rpcv(POIp),t)|Ei|ro - vo*t|t|Rpcv|POIp| +-+----------+-+-----------------------------+----+----+--+--+----------------+--+---------+-+----+----+ +-+----------+-+--------------------------+----+----+--+--+----------------+--+----------+-+----+----+ |1|Rocs(POIo)|c|dp[dt: |Ei(Rpcv(POIp),t)|]|Rocs|POIo|dp|dt|Ei(Rpcv(POIp),t)|Ei|Rpcv(POIp)|t|Rpcv|POIp| +-+----------+-+--------------------------+----+----+--+--+----------------+--+----------+-+----+----+ +-+----------+-+--------------------------+----+----+---+----+----------------+-----+----------+-+----+----+ |1|Rocs(POIo)|c|dp[dt: |Ei(Rpcv(POIp),t)|]|Rocs|POIo|∂|∂t|Ei(Rpcv(POIp),t)|EIodv|Rpcv(POIp)|t|Rpcv|POIp| +-+----------+-+--------------------------+----+----+---+----+----------------+-----+----------+-+----+----+ +-----------------------------+--+--+--+---------+ |dp[dt : | Ei(Rpcv(POIp),t) |]|dp|dt|Ei|ro - vo*t| +-----------------------------+--+--+--+---------+ +--------------------------+---+----+-----+----------+ |dp[dt: |Ei(Rpcv(POIp),t)|]|∂|∂t|EIodv|Rpcv(POIp)| +--------------------------+---+----+-----+----------+ # symTranslate_string_test example 6 : FAILED - result does NOT match standard t_input, t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : | Ei(ro - vo*t,t) |] ] + 1/Rocs(POIo)/c*∂[∂t : | EIodv(POIp(t),t) |] ] + 1/Rocs(POIo)/c*∂[∂t : | EIodv(Rpcv(POIp),t) |] ] >> This is interesting, as symList_raw has "lost" the Ei(ro - vo*t,t) Copy current operator for backup : symTranslate_string IS OP str_in { LOCAL i sed_expr symExpr_old symExpr_oldRaw symExpr_new symList_chg symList_raw symList_std textnew tranList tranList_chg ; NONLOCAL sym_chrs trans_old trans_new trans_msg trans_rows transExpr_old transExpr_new transExpr_msg transExpr_rows ; % ; textnew := str_in ; %write_debug link 'textnew start = ' textnew ; symExpr_old symExpr_new := null null ; IF (~= `$ str_in@0) THEN %first translate "compound symbol" expressions ; FOR i WITH tell transExpr_rows DO sed_expr := link '"s/\(' transExpr_old@i '\)/' transExpr_new@i '/g"' ; %write_debug link 'sed_expr= ' sed_expr ; textExpr := sed sed_expr textnew ; IF (~= textExpr textnew) THEN symExpr_old := link symExpr_old (solitary transExpr_old@i) ; symExpr_new := link symExpr_new (solitary transExpr_new@i) ; textnew := textExpr ; ENDIF ; %write_debug link (string i) ' : ' textnew ; ENDFOR ; EACH write_debug '[symExpr_old symExpr_new]= ' symExpr_old symExpr_new ; % now translate "real" symbols ; symList_raw := symExtract_string -1 symExtract_2D textnew ; symList_std := EACH sym_stdForm symList_raw ; IF (~= null symExpr_old) THEN FOR i WITH tell gage shape symExpr_old DO row_new := find_HOWELL symExpr_new@i symList_raw ; %remove any backslashes ; IF (NOT isfault row_new) THEN symExpr_oldRaw := sed '''s/\\//g''' symExpr_old@i ; symList_raw@row_new := symExpr_oldRaw ; ENDIF ; ENDFOR ; ENDIF ; tranList := EACH symTranslate symList_std ; symList_chg tranList_chg := (EACHBOTH ~= symList_raw tranList) EACHRIGHT sublist symList_raw tranList ; EACH write_debug '[str_in,textnew,symList_raw,symList_std,tranList,symList_chg,tranList_chg]= ' str_in textnew symList_raw symList_std tranList symList_chg tranList_chg ; FOR i WITH tell gage shape symList_chg DO sed_expr := link '"s/\([^' sym_chrs ']\)\(' symList_chg@i '\)\([^' sym_chrs ']\)/\1' tranList_chg@i '\3/g"' ; %write_debug link 'sed_expr= ' sed_expr ; textnew := sed sed_expr textnew ; %write_debug link (string i) ' : ' textnew ; ENDFOR ; ENDIF ; textnew } # old code IF (~= null exprList_raw) THEN FOR i WITH tell gage shape exprList_raw DO row_new := find_HOWELL tranList_expr@i symList_int ; %remove any backslashes ; IF (NOT isfault row_new) THEN exprList_rawInt := sed '''s/\\//g''' exprList_raw@i ; symList_int@row_new := exprListInt ; ENDIF ; ENDFOR ; ENDIF ; # # test of sort & cull qnial> a := 'Rocs(POIo)' 'c' 'dp[dt: ' 'Ei(ro - vo*t,t)' ']' 'Rocs' 'POIo' 'dp' 'dt' 'Ei(ro - vo*t,t)' 'Ei' 'ro' 'vo' 't' 't' +----------+-+-------+---------------+-+----+----+--+--+---------------+--+--+--+-+-+ |Rocs(POIo)|c|dp[dt: |Ei(ro - vo*t,t)|]|Rocs|POIo|dp|dt|Ei(ro - vo*t,t)|Ei|ro|vo|t|t| +----------+-+-------+---------------+-+----+----+--+--+---------------+--+--+--+-+-+ qnial> lengths := EACH (gage shape) a 10 1 7 15 1 4 4 2 2 15 2 2 2 1 1 qnial> address := grade >= lengths 3 9 0 2 5 6 7 8 10 11 12 1 4 13 14 qnial> b := address choose a +---------------+---------------+----------+-------+----+----+--+--+--+--+--+-+-+-+-+ |Ei(ro - vo*t,t)|Ei(ro - vo*t,t)|Rocs(POIo)|dp[dt: |Rocs|POIo|dp|dt|Ei|ro|vo|c|]|t|t| +---------------+---------------+----------+-------+----+----+--+--+--+--+--+-+-+-+-+ qnial> c := cull b +---------------+----------+-------+----+----+--+--+--+--+--+-+-+-+ |Ei(ro - vo*t,t)|Rocs(POIo)|dp[dt: |Rocs|POIo|dp|dt|Ei|ro|vo|c|]|t| +---------------+----------+-------+----+----+--+--+--+--+--+-+-+-+ qnial> d := a EACHBOTH pair b +----------------------------+-------------------+--------------------+-------------------------+--------+---- |+----------+---------------+|+-+---------------+|+-------+----------+|+---------------+-------+|+-+----+|+--- ||Rocs(POIo)|Ei(ro - vo*t,t)|||c|Ei(ro - vo*t,t)|||dp[dt: |Rocs(POIo)|||Ei(ro - vo*t,t)|dp[dt: |||]|Rocs|||Roc |+----------+---------------+|+-+---------------+|+-------+----------+|+---------------+-------+|+-+----+|+--- +----------------------------+-------------------+--------------------+-------------------------+--------+---- -------+---------+-------+-------+--------------------+-------+------+------+-----+-----+ -+----+|+----+--+|+--+--+|+--+--+|+---------------+--+|+--+--+|+--+-+|+--+-+|+-+-+|+-+-+| s|POIo|||POIo|dp|||dp|dt|||dt|Ei|||Ei(ro - vo*t,t)|ro|||Ei|vo|||ro|c|||vo|]|||t|t|||t|t|| -+----+|+----+--+|+--+--+|+--+--+|+---------------+--+|+--+--+|+--+-+|+--+-+|+-+-+|+-+-+| -------+---------+-------+-------+--------------------+-------+------+------+-----+-----+ qnial> cull d +----------------------------+-------------------+--------------------+-------------------------+--------+---- |+----------+---------------+|+-+---------------+|+-------+----------+|+---------------+-------+|+-+----+|+--- ||Rocs(POIo)|Ei(ro - vo*t,t)|||c|Ei(ro - vo*t,t)|||dp[dt: |Rocs(POIo)|||Ei(ro - vo*t,t)|dp[dt: |||]|Rocs|||Roc |+----------+---------------+|+-+---------------+|+-------+----------+|+---------------+-------+|+-+----+|+--- +----------------------------+-------------------+--------------------+-------------------------+--------+---- -------+---------+-------+-------+--------------------+-------+------+------+-----+ -+----+|+----+--+|+--+--+|+--+--+|+---------------+--+|+--+--+|+--+-+|+--+-+|+-+-+| s|POIo|||POIo|dp|||dp|dt|||dt|Ei|||Ei(ro - vo*t,t)|ro|||Ei|vo|||ro|c|||vo|]|||t|t|| -+----+|+----+--+|+--+--+|+--+--+|+---------------+--+|+--+--+|+--+-+|+--+-+|+-+-+| -------+---------+-------+-------+--------------------+-------+------+------+-----+ +-----------------------+ 02May2018 re-test >> OOPS, no longer works, check it out qnial> trans_rows ?no_value >> Ah Hah! undefined "symbols translate- tests.ndf" must load "symbols badList Lucas.ndf"!! >> I got repeated "particle" as with : - ∂[∂t : EIpds(POIo(t),t)]/Vons(particle)(particle)/cos(Aθpc(POIo(t),t)) >> this is because the "Vons" is translated to "Vons(particle)" >> OK, only failure is : # symTranslate_string_test example 2 : FAILED - result does NOT match standard t_input, t_standard, t_result = - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/|Rpcs(POIp)|" in the first term in parenthesis. - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/|Rpcv(POIp)|" in the first term in parenthesis. >> the standard is wrong! I changed it >> Now they all work again 04May2018 17:15 Re-test qnial> symTranslate_string_test # symTranslate_string_test example 1 : OK - result matches standard t_input, t_standard, t_result = - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) - ∂[∂t : EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) - ∂[∂t : EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory sh: 1: Syntax error: "(" unexpected # symTranslate_string_test example 2 : FAILED - result does NOT match standard t_input, t_standard, t_result = - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/|Rpcs(POIp)|" in the first term in parenthesis. - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/|Rocv(POIo) - Vonv(particle)*t|" in the first term in parenthesis. rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory # symTranslate_string_test example 3 : OK - result matches standard t_input, t_standard, t_result = - I have NO real idea of why the (ros*cosOo - vos*t) pops up anyways, and why the cos term all of a sudden (sp herical coords does not explain this!) - I have NO real idea of why the (Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!) - I have NO real idea of why the (Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!) # symTranslate_string_test example 4 : OK - result matches standard t_input, t_standard, t_result = - has too many "c"'s - has too many "c"'s - has too many "c"'s # symTranslate_string_test example 5 : OK - result matches standard t_input, t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] + 1/Rocs(POIo)/c*∂[∂t : EIods(POIp(t),t)] ] + 1/Rocs(POIo)/c*∂[∂t : EIods(POIp(t),t)] ] # symTranslate_string_test example 6 : FAILED - result does NOT match standard t_input, t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : | Ei(ro - vo*t,t) |] ] + 1/Rocs(POIo)/c*∂[∂t : | EIodv(POIp(t),t) |] ] + 1/Rocs(POIo)/c*∂[∂t : | EIodv(Rpcv(POIp),t) |] ] # symTranslate_string_test example 7 : FAILED - result does NOT match standard t_input, t_standard, t_result = = vos/c*Rocs(POIo)*sinOo*q/|rov - vo*t|^3*Pph = Vons(particle)/c*Rocs(POIo)*sin(Aθoc(POIo))*Q(particle)/Rpcs(POIo(t),t)^3*???Rodh(Vonv_X_Rpcv) = Vons(particle)/c*Rocs(POIo)*sin(Aθoc(POIo))*Q(particle)/Rpcs(POIp)^3*???Rodh(Vonv_X_Rpcv) # symTranslate_string_test example 8 : FAILED - result does NOT match standard t_input, t_standard, t_result = = vos/c*Rocs(POIo)/|rov - vo*t|*sinOo*Pph = Vons(particle)/c*Rocs(POIo)/|Rpcv(POIp)|*sin(Aθoc(POIo))*???Rodh(Vonv_X_Rpcv) = Vons(particle)/c*Rocs(POIo)/Rpcs(POIp)*sin(Aθoc(POIo))*???Rodh(Vonv_X_Rpcv) # symTranslate_string_test example 9 : OK - result matches standard t_input, t_standard, t_result = HLFN = q/c*(vovrpv)/rps^2 + vov/cEi(rp,tp) HLFN = Q(particle)/c*(???Vonv_X_Rpcv)/Rpcs(POIp)^2 + Vonv(particle)/cEIodv(Rpcv(POIp),tp) HLFN = Q(particle)/c*(???Vonv_X_Rpcv)/Rpcs(POIp)^2 + Vonv(particle)/cEIodv(Rpcv(POIp),tp) >> Results : OK- works : [1,3-5,9] FAILED : [2,6-8] - actually [7,8] are correct! - fix t_standard !!!!!!!!!!!!!!!!!!!! >> NOTE : tabs are being dropped! This is dangerous!! !!!!!!!!!!!!!!!!!!!! # symTranslate_string_test example 2 : FAILED - result does NOT match standard t_input, t_standard, t_result = - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/|Rpcs(POIp)|" in the first term in parenthesis. - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/|Rocv(POIo) - Vonv(particle)*t|" in the first term in parenthesis. >> This should have worked? It worked better before the last changes...!? >> change t_standard # symTranslate_string_test example 6 : FAILED - result does NOT match standard t_input, t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : | Ei(ro - vo*t,t) |] ] + 1/Rocs(POIo)/c*∂[∂t : | EIodv(POIp(t),t) |] ] + 1/Rocs(POIo)/c*∂[∂t : | EIodv(Rpcv(POIp),t) |] ] >> I added to transExpr_table : 'Ei(ro - vo\*t,t)' 'EIodv(POIp(t),t)' (msg_Lucas msg_abs) +-----------------------+ 02May2018 17:34 re-test >> OK - only example #2 is still a problem !!!!!!!!!!!!!!!!!!!! >> NOTE : tabs are being dropped! This is dangerous!! !!!!!!!!!!!!!!!!!!!! >> OK - QNial screen output strips characters, but they should still be in t_standard 04May2019 21:48 Example #2 [sed_prep_string,sed_unprep_string] are supposed to take care of the quotes, but I haven't yet put the quote in sed_unprep_string. trans_syms_replace_quotes - I should look at this some other time Is this the problem? - it isn't apparent from the result for #2 (above) MORON - the "|" characters don't immediately surround the string, and transExpr_table does not have "| Ei(ro - vo*t,t) |" !! Example #5 works because there is an entry in transExpr_table that corresponds to it. Leave Example #6 as-is : at some time in the future I need to be able to create a "standard form for expressions"! Go on to symTranslate_file_test 05May2018 After many changes for symTranslate_expressions_test, I re-checked >> have to modify symTranslate_string convert to QNial operators rathe than sed? 06May2018 22:53 Re-test, after working on string_sub qnial> symTranslate_string_test # symTranslate_string_test example 1 : OK - result matches standard t_input, t_standard, t_result = - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) - ∂[∂t: EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) - ∂[∂t: EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) # symTranslate_string_test example 2 : FAILED - result does NOT match standard t_input, t_standard, t_result = - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" . - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/Rpcs(POIp)" . - has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/Rpcs(POIp)" . >> close enough for now - spaes after the period # symTranslate_string_test example 3 : OK - result matches standard t_input, t_standard, t_result = - I have NO real idea of why the (ros*cosOo - vos*t) pops up anyways, and why the cos term all of a sudden (sp herical coords does not explain this!) - I have NO real idea of why the (Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!) - I have NO real idea of why the (Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!) # symTranslate_string_test example 4 : FAILED - result does NOT match standard t_input, t_standard, t_result = - has too many "c"'s - has too many "c"'s - has to o many "c"'s >> example 4 FAILED : Interesting - I still have to fix "keyword formatting" # symTranslate_string_test example 5 : OK - result matches standard t_input, t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] + 1/Rocs(POIo)/c*∂[∂t: EIods(POIp(t),t)] ] + 1/Rocs(POIo)/c*∂[∂t: EIods(POIp(t),t)] ] # symTranslate_string_test example 6 : OK - result matches standard t_input, t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : | Ei(ro - vo*t,t) |] ] + 1/Rocs(POIo)/c*∂[∂t: |EIodv(POIp(t),t)|] ] + 1/Rocs(POIo)/c*∂[∂t: |EIodv(POIp(t),t)|] ] # symTranslate_string_test example 7 : OK - result matches standard t_input, t_standard, t_result = = vos/c*Rocs(POIo)*sinOo*q/|rov - vo*t|^3*Pph = Vons(particle)/c*Rocs(POIo)*sin(Aθoc(POIo))*Q(particle)/Rpcs(POIp)^3*???Rodh(Vonv_X_Rpcv) = Vons(particle)/c*Rocs(POIo)*sin(Aθoc(POIo))*Q(particle)/Rpcs(POIp)^3*???Rodh(Vonv_X_Rpcv) # symTranslate_string_test example 8 : OK - result matches standard t_input, t_standard, t_result = = vos/c*Rocs(POIo)/|rov - vo*t|*sinOo*Pph = Vons(particle)/c*Rocs(POIo)/Rpcs(POIp)*sin(Aθoc(POIo))*???Rodh(Vonv_X_Rpcv) = Vons(particle)/c*Rocs(POIo)/Rpcs(POIp)*sin(Aθoc(POIo))*???Rodh(Vonv_X_Rpcv) # symTranslate_string_test example 9 : OK - result matches standard t_input, t_standard, t_result = HLFN = q/c*(vovrpv)/rps^2 + vov/cEi(rp,tp) HLFN = Q(particle)/c*(???Vonv_X_Rpcv)/Rpcs(POIp)^2 + Vonv(particle)/cEIodv(Rpcv(POIp),tp) HLFN = Q(particle)/c*(???Vonv_X_Rpcv)/Rpcs(POIp)^2 + Vonv(particle)/cEIodv(Rpcv(POIp),tp) >> Overall results above - pretty good # symTranslate_string_test example 4 : FAILED - result does NOT match standard t_input, t_standard, t_result = - has too many "c"'s - has too many "c"'s - has to o many "c"'s >> example 4 FAILED : Interesting - I still have to fix "keyword formatting" >> should be easy to fix!? 07May2018 I changed to include '.' : chrs_symbols_HFLN := link chrs_alphaNumeric '.' chrs_Greek_all chr_underscore ; % chr_codes ??? ; >> remove this - useless sym_stdForm IS OP str_symbol >> seems to be OK symExtract_file IS OP pname_inn pname_out >> seems to be OK I only have to ensure "." surrounds keywords [to,over], keyword "from" only used for "|.from." expressions >> I edited "/home/bill/SWAPPER/Lucas - Universal Force/Howell - math of Lucas Universal Force.txt" 07May2018 15:57 try chars [´,•,·] : t_name := '# symTranslate_string_test example 12' ; t_input := '[·dl : E(r´,t´)] = -1/c*dp[dt : [dA : B(r,t) •n]] .and.[·dl : E(r´,t´)] = - [dA : dp[dt : B(r,t))]·n]' ; t_standard := '[·dl : Eodv(Rocv(POIp(t),t)] = -1/c*∂[∂t: [dA: Bodv(Rocv(POIp(t),t)•n]] .and.[·dl : E(Rocv(POIp(t),t),t)] = - [dA : ∂[∂t: B(Rocv(POIp(t),t)]·n]' ; t_result := symTranslate_string t_input ; test_comment t_name t_input t_standard t_result ; qnial> symTranslate_string_test # symTranslate_string_test example 12 : FAILED - result does NOT match standard t_input, t_standard, t_result = [·dl : E(r´,t´)] = -1/c*dp[dt : [dA : B(r,t) •n]] .and.[·dl : E(r´,t´)] = - [dA : dp[dt : B(r,t))]·n] [·dl : E(Rocv(POIp(t),t)] = -1/c*∂[∂t: [dA: Bodv(Rocv(POIp(t),t)•n]] .and.[·dl : E(Rocv(POIp(t),t),t)] = - [dA : ∂[∂t: B(Rocv(POIp(t),t)]·n] [·dl : E(Rocv(POIo)´,t´)] = -1/c*∂[∂t: [dA: B(Rocv(POIo),t)•n]] .and.[·dl : E(Rocv(POIo)´,t´)] = - [dA : ∂[∂t: B(Rocv(POIo),t))]·n] >> QNial EASILY handles chars [´,•,·] >> But I need to rewrite "Howell - math of Lucas Universal Force.txt" to use these more fully as per original Lucas >> AND - I need to add translations to "symbols badList Lucas.ndf" >> Many "mashed" expressions like : HLFN FLENZodVonVonVonv(particle)(paRocVonv(particle)(POIo)ticle)(paRocVonVonv(particle)(paRocVonv(particle)(POIo)ticle)(POIo)ticle)(POIo,t) = Q(paRocVonVonv(particle)(paRocVonv(particle)(POIo)ticle)(POIo)ticle)*[ ETodVonVonVonv(particle)(paRocVonv(particle)(POIo)ticle)(paRocVonVonv(particle)(paRocVonv(particle)(POIo)ticle)(POIo)ticle)(POIo,t) + VonVonVonv(particle)(paRocVonv(particle)(POIo)ticle)(paRocVonVonv(particle)(paRocVonv(particle)(POIo)ticle)(POIo)ticle)BTodVonVonVonv(particle)(paRocVonv(particle)(POIo)ticle)(paRocVonVonv(particle)(paRocVonv(particle)(POIo)ticle)(POIo)ticle)(POIo,t) ] >> Why? I replaced "·" with "•" in "Howell - math of Lucas Universal Force.txt" # 08********08 #] 15Apr2018 sed_prep_string /media/bill/PROJECTS/Qnial/code tests/strings- tests.ndf Sun Apr 15 11:09:33 2018 #+-----+ # sed_prep_string example 1 : OK - result matches standardsymTranslate_string_test t_input= - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. t_standard, t_result_trimmed = '- has the term \"(ros*cosOo - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' '- has the term \"(ros*cosOo - vos*t)/|ro - vo*t|\" in the first term in parenthesis. ' # sed_prep_string example 2 : OK - result matches standard t_input= - has too many "c"'s t_standard, t_result_trimmed = '- has too many \"c\"''s' '- has too many \"c\"''s' # sed_prep_string example 3 : OK - result matches standard t_input= how does '" '"'"this handle [single, double] apostrophes ' and "quotes? t_standard, t_result_trimmed = 'how does ''\" ''\"''\"this handle [single, double] apostrophes '' and \"quotes? ' 'how does ''\" ''\"''\"this handle [single, double] apostrophes '' and \"quotes? ' # sed_prep_string example 4 : OK - result matches standard t_input= how does '" '"'"this handle [single, double] apostrophes ' and " quotes? t_standard, t_result_trimmed = 'how does ''\" ''\"''\"this handle [single, double] apostrophes '' and \" quotes? ' 'how does ''\" ''\"''\"this handle [single, double] apostrophes '' and \" quotes? ' #+-----+ # sed_test example 1 : FAILED - result does NOT match standard t_input= - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) t_standard, t_result = - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(cos(Aθoc(POIo))) # sed_test example 2 : OK - result matches standard t_input= - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. t_standard, t_result_trimmed = - has the term "(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|" in the first term in parenthesis. - has the term "(ros*cos(Aθoc(POIo)) - vos*t)/|ro - vo*t|" in the first term in parenthesis. # sed_test example 3 : OK - result matches standard t_input= - I have NO real idea of why the (ros*cosOo - vos*t) pops up anyways, and why the cos term all of a sudden (sp herical coords does not explain this!) t_standard, t_result_trimmed = - I have NO real idea of why the (ros*cos(Aθoc(POIo)) - vos*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!) - I have NO real idea of why the (ros*cos(Aθoc(POIo)) - vos*t) pops up anyways, and why the cos term all of a sudden (spherical coords does not explain this!) # sed_test example 4 : OK - result matches standard t_input= - has too many "c"'s t_standard, t_result_trimmed = - has too many "c"'s - has too many "c"'s sed: -e expression #1, char 66: invalid reference \3 on `s' command's RHS # sed_test example 5 : FAILED - result does NOT match standard t_input= - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) t_standard, t_result = - ∂[∂t : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) # 08********08 #] 14Apr2018 remove these operators to keep the code simple # translate_sed IS OP sed_expr string_in - Unix sed applied for translation via dictionary # 10Apr2018 - custom version of sed that doesn't double-correct for [apos,quotes] translate_sed IS OP sed_expr string_in { LOCAL fin p_sed s_out ; p_sed := link d_QNial_temp 'translate_sed_temp.txt' ; host link ' echo ' string_in ' | sed ' sed_expr ' >"' p_sed '" ' ; fin := open p_sed "r ; s_out := readfile fin ; close fin ; s_out } # old code %textnew := sed_prep_string string_in ; %textnew := link `' string_in `' ; %write_debug link 'string_in= ' string_in ; %write_debug link 'textnew= ' textnew ; %host link 'rm "' p_sed '" ' ; # [grep,sed] make choke on characters : # from https://unix.stackexchange.com/questions/32907/what-characters-do-i-need-to-escape-when-using-sed-in-a-sh-script For details, see "/media/bill/PROJECTS/System_maintenance/Linux/sed notes.txt" in the list of characters matched by a bracket expression '$.*/[\]^' -> most of these are NOT legal symbol characters, so they won't be in extracted symbols In the replacement text: '&\/\n' ; # 15Apr2018 Currently I do this manually # 04Masy2018 may have problems with quotes '"' # sed version that was intended for strings AND files symTranslate_string IS OP flag_pre str { LOCAL address i lengths mixList mixList_cull sed_expr textnew symList_all symList_chg symList_cull symList_grade symList_raw symList_std trnList_all trnList_chg trnList_cull trnList_xpr trnList_grade xprList_raw xprList_loc ; NONLOCAL sym_chrs ; % ; textnew := str ; %write_debug link 'textnew start = ' textnew ; IF (~= `$ str@0) THEN xprList_raw xprList_loc := xprsLocationsList str ; symList_raw symList_loc := symsLocationsList -1 symExtract_2D str ; symList_std := EACH sym_stdForm symList_raw ; trnList_std := EACH symTranslate symList_std ; symList_all := link symList_raw xprList_raw ; trnList_all := link trnList_std trnList_xpr ; % ; symList_chg trnList_chg := (EACHBOTH ~= symList_all trnList_all) EACHRIGHT sublist symList_all trnList_all ; % now, how do I use symList_chg to [cull,sort] BOTH [symList_chg,trnList_chg] in the SAME order? ; % sort by decreasing length of symList_chg - BOTH [symList_grade,trnList_grade] must be the same to cull a pair. ; lengths := EACH (gage shape) symList_chg ; address := grade >= lengths ; symList_grade trnList_grade := address EACHRIGHT choose symList_chg trnList_chg ; %cull the two lists ; mixList := symList_grade EACHBOTH pair trnList_grade ; mixList_cull := cull mixList ; symList_cull trnList_cull := [EACH first, EACH second] mixList ; %EACH write_debug '[str,symList_all,trnList_all,symList_chg,trnList_chg,symList_cull,trnList_cull]= ' str symList_all trnList_all symList_chg trnList_chg symList_cull trnList_cull ; % ; FOR i WITH tell gage shape symList_grade DO sed_expr := link '"s/\([^' sym_chrs ']\)\(' symList_cull@i '\)\([^' sym_chrs ']\)/\1' trnList_cull@i '\3/g"' ; %write_debug link 'sed_expr= ' sed_expr ; textnew := sed flag_pre sed_expr textnew ; %write_debug link (string i) ' : ' textnew ; ENDFOR ; ENDIF ; textnew } # sym_stdForm_keyWd IS OP symList - put spaces around key words, eg [from,to,over,???] # - words must be normal alphanumeric - puctuation and unicode may be a problem! # 24Apr2018 initial # sed version sym_stdForm_keyWd IS OP str_trgt str_in { LOCAL sed_expr ; NONLOCAL chrs_blank chrs_stop_paren chrs_strt_paren chrs_symbols_HFLN ; sed_expr := link ' ''s/\([^' chrs_symbols_HFLN ']\)\(' str_trgt '\)\([^' chrs_symbols_HFLN ']\)/\1 ' str_trgt ' \3/g'' ' ; sed sed_expr str_in } # QNial version # sym_stdForm_keyWd IS OP str_trgt str { LOCAL sed_expr ; NONLOCAL chrs_blank chrs_stop_paren chrs_strt_paren chrs_symbols_HFLN ; FOR trgt_posn WITH trgt_posns DO trgt_posns := find_string str_trgt str ; IF (trgt_posn > 0) THEN IF (trgt_posn } # 06May2018 not used ... xprLocationsList IS OP str { LOCAL i xpr_locations xprList_raw xprList_loc ; NONLOCAL transExpr_old transExpr_new transExpr_msg transExpr_rows ; xprLocatiosList_raw xprList_loc := null null ; FOR i WITH tell transExpr_rows DO xpr_locations := find_expression transExpr_old@i str ; IF (~= null xpr_locations) THEN xprList_raw := link xprList_raw (solitary transExpr_old@i) ; xprList_loc := link xprList_loc (solitary xpr_locations ) ; %EACH write '[xprList_raw trnList_xpr]= ' xprList_raw xprList_loc ; ENDIF ; ENDFOR ; xprList_raw xprList_loc } # xprLocations_find IS OP xpr str - provide a list of non-ovelapping locations of xpr in str # WARNING : must add unicode character lengths!! otherwise your t_standards will be wrong! # WARNING : returns are either a null or a list (eg solitary!) # 05May2018 # find_expression just use find_string !! xprLocations_find IS OP xpr str { LOCAL len_xpr len_str i_str i_xpr xpr_locn ; len_xpr := gage shape xpr ; len_str := gage shape str ; i_str i_xpr := 0 0 ; xpr_locn := null ; WHILE (i_str < (len_str - len_xpr + 1)) DO WHILE (AND ((i_xpr + i_str) < len_str) (i_xpr < len_xpr) (= xpr@i_xpr str@(i_str + i_xpr)) ) DO i_xpr := i_xpr + 1 ; ENDWHILE ; IF (= i_xpr len_xpr) THEN xpr_locn := link xpr_locn i_str ; ENDIF ; i_str := i_str + 1 ; i_xpr := 0 ; ENDWHILE ; xpr_locn } # symTranslate_expressions IS OP str { LOCAL i xprList_raw trnList_xpr ; NONLOCAL transExpr_old transExpr_new transExpr_msg transExpr_rows ; xprList_raw trnList_xpr := null null ; FOR i WITH tell transExpr_rows DO % note that escapes must be retained in the transExpr_old@i when using string_in, (but NOT for in_string) ; IF (in_string transExpr_old@i str) THEN xprList_raw := link xprList_raw (solitary transExpr_old@i) ; trnList_xpr := link trnList_xpr (solitary transExpr_new@i) ; %EACH write '[xprList_raw trnList_xpr]= ' xprList_raw trnList_xpr ; ENDIF ; ENDFOR ; xprList_raw trnList_xpr } # in_string 'rov - vo*t' ' = vos/c*Rocs(POIo)*sinOo*q/|rov - vo*t|^3*Pph ' >> +-----+ # bash utilities # 16Apr2018 Convert a list of missing symbols (produced by hand by noticing which symbols were not translated) to initial "symbols translate" format # after running - in a text editor manaully replace quotes with apostophes trans_syms_missing_augment IS { d_Lucas := '/media/bill/PROJECTS/Lucas - Universal Force/' ; f_syms_missing := link d_Lucas 'symbols missing ?date?.txt' ; f_syms_augment := link d_Lucas 'symbols missing ?date? augmented.txt' ; cmd := link 'cat "' f_syms_missing '" | sed ''s/\(^.*$\)/\t''\''''\1''\''''\t\t\t\t\t\t\t''\''''\1''\''''\t\t\t\t\t\t\t\t\t"needs explanation"/'' >"' f_syms_augment '" ' ; write cmd ; host cmd ; } # converts quotes to apostrophes # shouldn't need this if trans_syms_missing_augment works properly trans_syms_replace_quotes IS { d_Lucas := '/media/bill/PROJECTS/Lucas - Universal Force/' ; f_syms_missing := link d_Lucas 'symbols missing augmented 180416.txt' ; f_syms_augment := link d_Qnial_temp 'symbols missing augmented 180416 v2.txt' ; cmd := link 'cat "' f_syms_missing '" | sed ''s/"/''\''''/g'' >"' f_syms_augment '" ' ; %write cmd ; host cmd ; } write_debug 'loading find_expression_test' ; # 08********08 #] find_expression_test IS - test correctness of results using known results # www.BillHowell.ca 05May2018 simple tests # WARNING : must add unicode character lengths!! otherwise your t_standards will be wrong! # WARNING : returns are either a null or a list (eg solitary!) find_expression_test IS { LOCAL t_name t_input t_standard t_result ; % ; t_name := '# find_expression_test example 1' ; t_input := '|EIodv(POIo,t)|' ' - ∂[∂t : EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) ' ; t_standard := null ; t_result := find_expression t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# find_expression_test example 2' ; t_input := 'POIo' ' - ∂[∂t : EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) ' ; t_standard := 28 65 ; t_result := find_expression t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# find_expression_test example 3' ; t_input := 't' ' - ∂[∂t : EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) ' ; t_standard := 18 33 36 48 70 73 ; t_result := find_expression t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# find_expression_test example 4' ; t_input := 'the' '- has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. ' ; t_standard := 6 52 75 ; t_result := find_expression t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# find_expression_test example 5' ; t_input := 'ro - vo*t' '- has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. ' ; t_standard := solitary 37 ; t_result := find_expression t_input ; test_comment t_name t_input t_standard t_result ; % ; t_name := '# find_expression_test example 6' ; t_input := 'rp' 'HLFN = q/c*(vovrpv)/rps^2 + vov/cEi(rp,tp)' ; t_standard := 19 24 43 ; t_result := find_expression t_input ; test_comment t_name t_input t_standard t_result ; } # all examples % ; t_name := '# find_expression_test example 7' ; t_input := 'rp' 'HLFN = q/c*(vovrpv)/rps^2 + vov/cEi(rp,tp)' ; t_standard := null null ; t_result := find_expression t_input ; test_comment t_name t_input t_standard t_result ; # 08********08 #] symTranslate_file_test initially called it "translate_file_long" write_debug '>>>>>> loading translate_file_long' ; translate_file_long IS OP pname_diff pname_inn pname_int1 pname_int2 pname_out { LOCAL cmd sed_expr ; NONLOCAL sym_chars trans_old trans_new trans_msg trans_rows ; % ; sed_prep_file pname_inn pname_int1 ; FOR i WITH tell trans_rows DO sed_expr := link '"s/\([^' sym_chars ']\)\(' trans_old@i '\)\([^' sym_chars ']\)/\1' trans_new@i '\3/g"' ; cmd := link 'cat "' pname_int1 '" | sed "' sed_expr '" >"' pname_int2 '" ' ; host cmd ; host 'cp "' pname_int2 '" "' pname_int1 '" ' ; ENDFOR ; } write_debug '>>>>>> loading translate_file_long_test' ; translate_file_long_test IS { LOCAL pname_diff pname_inn pname_sed pname_out ; d_Lucas := '/media/bill/PROJECTS/Lucas - Universal Force/' ; pname_diff := link d_QNial_temp 'trans_long_diff.txt' ; pname_inn := link d_Lucas 'translate inn.txt' ; pname_sed := link d_QNial_temp 'trans_long_temp.txt' ; pname_out := link d_QNial_temp 'trans_long_out.txt' ; translate_file_long pname_diff pname_inn pname_sed pname_out ; host link 'diff >"' pname_diff '" "' pname_inn '" "' pname_out '" ' ; } # old tests with test_translate_file # 10Aug2018 work with translate_string first to get it right (simpler) 15Apr2018 after code changes (from "translate_string" comments above) qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf' ... /C >> translate_string_test - [examples [1,2,3] FAILED, example 4 OK >> translate_file_test - infinite loop renamed "translate_file_long" to "symTranslate_file_test" 02May2018 test symTranslate_file IS OP pname_inn pname_out { LOCAL i sed_expr pname_int ; NONLOCAL sym_chrs trans_old trans_new trans_msg trans_rows ; % ; pname_int := link d_QNial_temp 'trans_file_intermediate.txt' ; host link 'cp "' pname_inn '" "' pname_int '" ' ; FOR i WITH (tell trans_rows) DO sed_expr := link '"s/\([^' sym_chrs ']\)\(' trans_old@i '\)\([^' sym_chrs ']\)/\1' trans_new@i '\3/g"' ; write link (string i) ' ' sed_expr ; sed_file sed_expr pname_int pname_out ; host link 'cp "' pname_out '" "' pname_int '" ' ; ENDFOR ; } symTranslate_file_test IS { LOCAL d_Lucas pname_diff pname_inn pname_out ; % ; d_Lucas := '/media/bill/PROJECTS/Lucas - Universal Force/' ; pname_diff := link d_QNial_temp 'trans_file_diff.txt' ; pname_inn := link d_Lucas 'Howell - math of Lucas Universal Force.txt' ; pname_out := link d_QNial_temp 'trans_file_out.txt' ; % ; write '***************************' ; write '/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf' ; write timestamp ; write ' ' ; write '# symTranslate_file_test example 1: compare test results in : ' ; write link ' ' pname_inn ; write link ' ' pname_out ; write link ' ' pname_diff ; write link ' (ideally "' pname_diff '" ' 'will be empty except for "good" substitution liness)' ; % ; symTranslate_file pname_inn pname_out ; host link 'diff >>"' pname_diff '" "' pname_inn '" "' pname_out '" ' ; write timestamp ; } >> Output file "trans_file_out.txt" has : Ω_full_sphere Ω_full_sphere Ω_full_sphere Ω_full_sphere ... >> OOPS, what gives? >> I guess that I didn't finish the "" operator development? qnial> trans_rows ?no_value >> See "symTranslate_string_test" above to get that working right Retry : 1. haven't instituted start of line code "$" to deny translation (done - in symTranslate_string) 2. must first convert input to standard form before translating! (done - in symTranslate_string) 3. rather than go through entire list of symbols for each [string,line], first extract lines symbols, then translate each of them? use an efficient search for a sorted list (This would cause problems with double+ substitutions!) ... (done - in symTranslate_file, after revamping symTranslate_string) 04May2018 22:12 re-test >> Too many errors of the form : sh: 1: Syntax error: word unexpected (expecting ")") rm: cannot remove ‘/media/bill/ramdisk/string_in results.txt’: No such file or directory ... >> Redirect stderr to a d_Qnial_temp file for "string_in" >> comment-out write statements >> seems to be MUCH faster than with background file >> appears to be complete, but perhaps I am missing lines of output? string_in - redirection of stderr didn't help Must be sed use somewhere - OR perhaps I didn't save string_in? +---+ pname_err := link d_QNial_temp 'trans_file_err.txt' ; host link 'echo "' str_in '" | grep -i "' substr '" >"' p_name '" 2>"' pname_err '" ' ; +---+ I re-ran it, but the changes eliminated most output!?? symTranslate_expressions - calls string_in (no others in "symbols translate.ndf") qnial> find_expression_test # find_expression_test example 1 : OK - result matches standard t_input, t_standard, t_result = +---------------+------------------------------------------------------------------------------+ ||EIodv(POIo,t)|| - ∂[∂t : EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) | +---------------+------------------------------------------------------------------------------+ # find_expression_test example 2 : OK - result matches standard t_input, t_standard, t_result = +----+------------------------------------------------------------------------------+ |POIo| - ∂[∂t : EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) | +----+------------------------------------------------------------------------------+ 28 65 28 65 # find_expression_test example 3 : OK - result matches standard t_input, t_standard, t_result = +-+------------------------------------------------------------------------------+ |t| - ∂[∂t : EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) | +-+------------------------------------------------------------------------------+ 18 33 36 48 70 73 18 33 36 48 70 73 # find_expression_test example 4 : OK - result matches standard t_input, t_standard, t_result = +---+------------------------------------------------------------------------------------+ |the|- has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. | +---+------------------------------------------------------------------------------------+ 6 52 75 6 52 75 # find_expression_test example 5 : OK - result matches standard t_input, t_standard, t_result = +---------+------------------------------------------------------------------------------------+ |ro - vo*t|- has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. | +---------+------------------------------------------------------------------------------------+ 37 37 # find_expression_test example 6 : OK - result matches standard t_input, t_standard, t_result = +--+-------------------------------------------------+ |rp|HLFN = q/c*(vovrpv)/rps^2 + vov/cEi(rp,tp)| +--+-------------------------------------------------+ 19 24 43 19 24 43 +-----+ 07May2018 dump this - no longer using blend of [QNial,bash] symTranslate_file_test IS { LOCAL d_Lucas pname_diff pname_inn pname_out ; % ; d_Lucas := '/media/bill/PROJECTS/Lucas - Universal Force/' ; pname_inn := link d_Lucas 'Howell - math of Lucas Universal Force.txt' ; pname_out := link d_QNial_temp 'trans_file_out.txt' ; pname_diff := link d_QNial_temp 'trans_file_diff.txt' ; % ; write '***************************' ; write '/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf' ; write timestamp ; write ' ' ; write '# symTranslate_file_test example 1: compare test results in : ' ; write link ' ' pname_inn ; write link ' ' pname_out ; write link ' ' pname_diff ; write link ' (ideally "' pname_diff '" ' 'will be empty except for "good" substitution lines)' ; % ; symTranslate_file pname_inn pname_out ; host link 'diff >>"' pname_diff '" "' pname_inn '" "' pname_out '" ' ; write timestamp ; } >> Good except empty lines are thrown out! >> change : symTranslate_file IS OP pname_inn pname_out { LOCAL fin fot i line_in str ; i := 0 ; fin := open pname_inn "r ; fot := open pname_out "w ; WHILE ( ~= ??eof (str := readfile fin)) DO line_in := symTranslate_string str ; IF (~= null line_in) THEN write link (string i) ' ' line_in ; writefile fot line_in ; ENDIF ; i := i + 1 ; ENDWHILE ; EACH close fin fot ; } >> to : symTranslate_file IS OP pname_inn pname_out { LOCAL fin fot i line_in str ; i := 0 ; fin := open pname_inn "r ; fot := open pname_out "w ; WHILE ( ~= ??eof (str := readfile fin)) DO line_in := symTranslate_string str ; %write link (string i) ' ' line_in ; writefile fot line_in ; i := i + 1 ; ENDWHILE ; EACH close fin fot ; } >> stdout : qnial> symTranslate_file_test +-------------------------------+ /media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf Mon May 7 10:59:52 2018 # symTranslate_file_test example 1: compare test results in : /media/bill/PROJECTS/Lucas - Universal Force/Howell - math of Lucas Universal Force.txt /media/bill/ramdisk/trans_file_out.txt /media/bill/ramdisk/trans_file_diff.txt (ideally "/media/bill/ramdisk/trans_file_diff.txt" will be empty except for "good" substitution lines) Mon May 7 11:00:15 2018 >> OK, looks good! >> Great lesson - just use QNial! : >> runs 100 times faster with QNial than my hybrid [QNial,sed] version!!! >> (23 seconds rather than ~40 minutes (2,400 seconds) >> Coding with QNial is >>10 times faster than hybrid [QNial,sed], and FAR simpler >> Development time is critical - and QNial is a great prototyping language >> I'll have to check in detail manually. qnial> symTranslate_file_test +-------------------------------+ /media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf Mon May 7 11:11:23 2018 # symTranslate_file_test example 1: compare test results in : /media/bill/PROJECTS/Lucas - Universal Force/Howell - math of Lucas Universal Force 160615.ndf /media/bill/ramdisk/trans_file_out.txt /media/bill/ramdisk/trans_file_diff.txt (ideally "/media/bill/ramdisk/trans_file_diff.txt" will be empty except for "good" substitution lines) Mon May 7 11:12:39 2018 >> apostrophes in the old file just kill the output!! >> much larger old file size I'll have to cross-check manuall ******************************************** 10May2018 After significant rewrites of "symbols extract & sort.ndf" and "strings.ndf" re-test NOTE that the translation table is VERY incomplete and incorrect. But at least it tests the cding. qnial> symTrans_test This test is using "symTranList Lucas to HLFN.ndf", with flag_strProtected = o The translation table is very incomplete, so only some symbols are translated # symTrans_test example 1 : OK - result matches standard t_input, t_standard, t_result = Rocs(POIo) Rocs(POIo) Rocs(POIo) # symTrans_test example 2 : OK - result matches standard t_input, t_standard, t_result = Rocs Rocs Rocs # symTrans_test example 3 : OK - result matches standard t_input, t_standard, t_result = Ei(ro - vo*t,t) EIodv(POIp(t),t) EIodv(POIp(t),t) # symTrans_test example 4 : OK - result matches standard t_input, t_standard, t_result = dp[dt : |Ei(ro - vo*t,t)|] dp[dt : |Ei(ro - vo*t,t)|] dp[dt : |Ei(ro - vo*t,t)|] # symTrans_test example 5 : OK - result matches standard t_input, t_standard, t_result = dp ∂ ∂ # symTrans_test example 6 : OK - result matches standard t_input, t_standard, t_result = Ei EIodv EIodv # symTrans_test example 7 : OK - result matches standard t_input, t_standard, t_result = Rocs(POIo) Rocs(POIo) Rocs(POIo) # symTrans_test example 8 : OK - result matches standard t_input, t_standard, t_result = - has too many "c"'s - has too many "c"'s - has too many "c"'s # symTrans_test example 9 : OK - result matches standard t_input, t_standard, t_result = - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. >> SORT of OK. >> Several translations didn't succeed # 08********08 #] 11May2018 log file of output As the tests are generating a great deal of output, I want to reduce my "copy-paste" of results and the length of this file "symbols translate - coding development.txt". I changed "strings.ndf" and "symbols translate- tests.ndf" to provide flexible output to screen or file. At present, "" is not activated as I will do that apart. First log output : /media/bill/PROJECTS/Qnial/code tests/symTranslate_alltest 180511.txt Now it is much easier to follow and comment, and to regularly test code changes over all operators. symTrans_test - all examples are OK xprs_ExtractTranslate_test - example 9 of 9 failed, but examples are ill-suited to xprs_ExtractTranslate symTranslate_string_test - examples [1,12] of 12 failed # symTranslate_string_test example 1 : FAILED - result does NOT match standard t_input, t_standard, t_result = - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) - ∂[∂t: EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) - ∂[∂t: EIpds(POIo,t)]/Vons(particle)/cos(???Aθpc(POIp)(POIo,t)) >> wrong translations : [EIpds(POIo,t)] - I changed code for this in [symTranList Lucas to HLFN.ndf,symTranList HLFN bads.ndf] >> out of place translations : Aθpc(POIp)(POIo,t) # symTranslate_string_test example 12 : FAILED - result does NOT match standard t_input, t_standard, t_result = [·dl : E(r´,t´)] = -1/c*dp[dt : [dA : B(r,t) •n]] .and.[·dl : E(r´,t´)] = - [dA : dp[dt : B(r,t))]·n] [·dl : Eodv(Rpcv(POIp,t)] = -1/c*∂[∂t: [dA: Bodv(Rpcv(POIp,t)•n]] .and.[·dl : E(Rpcv(POIp,t),t)] = - [dA : ∂[∂t: B(Rpcv(POIp,t)]·n] [·dl: E(Rocv(POIo),t)] = -1/c*∂[∂t: [dA: B(Rocv(POIo),t)•n]] .and.[·dl: E(Rocv(POIo)´,t´)] = - [dA: ∂[∂t: B(Rocv(POIo),t))]·n] >> character `´ must be added to chrs_symbols_HFLN >> wrong translations : [B(r,t) -> B(Rocv(POIo),t),spaces before ":" in t_standards] >> missing translations : [E(r´,t´),B(r,t)] >> some of this is due to the use of symTranList Lucas to HLFN.ndf >> I need to first do symTranList Lucas bads.ndf -> symTranList Lucas to HLFN.ndf -> symTranList HLFN bads.ndf # 08********08 #] 18May2018 Change translations to pick the [right trans-table, TransExpre_tables] This will allow choosing the right [trans_tables, transExpr_tables] when doing line-by-line tranlations of a file Revamp of [symTranslate_string, symsExtractTranslate, f_remove_extra_lineTypes, symTranslate_file, symTranslate_file_test] +---+ # old code # %host link 'diff >>"' pname_diff '" "' pname_inn '" "' pname_out '" ' ; % ; d_Lucas := '/media/bill/PROJECTS/Lucas - Universal Force/' ; pname_diff := link d_QNial_temp 'trans_file_diff.txt' ; pname_inn := link d_Lucas 'z_Archive/Howell - math of Lucas Universal Force 160615 translated 180507.ndf' ; pname_out := link d_QNial_temp 'Howell - math of Lucas Universal Force ' timestamp_YYMMDD '.txt' ; % ; write '***************************' ; write '/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf' ; write timestamp ; write ' ' ; write '# symTranslate_file_test example 1: compare test results in : ' ; write link ' ' pname_inn ; write link ' ' pname_out ; write link ' ' pname_diff ; write link ' (ideally "' pname_diff '" ' 'will be empty except for "good" substitution liness)' ; % ; symTranslate_file pname_inn pname_out ; host link 'diff >"' pname_diff '" "' pname_inn '" "' pname_out '" ' ; write timestamp ; % ; d_Lucas := '/media/bill/PROJECTS/Lucas - Universal Force/' ; pname_inn := link d_Lucas 'Howell - math of Lucas Universal Force.txt' ; pname_out := link d_QNial_temp 'trans_file_out.txt' ; pname_diff := link d_QNial_temp 'trans_file_diff.txt' ; % ; write '***************************' ; write '/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf' ; write timestamp ; write ' ' ; write '# symTranslate_file_test example 1: compare test results in : ' ; write link ' ' pname_inn ; write link ' ' pname_out ; write link ' ' pname_diff ; write link ' (ideally "' pname_diff '" ' 'will be empty except for "good" substitution lines)' ; % ; symTranslate_file pname_inn pname_out ; host link 'diff >>"' pname_diff '" "' pname_inn '" "' pname_out '" ' ; write timestamp ; +---+ >> Current code : symTranslate_file_test IS { LOCAL d_Lucas test_name pname_diff pname_inn pname_out ; NONLOCAL flag_test_comment_log ; % ; test_name := link 'symTranslate_file_test: ' timestamp ; IF flag_test_comment_log THEN open_test_comment_logFile test_name ; ENDIF ; EACH write_testStr ' ' '+---------------+' test_name ; write_testStr 'symTranslate_string translates "simple symbols" and "composite expressions"' ; % ; d_Lucas := '/media/bill/PROJECTS/Lucas - Universal Force/' ; pname_inn := link d_Lucas 'Howell - math of Lucas Universal Force 180518.txt' ; pname_out := link d_QNial_temp 'Howell - math of Lucas Universal Force ' timestamp_YYMMDD '.txt' ; pname_diff := link d_QNial_temp 'trans_file_diff.txt' ; % ; write_testStr ' symTranslate_file_test example 1: compare test results in : ' ; write_testStr link ' pname_inn= ' pname_inn ; write_testStr link ' pname_out= ' pname_out ; write_testStr link ' pname_dif= ' pname_diff ; write_testStr link ' (ideally "' pname_diff '" will be empty except for "good" substitution lines)' ; % ; symTranslate_file pname_inn pname_out ; host link 'diff >>"' pname_diff '" "' pname_inn '" "' pname_out '" ' ; write_testStr timestamp ; % ; IF flag_test_comment_log THEN close_test_comment_logFile ; ENDIF ; } I removed : # 18May2018 no longer used for now set_trans_table IS OP tbl_name { NONLOCAL flag_strProtected trans_rows trans_old trans_new trans_msg transExpr_rows transExpr_old transExpr_new transExpr_msg ; trans_rows := execute link 'trans_rows_' tbl_name ; trans_old := execute link 'trans_old_' tbl_name ; trans_new := execute link 'trans_new_' tbl_name ; trans_msg := execute link 'trans_msg_' tbl_name ; transExpr_rows := execute link 'transExpr_rows_' tbl_name ; transExpr_old := execute link 'transExpr_old_' tbl_name ; transExpr_new := execute link 'transExpr_new_' tbl_name ; transExpr_msg := execute link 'transExpr_msg_' tbl_name ; IF (= 'Lucas_bads' tbl_name) THEN flag_strProtected := l ; ELSEIF (= 'Lucas_to_HLFN' tbl_name) THEN flag_strProtected := o ; ELSEIF (= 'HLFN_bads' tbl_name) THEN flag_strProtected := o ; ELSE write 'set_trans_table ERROR: tbl_name is unknown' ; ENDIF ; } # default start %flag_strProtected := o ; Redo my standard tests to [track,kill] bugs : >> I had to modify the [] tests to specify WHICH [trans,transExpr]_table to use. 19May2018 Numerous glitches were encountered, so I'll have to bug-track them +-----+ symTrans_test ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΣΤΥΦΧ��Ωαβγδεζηθικλμνξοπρςστυφχψω∬∮∂∫� >> YIKES! two characters don't work!! 'Ψ´' In strings.ndf, I changed `´ to '´' : chrs_symbols_HFLN := link chrs_alphaNumUnder chrs_Greek_all chrs_unicode3 '´' ; % Howell's Flat-Liner Notation ; >> Not enough - I have TWO symbols [search '',replace '´'] in "Howell - math of Lucas Universal Force.ndf" and all "symbols translate" files >> OK - now it works How do I fix 'Ψ' ?? it doesn't work properly? but it does work at a simple level : qnial> a := 'Ψ' Ψ qnial> a Ψ # >> is there "unicode overlap" with [adjacent,other] symbols? >> leave for later ... Example 2 glitch : error as symbol not found >> problem was a stray "flag_test_comment_log" that disrupted output. >> Ok, now it works Retry ALL symTrans_test : >> OK, they ALL work correctly +-----+ xprs_ExtractTranslate_test 19May2018 symTrans_lineType - was missing from xprs_ExtractTranslate_test NONLOCAL, defaults to `# -->[nextv] transExpr_old_Lucas_bads@0 ?address >> this should be OK??? what gives, as transExpr_old_Lucas_bads has 36 strings!! -->[nextv] in_string '|ro - vo*t|' str l >> OK -->[nextv] gage shape transExpr_old_Lucas_bads >> WRONG! returns null ??? -->[nextv] gage shape transExpr_new_Lucas_bad 36 >> OK >> AH HAH! all transExpr_ variable names have "bad" instead of "bads" >> Fix it for ALL transExpr_[Lucas,HLFN]_bads - actually, ONLY transExpr_[oldn,ew]_Lucas_bads had the problem -->[nextv] 1 EACHRIGHT writefile t_input t_standard t_result - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. ?noexpr ?not char data in writefile ?not char data in writefile -->[nextv] writefile 1 t_result ?not char data in writefile -->[nextv] write t_result +-----------------------------------------+-------------------------------------+ |+-----------+-----------------+---------+|+---------+-----------------+-------+| |||ro - vo*t||ros*cosOo - vos*t|ro - vo*t||||r - v*t||rs*cos(θ) - vs*t|r - v*t|| |+-----------+-----------------+---------+|+---------+-----------------+-------+| +-----------------------------------------+-------------------------------------+ -->[nextv] writefile 1 (picture t_result) +-----------------------------------------+-------------------------------------+ |+-----------+-----------------+---------+|+---------+-----------------+-------+| |||ro - vo*t||ros*cosOo - vos*t|ro - vo*t||||r - v*t||rs*cos(θ) - vs*t|r - v*t|| |+-----------+-----------------+---------+|+---------+-----------------+-------+| +-----------------------------------------+-------------------------------------+ -->[nextv] 1 EACHRIGHT writefile (EACH picture t_input t_standard t_result) - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. +-----------------------------------------+-------------------------------------+ |+-----------+-----------------+---------+|+---------+-----------------+-------+| |||ro - vo*t||ros*cosOo - vos*t|ro - vo*t||||r - v*t||rs*cos(θ) - vs*t|r - v*t|| |+-----------+-----------------+---------+|+---------+-----------------+-------+| +-----------------------------------------+-------------------------------------+ +-----------------------------------------+-------------------------------------+ |+-----------+-----------------+---------+|+---------+-----------------+-------+| |||ro - vo*t||ros*cosOo - vos*t|ro - vo*t||||r - v*t||rs*cos(θ) - vs*t|r - v*t|| |+-----------+-----------------+---------+|+---------+-----------------+-------+| +-----------------------------------------+-------------------------------------+ ?noexpr ?noexpr ?noexpr So in strings.ndf -> test_comment I changed : fot_test_comment EACHRIGHT writefile 't_input, t_standard, t_result = ' (picture t_input) t_standard t_result ; >> to : fot_test_comment EACHRIGHT writefile (EACH picture 't_input, t_standard, t_result = ' (picture t_input) t_standard t_result) ; >> Try again : qnial> xprs_ExtractTranslate_test +---------------+ xprs_ExtractTranslate_test xprs_ExtractTranslate ONLY translates "composite expressions" that have exact copies in transExpr_table. - otherwise it returns null 11May2018 - poor tests, almost all give null results. - must be changed to properly test xprs_ExtractTranslate. # xprs_ExtractTranslate_test example 2a : OK - result matches standard t_input, t_standard, t_result = - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. +-----------------------------------------+-------------------------------------+ |+-----------+-----------------+---------+|+---------+-----------------+-------+| |||ro - vo*t||ros*cosOo - vos*t|ro - vo*t||||r - v*t||rs*cos(θ) - vs*t|r - v*t|| |+-----------+-----------------+---------+|+---------+-----------------+-------+| +-----------------------------------------+-------------------------------------+ +-----------------------------------------+-------------------------------------+ |+-----------+-----------------+---------+|+---------+-----------------+-------+| |||ro - vo*t||ros*cosOo - vos*t|ro - vo*t||||r - v*t||rs*cos(θ) - vs*t|r - v*t|| |+-----------+-----------------+---------+|+---------+-----------------+-------+| +-----------------------------------------+-------------------------------------+ symTrans_lineType= $ translation should work: incorrect "composite expressions" are in transExpr_HFLN_bads >> Looks good! Try ALL xprs_ExtractTranslate_test examples (after fixing [symTrans_lineType,comments]) : >> I changed strings.ndf -> test_comment to writefile pictures of each result!! >> 19May2018 12:36 OK, now ALL xprs_ExtractTranslate_test give correct results +---------------+ symTranslate_string_test, 19May2018 12:41 Multiple [run,assess,code change] cycles : +---+ Examples [8^,] - r-> Rocv(POIo) !! (WHY??) I can't see why this is happening +---+ Examples [1%,] - dp[dt converted to ∂[∂t Examples [5^,5a$,9$,10^] - dp[dt retained - WHY?!?! As per : symsExtractTranslate IS OP str { LOCAL address i lengths mixList mixList_cull textnew xprList_raw xprList_trn symList_raw symList_std symList_trn symList_raw_chg symList_std_chg symList_trn_chg allList_raw allList_std allList_trn allList_raw_grade allList_trn_grade allList_raw_cull allList_trn_cull ; NONLOCAL chrs_symbols_HFLN ; % ; textnew := str ; xprList_raw xprList_trn := xprs_ExtractTranslate str ; symList_raw := symExtract_string str ; % ; symList_std := EACH sym_stdForm symList_raw ; symList_trn := EACH symTrans symList_std ; >> xprs_ExtractTranslate runs BEFORE symTrans >> Also dp[dt and others like that are 'composite expressions", not symbols, so they should be in symTrans? >> I changed trans[.Expr]_[Lucas_bads,Lucas_to_HFLN,HFLN_bads] >> OK!! now dp[dt is converted to ∂[∂t for all examples. +---+ Examples [1%,5^,10^] - spaces removed from symParens - is this supposed to happen? Examples [5a$,9$] - spaces kept in symParens - is this supposed to happen? see example 9 and "symbols stdForm.ndf" : % remove all [spaces,tabs] EXCEPT ensure 1 space around each '-+', retain '.', and following each chrs_stop_paren=')]}>' ; >> OK +---+ Also need to : convert to : ∬s( ∬[ ∮( ∮[ >> OK +---+ 19May2018 19:10 I have a problem with substitutions WITHIN symbols (YIKES!!!!) Sometimes symbols are NOT being substituted (WHY?) #] 20May2018 08:11 YIKES!!! I need to get rid of this, as flag_strProtected is no longer useful!! remove all references to flag_strProtected from "symbols translate.ndf" and "symbols extract & sort.ndf" copy content of symExtractString into symExtract_string symExtract_string IS OP str { NONLOCAL flag_strProtected sym_chrs symExtractString_recurLevel ; symExtractString_recurLevel := -1 ; IF (AND flag_strProtected ( = `$ str@0)) THEN symExtractString str ELSEIF (AND (NOT flag_strProtected) (~= `$ str@0)) THEN symExtractString str ELSE null ENDIF } Now retry symTranslate_string_test example 9 : >> OK - works!! Now retry all symTranslate_string_test, after adjusting blanks # 08********08 #] 20May2018 I have a problem with substitutions WITHIN symbols (YIKES!!!!) # symTranslate_string_test example 8 : FAILED - result does NOT match standard t_input, t_standard, t_result = ^HLFN = q/c*(vr)/r´s^2 + vov/cEi(rp,tp) ^HLFN = Q(particle)/c*(Vonv_X_Rpcv)/Rpcs(POIp)^2 + vov/cEIodv(POIp(t),t) ^HLFN = Q(paRocv(POIo)ticle)/c*(Vonv(paRocv(POIo)ticle)Rocv(POIo))/Rpcs(POIp)^2 + Vonv(paRocv(POIo)ticle)oVonv(paRocv(POIo)ticle)/cEIodVonv(paRocv(POIo)ticle)(POIp(t),t) symTrans_lineType= ^ translation should work for some [syms,exprs] as they are in trans[,Expr]_old_Lucas_to_HFLN. !! r-> Rocv(POIo) !! # symTranslate_string_test example 9 : OK - result matches standard t_input, t_standard, t_result = $HLFN : ∮(dl, over C : B) = ∬s(·dS : μ0*J + μ0*ε0*dp[dt : E] ) $HLFN : ∮[∂(l),overC: B) = ∬[·∂(Area): μ0*J + μ0*ε0*∂[∂(t): E]) $HLFN : ∮[∂(l),overC: B) = ∬[·∂(Area): μ0*J + μ0*ε0*∂[∂(t): E]) symTrans_lineType= $ translation should work for some [syms,exprs] as they are in trans[,Expr]_old_Lucas_bads # symTranslate_string_test example 9a : OK - result matches standard t_input, t_standard, t_result = $HLFN : ∮(dl,.over.C : B) = ∬s(·dS : μ0*J + μ0*ε0*dp[dt : E] ) $HLFN : ∮[∂(l),.over.C: B) = ∬[·∂(Area): μ0*J + μ0*ε0*∂[∂(t): E]) $HLFN : ∮[∂(l),.over.C: B) = ∬[·∂(Area): μ0*J + μ0*ε0*∂[∂(t): E]) symTrans_lineType= $ same as example 9 # symTranslate_string_test example 10 : FAILED - result does NOT match standard t_input, t_standard, t_result = ^[·dl : E(r´,t´)] = -1/c*dp[dt : [dA : B(r,t) •n]] .and.[·dl : E(r´,t´)] = - [dA : dp[dt : B(r,t))]·n] ^[·∂(l): ETodv(POIp(t),t)] = -1/c*∂[∂(t): [∂(Area): BTodv(POIo,t)•n]] .and.[·∂(l): ETodv(POIp(t),t)] = - [∂(Area): ∂[∂(t): BTodv(POIp(t),t)] ·n] ^[·∂(l): ETodv(POIp(t),t)] = -1/c*∂[∂(t): [∂(ARocv(POIo)ea): BTodv(POIo,t)•n]] .and.[·∂(l): ETodv(POIp(t),t)] = - [∂(ARocv(POIo)ea): ∂[∂(t): BTodv(POIo,t))]·n] symTrans_lineType= ^ translation should work for most [syms,exprs], those that are in trans[,Expr]_Lucas_to_HFLN Notice that examples [9,9a] don't have a problem, but [8,10] do. This may be due to `$ applies to [9,9a], `^ applies to [8,10] ? Showing recursion [level original translated] : +---+ Example 8 : glitches, double substitution 0 q Q(paRocv(POIo)ticle) ? vr Vonv(paRocv(POIo)ticle) ? vov Vonv(paRocv(POIo)ticle)oVonv(paRocv(POIo)ticle) ? EIodv(POIp(t),t) EIodVonv(paRocv(POIo)ticle)(POIp(t),t) "tranList Lucas to HLFN.ndf" has : 'vr' 'Vonv_X_Rpcv' msg_Lucas_to_HLFN_sol This was in TWICE!! (extra removed : 'q' 'Q(particle)' msg_Lucas_to_HLFN_sol >> should have given But "tranList Lucas to HLFN.ndf" doesn't even have : ? vov Vonv(paRocv(POIo)ticle)oVonv(paRocv(POIo)ticle) perhaps by sub v Vonv(particle) Vonv(particle)oVonv(particle) sub r Rocv(POIo) Vonv(paRocv(POIo)ticle)oVonv(paRocv(POIo)ticle) >> These are definitely NOT supposed to happen, as it is breaking up symbols!! >> Only symExpr can do that?, vut v,r are NOT in transExpr_Lucas_to_HFLN >> Similar problem with [q,vr] Perhaps related to [single,solitary] issue? break trace Bye, then qnial, then : qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf' >>> loading start : symbols translate- tests.ndf >>>>>> loading start : strings.ndf >>>>>>>>> loading start : file_ops.ndf <<<<<<<<< loading ended : file_ops.ndf <<<<<< loading ended : strings.ndf >>>>>> loading start : symbols translate.ndf >>>>>>>>> loading start : symbols stdForm.ndf <<<<<<<<< loading ended : symbols stdForm.ndf >>>>>>>>> loading start : symbols extract & sort.ndf ?undefined identifier: := EACH SYMEXTRACTSTRING <***> SYMPARENLIST ; SYMLIST <<<<<<<<< loading ended : symbols extract & sort.ndf errors found: 1 >>>>>>>>> loading start : tranList Lucas bads.ndf <<<<<<<<< loading ended : tranList Lucas bads.ndf >>>>>>>>> loading start : tranList Lucas to HLFN.ndf <<<<<<<<< loading ended : tranList Lucas to HLFN.ndf >>>>>>>>> loading start : tranList HLFN bads.ndf <<<<<<<<< loading ended : tranList HLFN bads.ndf ?undefined identifier: := EACH SYMEXTRACTSTRING <***> SYMPARENLIST ; SYMLIST ?undefined identifier: LINE_IN := SYMTRANSLATE_STRING <***> STR ; ?undefined identifier: % ; <<<<<< loading ended : symbols translate.ndf errors found: 3 ?undefined identifier: T_RESULT := SYMTRANSLATE_STRING <***> T_INPUT ; TEST_COMMENT ?undefined identifier: % ; ?undefined identifier: XPRS_EXTRACTTRANSLATE_TEST ; SYMTRANSLATE_STRING_TEST <***> ; <<< loading ended : symbols translate- tests.ndf errors found: 3 In "symbols extract & sort.ndf" : symExtract_string calls SYMEXTRACTSTRING But SYMEXTRACTSTRING has been removed!!! Change : symExStr_List := EACH symExtractString symParenList ; To : symExStr_List := EACH symExtract_string symParenList ; bye, qnial qnial> loaddefs '/media/bill/PROJECTS/Qnial/code tests/symbols translate- tests.ndf' >>> loading start : symbols translate- tests.ndf >>>>>> loading start : strings.ndf >>>>>>>>> loading start : file_ops.ndf <<<<<<<<< loading ended : file_ops.ndf <<<<<< loading ended : strings.ndf >>>>>> loading start : symbols translate.ndf >>>>>>>>> loading start : symbols stdForm.ndf <<<<<<<<< loading ended : symbols stdForm.ndf >>>>>>>>> loading start : symbols extract & sort.ndf <<<<<<<<< loading ended : symbols extract & sort.ndf >>>>>>>>> loading start : tranList Lucas bads.ndf <<<<<<<<< loading ended : tranList Lucas bads.ndf >>>>>>>>> loading start : tranList Lucas to HLFN.ndf <<<<<<<<< loading ended : tranList Lucas to HLFN.ndf >>>>>>>>> loading start : tranList HLFN bads.ndf <<<<<<<<< loading ended : tranList HLFN bads.ndf ?undefined identifier: := EACH SYMEXTRACTSTRING <***> SYMPARENLIST ; SYMLIST ?undefined identifier: LINE_IN := SYMTRANSLATE_STRING <***> STR ; ?undefined identifier: % ; <<<<<< loading ended : symbols translate.ndf errors found: 3 ?undefined identifier: T_RESULT := SYMTRANSLATE_STRING <***> T_INPUT ; TEST_COMMENT ?undefined identifier: % ; ?undefined identifier: XPRS_EXTRACTTRANSLATE_TEST ; SYMTRANSLATE_STRING_TEST <***> ; <<< loading ended : symbols translate- tests.ndf errors found: 3 In "symbols translate.ndf", search-replace [symExtractString, symExtract_string] Now retry symTranslate_string_test >> HORRIBLE, symTranslate_string now returns a list of symbols! Muxup! I should have commented out the old (simple) symExtract_string, and renamed symExtractString to symExtract_string. I just did that... # symExtract_string IS OP str - decides whether [normal, protected] lines are extracted, or if null is simply returned symExtract_string IS OP str { NONLOCAL flag_strProtected sym_chrs symExtractString_recurLevel ; symExtractString_recurLevel := -1 ; IF (AND flag_strProtected ( = `$ str@0)) THEN symExtractString str ELSEIF (AND (NOT flag_strProtected) (~= `$ str@0)) THEN symExtractString str ELSE null ENDIF } Gives : symExtract_string IS OP str { LOCAL chr_code chr_code2 chr_new dim_flags flags i len n_paren symExStr_List symParenList symList symNew ; NONLOCAL chrs_symbols_HFLN chrs_stop_paren chrs_strt_paren symExtract_array symExtractString_recurLevel ; symExtractString_recurLevel := symExtractString_recurLevel + 1 ; %----------write link 'symExtractString_recurLevel: ' (string symExtractString_recurLevel) ; % ; %------------ ; %stops recursive callS ; IF (isstring str) THEN % ; symNew := '' ; symList := null ; dim_flags := gage shape shape symExtract_array ; flags := dim_flags reshape 0 ; n_paren := 0 ; len := gage shape str ; i := 0 ; % ; WHILE (i < len) DO chr_code := charrep str@i ; IF (chr_code < 0) THEN chr_code2 := charrep str@(i + 1) ; IF (chr_code2 < 0) THEN chr_code3 := charrep str@(i + 2) ; IF (chr_code3 < 0) THEN chr_new := char (chr_code chr_code2 chr_code3) ; i := i + 2 ; ELSE chr_new := char (chr_code chr_code2 ) ; i := i + 1 ; ENDIF ; ELSE chr_new := char (chr_code ) ; ENDIF ; ELSE chr_new := char (chr_code ) ; ENDIF ; chr_new := string chr_new ; IF (in_string chr_new chrs_blank) THEN flags@1 := 0 ; execute symExtract_array@(flags) ; ELSEIF (in_string chr_new chrs_symbols_HFLN) THEN flags@1 := 1 ; execute symExtract_array@(flags) ; ELSEIF (in str@i chrs_strt_paren) THEN flags@1 := 0 ; IF (= 1 flags@0) THEN n_paren := n_paren + 1 ; flags@2 := 1 ; ENDIF ; execute symExtract_array@(flags) ; ELSEIF (in str@i chrs_stop_paren) THEN flags@1 := 0 ; execute symExtract_array@(flags) ; IF (= 1 flags@0) THEN n_paren := n_paren - 1 ; IF (0 < n_paren) THEN flags@2 := 1 ; ELSE flags@2 := 0 ; ENDIF ; ENDIF ; ELSE % non-[chrs_blank,chrs_symbols_HFLN,chrs_[strt,stop]_paren] characters ; flags@1 := 0 ; execute symExtract_array@(flags) ; ENDIF ; i := i + 1 ; symTranslate_alltest ENDWHILE ; % ; %capture the symNew at the end of the line (if there is one) ; IF (= 1 flags@0) THEN symList := link symList (solitary symNew) ; ENDIF ; symParenList := syms_inParens symList ; symExStr_List := EACH symExtractString symParenList ; symList := link symList (link symExStr_List) ; % ; %------------ ; %stops recursive calls ; ELSE symList := null ; %write link 'symExtractstring recurLevel null string input: ' (string symExtractString_recurLevel) ; ENDIF ; % ; symList } +---+ # symTranslate_string IS OP str - prepares a string and a sed expression # for translate_sed using a dictionary, so all dictionary subs are done # 09Apr2018 in the future I need to specify translation "dictionaries"! (not just use default names!) # 02May2018 keep [spaces,tabs] outside of symbols, standard form within # 02May2018 for now find_HOWELL searches entire trans_old, but I should use an efficient search! # if str starts with `$, then it is NOT translated, and the original string is returned # don't spend time on [expr,sym] locations initially, as the str is continually changing! # 05May2018 symList_raw components may change to a standard format, but for now expressions don't have a standard form ; # 05May2018 lines with no [syms,xprs] - errors and waste of time # QNial version # Note : # symbols - are symbol_character sequences, or compound phrases in a "headed parenthetical wrapping" # some such symbols are in trans_table, and thereby have a translation # expressions - are collections of symbols that have translations in transExpr_table # 18May2018 - no longer used : # WARNING!!! MUST use set_trans_table to choose right translation BEFORE running this # one of : ['Lucas_bads','Lucas_to_HLFN','HLFN_bads'] # old, not used symTranslate_string IS OP str { LOCAL address i lengths mixList mixList_cull textnew ; NONLOCAL symTrans_lineType ; % ; IF (in str@0 '#$%') THEN symTrans_lineType := str@0 ; ENDIF ; IF (= `# symTrans_lineType) THEN str ELSE symsExtractTranslate str ENDIF } # useful debugging output : EACH write 'symExtractString_recurLevel, symList= ' (link symExtractString_recurLevel symList) ; EACH write 'symParenList= ' symParenList ; EACH write 'symContentList= ' symContentList ; EACH write 'symExStr_List= ' symExStr_List ; # loaddefs link d_Qnial_mine 'symbols translate.ndf' +---+ >> OK, taken out of code now but now all of this mornings problems have returned!! still Ok : symTrans_test ; xprs_ExtractTranslate_test ; WILD GOOSE CHASE!! I reversed all the big changes above. Bakc to the drawing board # 08********08 #] 20May2018 RESTART on : I have a problem with substitutions WITHIN symbols (YIKES!!!!) # symTranslate_string_test example 8 : FAILED - result does NOT match standard t_input, t_standard, t_result = ^HLFN = q/c*(vr)/r´s^2 + vov/cEi(rp,tp) ^HLFN = Q(particle)/c*(Vonv_X_Rpcv)/Rpcs(POIp)^2 + vov/cEIodv(POIp(t),t) ^HLFN = Q(paRocv(POIo)ticle)/c*(Vonv(paRocv(POIo)ticle)Rocv(POIo))/Rpcs(POIp)^2 + Vonv(paRocv(POIo)ticle)oVonv(paRocv(POIo)ticle)/cEIodVonv(paRocv(POIo)ticle)(POIp(t),t) symTrans_lineType= ^ translation should work for some [syms,exprs] as they are in trans[,Expr]_old_Lucas_to_HFLN. !! r-> Rocv(POIo) !! # symTranslate_string_test example 9 : OK - result matches standard t_input, t_standard, t_result = $HLFN : ∮(dl, over C : B) = ∬s(·dS : μ0*J + μ0*ε0*dp[dt : E] ) $HLFN : ∮[∂(l),overC: B) = ∬[·∂(Area): μ0*J + μ0*ε0*∂[∂(t): E]) $HLFN : ∮[∂(l),overC: B) = ∬[·∂(Area): μ0*J + μ0*ε0*∂[∂(t): E]) symTrans_lineType= $ translation should work for some [syms,exprs] as they are in trans[,Expr]_old_Lucas_bads # symTranslate_string_test example 9a : OK - result matches standard t_input, t_standard, t_result = $HLFN : ∮(dl,.over.C : B) = ∬s(·dS : μ0*J + μ0*ε0*dp[dt : E] ) $HLFN : ∮[∂(l),.over.C: B) = ∬[·∂(Area): μ0*J + μ0*ε0*∂[∂(t): E]) $HLFN : ∮[∂(l),.over.C: B) = ∬[·∂(Area): μ0*J + μ0*ε0*∂[∂(t): E]) symTrans_lineType= $ same as example 9 # symTranslate_string_test example 10 : FAILED - result does NOT match standard t_input, t_standard, t_result = ^[·dl : E(r´,t´)] = -1/c*dp[dt : [dA : B(r,t) •n]] .and.[·dl : E(r´,t´)] = - [dA : dp[dt : B(r,t))]·n] ^[·∂(l): ETodv(POIp(t),t)] = -1/c*∂[∂(t): [∂(Area): BTodv(POIo,t)•n]] .and.[·∂(l): ETodv(POIp(t),t)] = - [∂(Area): ∂[∂(t): BTodv(POIp(t),t)] ·n] ^[·∂(l): ETodv(POIp(t),t)] = -1/c*∂[∂(t): [∂(ARocv(POIo)ea): BTodv(POIo,t)•n]] .and.[·∂(l): ETodv(POIp(t),t)] = - [∂(ARocv(POIo)ea): ∂[∂(t): BTodv(POIo,t))]·n] symTrans_lineType= ^ translation should work for most [syms,exprs], those that are in trans[,Expr]_Lucas_to_HFLN Notice that examples [9,9a] don't have a problem, but [8,10] do. This may be due to `$ applies to [9,9a], `^ applies to [8,10] ? Showing recursion [level original translated] : +---+ Example 8 : glitches, double substitution 0 q Q(paRocv(POIo)ticle) ? vr Vonv(paRocv(POIo)ticle) ? vov Vonv(paRocv(POIo)ticle)oVonv(paRocv(POIo)ticle) ? EIodv(POIp(t),t) EIodVonv(paRocv(POIo)ticle)(POIp(t),t) "tranList Lucas to HLFN.ndf" has : 'vr' 'Vonv_X_Rpcv' msg_Lucas_to_HLFN_sol This was in TWICE!! (extra removed : 'q' 'Q(particle)' msg_Lucas_to_HLFN_sol >> should have given But "tranList Lucas to HLFN.ndf" doesn't even have : ? vov Vonv(paRocv(POIo)ticle)oVonv(paRocv(POIo)ticle) perhaps by sub v Vonv(particle) Vonv(particle)oVonv(particle) sub r Rocv(POIo) Vonv(paRocv(POIo)ticle)oVonv(paRocv(POIo)ticle) >> These are definitely NOT supposed to happen, as it is breaking up symbols!! >> Only symExpr can do that?, vut v,r are NOT in transExpr_Lucas_to_HFLN >> Similar problem with [q,vr] Perhaps related to [single,solitary] issue? break trace symsExtractTranslate for example 8 20May2018 Ah Hah! in symsExtractTranslate : textnew := string_sub allList_raw_cull@i allList_trn_cull@i textnew ; >> THIS is the problem, as it MUST bye a [symbol,expression] substitution, NOT a sub-string substitution!! Need to write modifications to : (I forgot to copy it BEFORE making changes) symExpr_sub IS OP symExpr_old symExpr_new str { LOCAL i_str i_sub_old len_str len_sub_old textnew ; % ; IF (NOT OR (sub_old sub_new EACHLEFT = null)) THEN % ; len_sub_old := gage shape sub_old ; len_str := gage shape str ; i_str i_sub_old := 0 0 ; textnew := null ; WHILE (i_str < len_str) DO WHILE (AND ((i_sub_old + i_str) < len_str) (i_sub_old < len_sub_old) (= sub_old@i_sub_old str@(i_str + i_sub_old)) ) DO i_sub_old := i_sub_old + 1 ; ENDWHILE ; %write link '[i_str,i_sub_old]= ' (string i_str) ', ' (string i_sub_old) ; IF (len_sub_old = i_sub_old) THEN flag_follow flag_precede := l l ; IF (i_str > 0) THEN flag_precede := in str@(i_str - 1) chrs_symbols_HFLN ; ENDIF ; IF (i_str < (len_str - 1)) THEN flag_follow := in str@(i_str) chrs_symbols_HFLN ; ENDIF ; textnew := link textnew sub_new ; i_str := i_str + len_sub_old - 1 ; ELSEIF (0 <= i_sub_old) THEN textnew := link textnew str@i_str ; ELSE write fault '?symExpr_sub - i_sub_old is anomalous' ; ENDIF ; %write textnew ; i_str := i_str + 1 ; i_sub_old := 0 ; ENDWHILE ; % ; ELSE textnew := null ; ENDIF ; % ; IF (= null textnew) THEN str ELSE textnew ENDIF } # 08********08 # 21May2018 Now these seem to work (no more [multiple,erroneous,recursive] substitutions?) : chr_unicode_before_after_str_i IS OP direction i_str str symExpr_sub IS OP symExpr_old symExpr_new str symsExtractTranslate IS OP str symTranslate_string IS OP str Next, try : symTranslate_file_test IS And I will have to do a lot of work to improve : symList HFLN good.txt symList Lucas bad.txt symList Lucas english.txt symList Lucas equation numbers.txt symList Lucas good.txt tranList HLFN bads.ndf tranList Lucas bads.ndf tranList Lucas to HLFN.ndf # 08********08 #] 22May2018 15:48 Re-ran full set of tests except [symTranslate_file_test] via symTranslate_alltest see "symbols translate_alltest, 180522 02h05m49s.txt" >> all are correct, EXCEPT : +-----+ # symTranslate_string_test example 8 : FAILED - result does NOT match standard t_input, t_standard, t_result = ^HLFN = q/c*(vr)/r´s^2 + vov/cEi(rp,tp) ^HLFN = Q(particle)/c*(Vonv_X_Rocv(POIo))/Rpcs(POIp)^2 + Vonv(particle)/cEIodv(POIp(t),t) ^HLFN = Q(paRocv(POIo)ticle)/c*(VonVonv(paRocv(POIo)ticle)_X_RocVonv(paRocv(POIo)ticle)(POIo))/Rpcs(POIp)^2 + VonVonv(paRocv(POIo)ticle)(paRocv(POIo)ticle)/cEIodVonv(paRocv(POIo)ticle)(POIp(t),t) symTrans_lineType= ^ translation should work for all [syms,exprs] except vov, as they are in trans[,Expr]_old_Lucas_to_HFLN. # symTranslate_string_test example 10 : FAILED - result does NOT match standard t_input, t_standard, t_result = ^[·dl : E(r´,t´)] = -1/c*dp[dt : [dA : B(r,t) •n]] .and.[·dl : E(r´,t´)] = - [dA : dp[dt : B(r,t))]·n] ^[·∂(l): ETodv(POIp(t),t)] = -1/c*∂[∂(t): [∂(Area): BTodv(POIo,t)•n]] .and.[·∂(l): ETodv(POIo,t)] = - [∂(Area): ∂[∂(t): BTodv(POIp(t),t)]·n] ^[·∂(l): ETodv(POIp(t),t)] = -1/c*∂[∂(t): [∂(ARocv(POIo)ea): BTodv(POIo,t)•n]] .and.[·∂(l): ETodv(POIp(t),t)] = - [∂(ARocv(POIo)ea): ∂[∂(t): BTodv(POIo,t))]·n] symTrans_lineType= ^ translation should work for most [syms,exprs], those that are in trans[,Expr]_Lucas_to_HFLN +-----+ >> In other words, I have failed to solve the recursive substitution problem! >> NUTS!! I'm taking a break for a couple of days. Then I'll have to break-trace the failures. 22May2018 18:51 revised : symExpr_sub IS OP symExpr_old symExpr_new str { LOCAL flg_front flg_back flag_follow flag_precede flg_subStart flg_subEnd i_str i_sub_old len_str len_sub_old textnew ; % ; IF (NOT OR (symExpr_old symExpr_new EACHLEFT = null)) THEN % ; len_sub_old := gage shape symExpr_old ; len_str := gage shape str ; i_str i_sub_old := 0 0 ; textnew := null ; flg_subStart flg_subEnd := EACH NOT ( (EACH chrs_before_after_str_i (1 -1 symExpr_old) (-1 len_sub_old symExpr_old)) EACHLEFT in_string chrs_symbols_HFLN ) ; WHILE (i_str < len_str) DO WHILE (AND ((i_sub_old + i_str) < len_str) (i_sub_old < len_sub_old) (= symExpr_old@i_sub_old str@(i_str + i_sub_old)) ) DO i_sub_old := i_sub_old + 1 ; ENDWHILE ; %write link '[i_str,i_sub_old]= ' (string i_str) ', ' (string i_sub_old) ; IF (len_sub_old = i_sub_old) THEN flg_precede flg_follow := EACH NOT ( (EACH chrs_before_after_str_i (-1 i_str str) (1 (i_str + len_sub_old) str) ) EACHLEFT in_string chrs_symbols_HFLN ) ; IF flg_subStart THEN flg_front := o ; ELSE flg_front := flg_precede ; ENDIF ; IF flg_subEnd THEN flg_back := o ; ELSE flg_back := flg_follow ; ENDIF ; IF (OR (flg_front flg_back)) THEN write ' ' ; write i_sub_old i_str flg_front flg_back symExpr_old symExpr_new str ; textnew := link textnew symExpr_new ; i_str := i_str + len_sub_old - 1 ; write textnew ; ELSE textnew := link textnew str@i_str ; ENDIF ; ELSEIF (0 <= i_sub_old) THEN textnew := link textnew str@i_str ; ELSE write fault '?symExpr_sub - i_sub_old is anomalous' ; ENDIF ; %write textnew ; i_str := i_str + 1 ; i_sub_old := 0 ; ENDWHILE ; % ; ELSE textnew := null ; ENDIF ; % ; IF (= null textnew) THEN str ELSE textnew ENDIF } >> GREAT!! finally, examples [8,10] work, insofar as nasty substitutions!! +-----+ # symTranslate_string_test example 8 : OK - result matches standard t_input, t_standard, t_result = ^HLFN = q/c*(vr)/r´s^2 + vov/cEi(rp,tp) ^HLFN = Q(particle)/c*(Vonv_X_Rocv(POIo))/Rpcs(POIp)^2 + Vonv(particle)/cEIodv(POIp(t),t) ^HLFN = Q(particle)/c*(Vonv_X_Rocv(POIo))/Rpcs(POIp)^2 + Vonv(particle)/cEIodv(POIp(t),t) symTrans_lineType= ^ translation should work for all [syms,exprs], as they are in trans[,Expr]_old_Lucas_to_HFLN. # symTranslate_string_test example 10 : FAILED - result does NOT match standard t_input, t_standard, t_result = ^[·dl : E(r´,t´)] = -1/c*dp[dt : [dA : B(r,t) •n]] .and.[·dl : E(r´,t´)] = - [dA : dp[dt : B(r,t))]·n] ^[·∂(l): ETodv(POIp(t),t)] = -1/c*∂[∂(t): [∂(Area): BTodv(POIo,t)•n]] .and.[·∂(l): ETodv(POIo,t)] = - [∂(Area): ∂[∂(t): BTodv(POIp(t),t)]·n] ^[·∂(l): ETodv(POIp(t),t)] = -1/c*∂[∂(t): [∂(Area): BTodv(POIo,t)•n]] .and.[·∂(l): ETodv(POIp(t),t)] = - [∂(Area): ∂[∂(t): BTodv(POIo,t))]·n] symTrans_lineType= ^ translation should work for most [syms,exprs], those that are in trans[,Expr]_Lucas_to_HFLN +-----+ >> example 10 - 'E(r´,t´)' 'ETodv(POIp(t),t)' msg_Lucas_to_HLFN_sol >> so t_standard is wrong (I corrected it), and t_result is correct! I reran symTranslate_alltest - see "symbols translate_alltest, 180522 18h59m20s.txt" It was necessary to correct t_standard several times because of small errors +-----+ # symTranslate_string_test example 10 : OK - result matches standard t_input, t_standard, t_result = ^[·dl : E(r´,t´)] = -1/c*dp[dt : [dA : B(r,t) •n]] .and.[·dl : E(r´,t´)] = - [dA : dp[dt : B(r,t)]·n] ^[·∂(l): ETodv(POIp(t),t)] = -1/c*∂[∂(t): [∂(Area): BTodv(POIo,t)•n]] .and.[·∂(l): ETodv(POIp(t),t)] = - [∂(Area): ∂[∂(t): BTodv(POIo,t)]·n] ^[·∂(l): ETodv(POIp(t),t)] = -1/c*∂[∂(t): [∂(Area): BTodv(POIo,t)•n]] .and.[·∂(l): ETodv(POIp(t),t)] = - [∂(Area): ∂[∂(t): BTodv(POIo,t)]·n] symTrans_lineType= ^ translation should work for most [syms,exprs], those that are in trans[,Expr]_Lucas_to_HFLN +-----+ >> ALL examples are OK!!! AWESOME! # 08********08 #] 22May2018 Now [test,edit] cycle symTranslate_file_test +---------------+ uses symTranslate_string, which translates symbols and expressions symTranslate_file_test example 1: compare test results in : pname_inn= /media/bill/PROJECTS/Lucas - Universal Force/Howell - math of Lucas Universal Force 180518.txt pname_out= /media/bill/ramdisk/Howell - math of Lucas Universal Force 180522.txt pname_dif= /media/bill/ramdisk/trans_file_diff.txt (ideally "/media/bill/ramdisk/trans_file_diff.txt" will be empty except for "good" substitution lines) Tue May 22 21:33:01 2018 >> I couldn't see any "smash-ups" of bad symbol insertions >> I need to flush out missing [symbols,expressions] in : symList HFLN good.txt symList Lucas bad.txt symList Lucas english.txt symList Lucas equation numbers.txt symList Lucas good.txt tranList HLFN bads.ndf tranList Lucas bads.ndf tranList Lucas to HLFN.ndf >> I also need to activate symbols_compare IS OP symClass dname pname_extr >> which is in "symbols extract & sort.ndf" qnial> symTranslate_file_test >> Good, now the problem is that I have to modify [symExtract_string,symExtract_file] to handle : from "/media/bill/PROJECTS/Qnial/MY_NDFS/symbols translate.ndf" : +-----+ # symTrans_lineType : special characters at beginning of lines : # NOTE : these symbols are "persistent" until changed by a different symTrans_lineType (applies to next use of operators!!) `# comment only - no translation or extraction of symbols `$ applies tranList_Lucas_bads to a string `% applies tranList_HFLN_bads to a string `^ applies tranList_Lucas_to_HFLN to a string +-----+ >> NYET! [symExtract_string,symExtract_file] DON'T use translation, so the format is irrelevant it IS important to use "symTrans_lineType" : Do not extract if symTrans_lineType=[`#] (This is supposed to apply, but it doesn't look like it) Add a capability of separating symTrans_lineType [`$,`%,`^] >> unicode lines seek to be a problem (again!), for example : ∂(Area)ÂŽ(∇Ž[Bi(r - v*t,t)v]•np) +---------------+ symTranslate_file_test 180523 16h05m58s.txt /media/bill/PROJECTS/Qnial/code develop_tests/symbols translate- tests.ndf Wed May 23 16:05:58 2018 uses symTranslate_string, which translates symbols and expressions pname_inn= /media/bill/PROJECTS/Lucas - Universal Force/Howell - math of Lucas Universal Force 180518.txt pname_trn= /media/bill/PROJECTS/Lucas - Universal Force/Howell - math of Lucas Universal Force 180523 16h05m58s.txt pname_dif= /media/bill/ramdisk/fileDiff - math of Lucas Universal Force 180523 16h05m58s.txt (ideally "/media/bill/ramdisk/fileDiff - math of Lucas Universal Force 180523 16h05m58s.txt" will be empty except for "good" substitution lines) 183 /media/bill/PROJECTS/Lucas - Universal Force/symList bads Lucas.txt 141 /media/bill/PROJECTS/Lucas - Universal Force/symList bads HFLN.txt 398 /media/bill/PROJECTS/Lucas - Universal Force/symList good Lucas.txt 286 /media/bill/PROJECTS/Lucas - Universal Force/symList bads Lucas_to_HFLN.txt 816 /media/bill/PROJECTS/Lucas - Universal Force/symList good Lucas_to_HFLN.txt 647 /media/bill/PROJECTS/Lucas - Universal Force/symList good HFLN.txt 193 /media/bill/PROJECTS/Lucas - Universal Force/symList english.txt 86 /media/bill/PROJECTS/Lucas - Universal Force/symList equation numbers.txt 0 /media/bill/ramdisk/symDiff bads Lucas_to_HFLN.txt 607 /media/bill/ramdisk/symDiff bads Lucas.txt 0 /media/bill/ramdisk/symDiff bads LtoH.txt 248 /media/bill/ramdisk/symDiff bads HFLN.txt Wed May 23 16:08:12 2018 >> OK [symExtract_string,symExtract_file] splitting of [Lucas,Lucas_to_HFLN,HFLN] is working very well. >> There are very few english words in the symDiff files >> The remaining problem was noted above : unicode lines seek to be a problem (again!), for example : ∂(Area)ÂŽ(∇Ž[Bi(r - v*t,t)v]•np) >> Why is this happening? Is it a problem with Linux diff? Nope - this occurs in [symExtract_file HFLN.txt,symExtract_file Lucas.txt] (NOTE: "symExtract_file Lucas_to_HFLN.txt" is empty, as "Howell - math of Lucas Universal Force 180518.txt" doen't have ANY lines starting with "^") ∂[∂(t): E0ods(POIo,t=0)*sin(???AΞoc(POIp(t),t=0))^2] # 08********08 #] 24May2018 Code No longer used # symTransFile_Lucas_allTranTables IS OP pname_inn pname_out # - uses symTranslate_file for symbol translation by all of [tranList Lucas bads.ndf,tranList Lucas to HLFN.ndf,tranList HLFN bads.ndf] in that order # does't use [flag_test_comment_log,fot_test_comment,flag_test_comment] # 24May2018 doesn't work anymore???!! symTransFile_Lucas_allTranTables IS OP pname_inn pname_out { LOCAL fin fot i line_in str ; % ; IF (file_exists '-f' pname_inn) THEN pname_bads := link d_QNial_temp 'symTranFile_Lucas_allTranTables bads.txt' ; pname_Lucas_to_HLFN := link d_QNial_temp 'symTranFile_Lucas_allTranTables Lucas_to_HLFN.txt' ; % ; symTranslate_file 'Lucas_bads' pname_inn pname_bads ; symTranslate_file 'Lucas_to_HLFN' pname_inn pname_bads ; symTranslate_file 'HLFN_bads' pname_inn pname_bads ; % ; ELSE write link 'symTranFile_Lucas_allTranTables ERROR- file "' pname_inn '" does not exist' ; ENDIF ; } # old code : % 18May2018 no longer used : set_trans_table trans_table_name ; # don't need special conditions that return null : ELSEIF (= symbol symNew) THEN null ; ELSE symNew := fault '?symTrans - no translation' ; # FIRST change sin^2(...) & cos^2(...) to sin(...)^2 & cos(...)^2 # use sed via bash file "/media/bill/RaspPi_ext4_32Gb/Lucas - Universal Force/translations/sed cos & sin squared.sh" # 04Apr2018 I need an extractor of ALL symbols (skip comment lines and quoted text), # plus a [locator, identifier] of "unlisted" symbols # 08********08 #] 24May2018 Test again after many code changes - added tranList_HFLN_to_Lucas - modifications to [`^,`&] symTrans_lineTypes after translation of line >> Results : "Howell - math of Lucas Universal Force 180524 09h45m33s.txt" looks good (no symbol insertions into symbols that I can see) In "/media/bill/ramdisk/[symDiff bads [Lucas,HFLN].txt,symExtract_file [Lucas,HFLN].txt]" : >> NUTS!!! same problem of screwed up symbols!! example : ∂(Area)ÂŽ(∇Ž[Bi(r - v*t,t)v]•np) >> Why is this happening?? >> The problem must still be in "/media/bill/PROJECTS/Qnial/MY_NDFS/symbols extract & sort.ndf" 24May2018 19:30 Finally - I fixed [chrs_symbols_HFLN,chrs_unicodes_HFLN,sym_stdForm] and symTranslate_file_Lucas_test WORKS!!! YAHOO!! # 08********08 #] 24May2018 Now to run symTranslate_alltest, which now includes symExtract_alltest symTrans_test, all OK xprs_ExtractTranslate_test all OK symExpr_sub_test all but one (no translation) failed symTranslate_string_test most tests fail(> example 4), repeats input oops - also need to go back to "Howell - math of Lucas Universal Force 180518.txt" for symTranslate_file_Lucas_test I had changed '´' to ['`',''''] and other things >> done symTrans_test, all OK xprs_ExtractTranslate_test all OK symExpr_sub_test all but one (no translation) failed symTranslate_string_test most tests fail(> example 4), repeats input symParen_contents_test syms_inParens_test symExprExtract_stringPosn_test symExprExtract_stringPosn_test no outputs # 08********08 #] 26May2018 code changes to replace chrs_before_after_str_i by chrStr_get symExpr_sub : I'm not sure I have the correct logic : +-----+ IF flg_subStart THEN flg_front := o ; ELSE flg_front := flg_precede ; ENDIF ; IF flg_subEnd THEN flg_back := o ; ELSE flg_back := flg_follow ; ENDIF ; IF (AND (flg_front flg_back)) THEN textnew := link textnew symExpr_new ; i_str := i_str + len_old - 1 ; %write ' ' ; %write i_sub_old i_str flg_front flg_back symExpr_old symExpr_new str textnew ; +-----+ # 08********08 #] 31May2018 stupid wild-goose chase errors with find : # cd "/media/bill/PROJECTS/Qnial/code develop_test/" # d_tests="/media/bill/PROJECTS/Qnial/code develop_test/" # find -path "$d_tests" -maxdepth 1 -type f -name "alltest *" | xargs mv -u --target-directory="$d_tests""z_Archive/" # find -maxdepth 1 -type f "$d_tests""alltest *" | xargs mv -u --target-directory="$d_tests""z_Archive/" # find -maxdepth 1 -type f -path "$d_tests" -name "alltest *" #>> null result # find -maxdepth 1 -type f -path "$d_tests""alltest *" #>> null result # find -maxdepth 1 -type f -path "$d_tests" #>> null result # find -maxdepth 1 -type f -path "/media/bill/PROJECTS/Qnial/code develop_test/" #>> null result # find -maxdepth 1 -type f "/media/bill/PROJECTS/Qnial/code develop_test/" #find: paths must precede expression: /media/bill/PROJECTS/Qnial/code develop_test/ #Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression] # find -maxdepth 1 -type f "/media/bill/PROJECTS/Qnial/code develop_test/" -name "alltest *" #find: paths must precede expression: /media/bill/PROJECTS/Qnial/code develop_test/ #Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression] # find -maxdepth 1 -type f -path "/media/bill/PROJECTS/Qnial/code develop_test/" -name "alltest *" #>> null result # find -maxdepth 1 -type f -path "/media/bill/PROJECTS/Qnial/code develop_test/" -name "*" #>> null result # find -maxdepth 1 -type f -path "/media/bill/PROJECTS/Qnial/code develop_test" -name "*" #>> null result # find "/media/bill/PROJECTS/Qnial/code develop_test" -maxdepth 1 -type f -name "*" #>> OK - output! #/media/bill/PROJECTS/Qnial/code develop_test/NEUNET-D-14-00130 tests.ndf #/media/bill/PROJECTS/Qnial/code develop_test/symbols translate- develop.txt #>> OOPS! no files because I put them in a sub-directory! (idiot) # find "/media/bill/PROJECTS/Qnial/code develop_test/" -maxdepth 1 -type f -name "alltest *" #>> OK - correct result : #/media/bill/PROJECTS/Qnial/code develop_test/alltest symTranslate 180530 18h14m14s.txt #/media/bill/PROJECTS/Qnial/code develop_test/alltest zummary log 180530 18h14m.txt #/media/bill/PROJECTS/Qnial/code develop_test/alltest strings 180530 18h14m14s.txt #/media/bill/PROJECTS/Qnial/code develop_test/alltest symExtract 180530 18h14m14s.txt 31May2018 no longer used : # old code %in case this is being used by symbols_Translate_Extract_Strings_alltest ; p_fNames_log := link d_QNial_temp 'symTranslate_alltest log.txt' ; host link 'echo >>"' p_fNames_log '" "' f_log_test '" ' ; # 08********08 #] 26Jun2018 symExpr_sub revamped to simply convert str to chrList, get rid of chrStr_get # symExpr_sub IS OP symExpr_old symExpr_new str - substitutes symExpr_new for sub_old in str # must ensure that the positions found are NOT immediately [preceded,followed] by chrs_symbols_HFLN # 05May2018 based on in_string # 21May2018 big revamp to make it work without erroneous recursion : # replace string_sub with chr_unicode_before_after_str_i # 26Jun2018 revamped to simply convert str to chrList, get rid of chrStr_get # WARNING!! IF symExpr_old has (NOT chrs_symbols_HFLN) at [inital,end], then the SAME must apply to symExpr_new!!! change : +-----+ symExpr_sub IS OP symExpr_old symExpr_new str { LOCAL chr_new flg_front flg_back flag_follow flag_precede flg_subStart flg_subEnd i_str i_sub_old jump len_new len_old len_str textnew ; % ; IF (NOT OR (symExpr_old symExpr_new EACHLEFT = null)) THEN % ; len_old := gage shape symExpr_old ; len_new := gage shape symExpr_new ; len_str := gage shape str ; i_str i_sub_old := 0 0 ; textnew := null ; % ; chr_new jump := chrStr_get 1 0 symExpr_old ; flg_subStart := NOT in chr_new chrs_symbols_HFLN ; chr_new jump := chrStr_get -1 (len_old - 1) symExpr_old ; flg_subEnd := NOT in chr_new chrs_symbols_HFLN ; WHILE (i_str < len_str) DO WHILE (AND ((i_sub_old + i_str) < len_str) (i_sub_old < len_old) (= symExpr_old@i_sub_old str@(i_str + i_sub_old)) ) DO i_sub_old := i_sub_old + 1 ; ENDWHILE ; %write link '[i_str,i_sub_old]= ' (string i_str) ', ' (string i_sub_old) ; IF (len_old = i_sub_old) THEN chr_new jump := chrStr_get -1 (i_str - 1) str ; flg_precede := NOT in chr_new chrs_symbols_HFLN ; chr_new jump := chrStr_get 1 (i_str + len_old) str ; flg_follow := NOT in chr_new chrs_symbols_HFLN ; IF flg_subStart THEN flg_front := o ; ELSE flg_front := flg_precede ; ENDIF ; IF flg_subEnd THEN flg_back := o ; ELSE flg_back := flg_follow ; ENDIF ; IF (AND (flg_front flg_back)) THEN textnew := link textnew symExpr_new ; i_str := i_str + len_old - 1 ; %write ' ' ; %write i_sub_old i_str flg_front flg_back symExpr_old symExpr_new str textnew ; ELSE textnew := link textnew str@i_str ; ENDIF ; ELSEIF (0 <= i_sub_old) THEN textnew := link textnew str@i_str ; ELSE textnew := fault '?symExpr_sub - i_sub_old is anomalous' ; ENDIF ; %write textnew ; i_str := i_str + 1 ; i_sub_old := 0 ; ENDWHILE ; % ; ELSE textnew := null ; ENDIF ; % ; IF (= null textnew) THEN str ELSE textnew ENDIF } # IF (AND flag_break (= `( str@(i_str - 1)) (= `v str@i_str)) THEN BREAK ; ENDIF ; # follow break aftr ELSE in "IF (OR (flg_front flg_back)) THEN " clause # i_sub_old i_str flg_front flg_back symExpr_old symExpr_new str # # example 8 - follow break after "IF (len_old = i_sub_old) THEN " , zero in on : # IF (AND (= 'Vonv(particle)' symExpr_new) flag_break) THEN BREAK ; ENDIF ; # old code chr_precede := chr_unicode_before_after_str_i -1 (i_str - 1) str ; chr_follow := chr_unicode_before_after_str_i 1 (i_str + i_sub_old) str ; #Tracking during break mode: # 2 7 reshape 'len_str' 'lsub_old' 'i_str' 'i_sub_old' 'symExpr_old' 'symExpr_new' 'str' len_str len_sub_old i_str i_sub_old symExpr_old symExpr_new str # charrep str@(i_str - 1) +-----+ to : +-----+ symExpr_sub IS OP symExpr_old symExpr_new str { LOCAL chrList_old chrList_new chrList_str flg_front flg_back flag_follow flag_precede flg_subStart flg_subEnd i_str i_old jump len_new len_old len_str textnew ; % ; IF (NOT OR (symExpr_old symExpr_new EACHLEFT = null)) THEN % ; chrList_old chrList_new chrList_str := EACH string symExpr_old symExpr_new str ; len_old len_new len_str := EACH (gage shape) chrList_old chrList_new chrList_str ; i_str i_old := 0 0 ; textnew := null ; % ; flg_subStart := NOT in chrList_old@0 chrs_symbols_HFLN ; flg_subEnd := NOT in chrList_old@(len_old - 1) chrs_symbols_HFLN ; WHILE (i_str < len_str) DO WHILE (AND ((i_old + i_str) < len_str) ( i_old < len_old) (= chrList_old@i_old chrList_str@(i_str + i_old)) ) DO i_old := i_old + 1 ; ENDWHILE ; %write link '[i_str,i_old]= ' (string i_str) ', ' (string i_old) ; IF (len_old = i_old) THEN flg_precede := NOT in chrList_str@i_str chrs_symbols_HFLN ; flg_follow := NOT in chrList_str@(i_str + len_old) chrs_symbols_HFLN ; IF flg_subStart THEN flg_front := o ; ELSE flg_front := flg_precede ; ENDIF ; IF flg_subEnd THEN flg_back := o ; ELSE flg_back := flg_follow ; ENDIF ; IF (AND (flg_front flg_back)) THEN textnew := link textnew symExpr_new ; i_str := i_str + len_old - 1 ; %write ' ' ; %write i_old i_str flg_front flg_back chrList_old symExpr_new chrList_str textnew ; ELSE textnew := link textnew chrList_str@i_str ; ENDIF ; ELSE textnew := link textnew chrList_str@i_str ; ENDIF ; %write textnew ; i_str := i_str + 1 ; i_old := 0 ; ENDWHILE ; % ; ELSE textnew := str ; ENDIF ; % ; textnew } +-----+ # 08********08 #] 28Jun2018 10: tests AFTER replacing chrStr_get_test with str_to_unicodeList fixing [sym_stdForm,symExtract_stringPosn] symbols_Strings_Extract_Translate_alltest alltest strings 180628 10h45m54s.txt str_to_unicodeList_test ALL OK string_sub_test ALL OK sym_stdForm_test ALL OK alltest symExtract 180628 10h45m54s.txt symParen_contents_test ALL OK syms_inParens_test ALL OK symExtract_stringPosn_test ALL OK symExtract_string_test ALL OK alltest symTranslate 180628 10h45m54s.txt symTrans_test failed [11], OK - rest xprs_ExtractTranslate_test ALL OK symExpr_sub_test failed [2,3a,4,10], OK [1,3,5-7] symTranslate_string_test failed [1,5,8,9,9a,10], OK [2,2a,3,4,5a,6,6a,7,11] +-----+ # symTrans_test example 11 : FAILED - result does NOT match standard t_input, t_standard, t_result = ∮[*dφ´ : dp[dt : Bi(r - v*t,t)]•n´ - has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. ∮[*dφ´ : dp[dt : Bi(r - v*t,t)]•n´ symTrans_lineType= ^ NO translation: symTrans doesn't apply to composite expressions >> OOPS - symTrans_test, Thu Jun 28 11:34:15 2018 # symTrans_test example 11 : OK - result matches standard t_input, t_standard, t_result = ∮[*dφ´ : dp[dt : Bi(r - v*t,t)]•n´ ∮[*dφ´ : dp[dt : Bi(r - v*t,t)]•n´ ∮[*dφ´ : dp[dt : Bi(r - v*t,t)]•n´ symTrans_lineType= ^ NO translation: symTrans doesn't apply to composite expressions >> Now it's OK +-----+ symExpr_sub_test corrected t_standard for: symExpr_sub_test example [3a] serious problems with : symExpr_sub_test examples [2,4,10] # symExpr_sub_test example 4 : FAILED - result does NOT match standard t_input, t_standard, t_result = +-+----------+--------------------------------------------------------------------------+ |r|Rocv(POIo)|$ = r´/r/sinO *[ ∂/∂O(sinO*Ei(rp,t)·Pp) - ∂/∂P(Ei(rp,t)·O)] | +-+----------+--------------------------------------------------------------------------+ $ = r´/Rocv(POIo)/sinO *[ ∂/∂O(sinO*Ei(rp,t)·Pp) - ∂/∂P(Ei(rp,t)·O)] $ = Rocv(POIo)´/Rocv(POIo)/sinO *[ ∂/∂O(sinO*Ei(Rocv(POIo)p,t)·Pp) - ∂/∂P(Ei(Rocv(POIo)p,t)·O)] >> This looks like 'r´' in 'r´' is not recognized as being in chrs_symbols_HFLN qnial> charrep '´' -62 -76 qnial> charrep '´' -62 -76 >> NOPE - that is not the problem, remember that symExpr_sub doesn't work with symbols! >> It's dangerous to sub for [simple characters,charaSequences]! >> I fixed the standard, as the result is as expected >> OK # symExpr_sub_test example 2 : FAILED - result does NOT match standard t_input, t_standard, t_result = +-----------+------------------------------+---------------------------------------------------------------------+ |r(rb)|Rocv(POIo)(Rocv(POIo)β)| e^2*(r·b)*r(rb)/|r2 - r1|^2*6*Bpe^2*Bep^2*(-3/2/π) | +-----------+------------------------------+---------------------------------------------------------------------+ e^2*(r·b)*Rocv(POIo)(Rocv(POIo)β)/|r2 - r1|^2*6*Bpe^2*Bep^2*(-3/2/π) e^2*(r·b)*r(rb) /|r2 - r1|^2*6*Bpe^2*Bep^2*(-3/2/π) >> The problem here is not obvious... # symExpr_sub_test example 10 : FAILED - result does NOT match standard t_input, t_standard, t_result = +------+---------------------------+----------+ |vrp|Vonv(particle)Rpcv(POIp)|*(vrp)/| +------+---------------------------+----------+ *(Vonv(particle)Rpcv(POIp))/ *(vrp)/ >> Why fails? >> example 4 qnial> charrep '' -18 -124 -87 >> chrs_non_HFLN qnial> charrep '' -18 -124 -87 >> So that character should be recognized >> Note that example 1 worked?!?? : t_name := '# symExpr_sub_test example 1' ; t_input := 'vrp' 'Vons(particle)Rocv(POIo)' 'Bi(r,v,t) = q/c*(vrp)/rs^3 = (v/c)E0(r,t)' ; >> So why is there a problem with example 10????? Maybe the problem with examples [2,10] is the symExpr_sub line : flg_subEnd := NOT in chrList_old@(len_old - 1) chrs_symbols_HFLN ; >> nyet for now? qnial> charrep 'β' -50 -78 qnial> charrep 'β' -50 -78 # 08********08 #] 03Jul2018 11:02 symExpr_sub IF flag_break THEN BREAK ; ENDIF ; WRONG! : # WARNING!! IF symExpr_old has (NOT chrs_symbols_HFLN) at [inital,end], then the SAME must apply to symExpr_new!!! Change : +-----+ IF (len_old = i_old) THEN flg_precede := NOT in chrList_old@i_str chrs_symbols_HFLN ; flg_follow := NOT in chrList_old@(i_str + len_old) chrs_symbols_HFLN ; IF flg_subStart THEN flg_front := o ; ELSE flg_front := flg_precede ; ENDIF ; IF flg_subEnd THEN flg_back := o ; ELSE flg_back := flg_follow ; ENDIF ; IF (AND (flg_front flg_back)) THEN textnew := link textnew symExpr_new ; i_str := i_str + len_old - 1 ; ELSE textnew := link textnew chrList_str@i_str ; ENDIF ; ELSE textnew := link textnew chrList_str@i_str ; ENDIF ; +-----+ To : +-----+ IF (len_old = i_old) THEN IF (i_str = 0) THEN flg_precede := l ; ELSE flg_precede := NOT in chrList_str@(i_str - 1) chrs_symbols_HFLN ; ENDIF ; IF (len_str = (i_str + len_old)) THEN flg_follow := l ; ELSE flg_follow := NOT in chrList_str@(i_str + len_old) chrs_symbols_HFLN ; ENDIF ; IF (AND (OR flg_precede flg_subStart) (OR flg_subEnd flg_follow)) THEN textnew := link textnew symExpr_new ; i_str := i_str + len_old - 1 ; ELSE textnew := link textnew chrList_str@i_str ; ENDIF ; ELSE textnew := link textnew chrList_str@i_str ; ENDIF ; +-----+ qnial> symExpr_sub_test +---------------+ symExpr_sub_test, Tue Jul 3 15:50:47 2018 symExpr_sub substitutes symExpr_new for sub_old in str ... +-----+ >> ALL examples are now OK! # 08********08 #] 03Jul2018 Now try symTranslate_string_test >> same failures : symTranslate_string_test failed [1,5,8,9,9a,10], OK [2,2a,3,4,5a,6,6a,7,11] # symTranslate_string_test example 1 : FAILED - result does NOT match standard t_input, t_standard, t_result = % - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) % - ∂[∂(t) : EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) % - ∂[∂(t) : EIpds(POIo,t)]/Vons(particle)/cos(???Aθpc(POIp)(POIo,t)) symTrans_lineType= % translation should work for most "composite expressions" as they are in trans[,Expr]_old_HFLN_bads 04Jun2018 However, EIpds(POIo,t) was NOT translated! Instead, improper intermediate symbol substitutions were first made!!!, eg cos(???Aθpc(POIp)(POIo,t)) >> should work?? - something wrong with sequencing? # symTranslate_string_test example 5 : FAILED - result does NOT match standard t_input, t_standard, t_result = ^ + 1/Rocs(POIo)/c*dp[dt : |Ei(ro - vo*t,t)|] ] %^ + 1/Rocs(POIo)/c*∂[∂(t) : |Ei(ro - vo*t,t)|] ] %^ + 1/Rocs(POIo)/c*∂[∂(t) : |EIodv(ro - vo*t,t)|] ] symTrans_lineType= ^ >> OK, as `^ applies trans_Lucas_to_HFLN, which includes Ei # symTranslate_string_test example 8 : FAILED - result does NOT match standard t_input, t_standard, t_result = ^HLFN = q/c*(vr)/r´s^2 + vov/cEi(rp,tp) %^HLFN = Q(particle)/c*(Vonv_X_Rocv(POIo))/Rpcs(POIp)^2 + Vonv(particle)/cEIodv(POIp(t),t) %^HLFN = Q(particle)/c*(Vonv_X_Rocv(POIo))/Rpcs(POIp)^2 + Vonv(particle)/cEIodv(rp,tp) symTrans_lineType= ^ translation should work for all [syms,exprs], including Ei(rp,tp), which IS IN trans_Lucas_to_HFLN. >> ??????????? +-----+ BOTH of the following look like they match the standard - what gives? -> parenthesis!! # symTranslate_string_test example 9 : FAILED - result does NOT match standard t_input, t_standard, t_result = $HLFN : ∮(dl, over C : B) = ∬s(·dS : μ0*J + μ0*ε0*dp[dt : E] ) $HLFN : ∮[∂(l), over C : B) = ∬(·∂(Area) : μ0*J + μ0*ε0*∂[∂(t) : ET] ) $HLFN : ∮[∂(l), over C : B) = ∬[·∂(Area) : μ0*J + μ0*ε0*∂[∂(t) : ET] ) symTrans_lineType= $ translation should work for some [syms,exprs] as they are in trans[,Expr]_old_Lucas_bads 04Jun2018 Except ∬s prevents the ∬( -> ∬[ translation (will be done on next run with `$) However, the ∮( -> ∮[ translation SHOULD HAVE been done!? # symTranslate_string_test example 9a : FAILED - result does NOT match standard t_input, t_standard, t_result = $HLFN : ∮(dl,.over.C : B) = ∬s(·dS : μ0*J + μ0*ε0*dp[dt : E] ) $HLFN : ∮[∂(l),.over.C : B) = ∬(·∂(Area) : μ0*J + μ0*ε0*∂[∂(t) : ET] ) $HLFN : ∮[∂(l),.over.C : B) = ∬[·∂(Area) : μ0*J + μ0*ε0*∂[∂(t) : ET] ) symTrans_lineType= $ 04Jun2018 same as example 9, +-----+ # symTranslate_string_test example 10 : FAILED - result does NOT match standard t_input, t_standard, t_result = ^[·dl : E(r´,t´)] = -1/c*dp[dt : [dA : B(r,t) •n]] .and.[·dl : E(r´,t´)] = - [dA : dp[dt : B(r,t)]·n] %^[·∂(l) : ETodv(POIp(t),t)] = -1/c*∂[∂(t) : [∂(Area) : BTodv(POIo,t) •n]] .and.[·∂(l) : ETodv(POIp(t),t)] = - [∂(Area) : ∂[∂(t) : BTodv(POIo,t)]·n] %^[·∂(l) : E(Rpcv(POIp),t´)] = -1/c*∂[∂(t) : [∂(Area) : B(Rocv(POIo),t) •n]] .and.[·∂(l) : E(Rpcv(POIp),t´)] = - [∂(Area) : ∂[∂(t) : B(Rocv(POIo),t)]·n] symTrans_lineType= ^ translation should work for most [syms,exprs], those that are in trans[,Expr]_Lucas_to_HFLN 04Jun2018 The translations [E(r´,t´) -> ETodv(POIp(t),t), B(r,t) -> BTodv(POIo,t)] SHOULD HAVE been done!? Instead, improper intermediate symbol substitutions were first made!!! >> Messed up bad... seems to involve out-of-sequence translations? Re-run symTranslate_string_test >> now reduces to : symTranslate_string_test failed [1,8,10], OK [2,2a,3,4,5,5a,6,6a,7,9,9a,11] # 08********08 #] 03Jul2018 symTranslate_string_test - remaining FAILED +-----+ # symTranslate_string_test example 1 : FAILED - result does NOT match standard t_input, t_standard, t_result = % - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) % - ∂[∂(t) : EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) % - ∂[∂(t) : EIpds(POIo,t)]/Vons(particle)/cos(???Aθpc(POIp)(POIo,t)) symTrans_lineType= % translation should work for most "composite expressions" as they are in trans[,Expr]_old_HFLN_bads 04Jun2018 However, EIpds(POIo,t) was NOT translated! Instead, improper intermediate symbol substitutions were first made!!!, eg cos(???Aθpc(POIp)(POIo,t)) >> should work?? - something wrong with sequencing? >> Almost seems like wrong translation table being used? : trans_HFLN_bad is the right table # symTranslate_string_test example 8 : FAILED - result does NOT match standard t_input, t_standard, t_result = ^HLFN = q/c*(vr)/r´s^2 + vov/cEi(rp,tp) %^HLFN = Q(particle)/c*(Vonv_X_Rocv(POIo))/Rpcs(POIp)^2 + Vonv(particle)/cEIodv(POIp(t),t) %^HLFN = Q(particle)/c*(Vonv_X_Rocv(POIo))/Rpcs(POIp)^2 + Vonv(particle)/cEIodv(rp,tp) symTrans_lineType= ^ translation should work for all [syms,exprs], including Ei(rp,tp), which IS IN trans_Lucas_to_HFLN. >> ??????????? # symTranslate_string_test example 10 : FAILED - result does NOT match standard t_input, t_standard, t_result = ^[·dl : E(r´,t´)] = -1/c*dp[dt : [dA : B(r,t) •n]] .and.[·dl : E(r´,t´)] = - [dA : dp[dt : B(r,t)]·n] %^[·∂(l) : ETodv(POIp(t),t)] = -1/c*∂[∂(t) : [∂(Area) : BTodv(POIo,t) •n]] .and.[·∂(l) : ETodv(POIp(t),t)] = - [∂(Area) : ∂[∂(t) : BTodv(POIo,t)]·n] %^[·∂(l) : E(Rpcv(POIp),t´)] = -1/c*∂[∂(t) : [∂(Area) : B(Rocv(POIo),t) •n]] .and.[·∂(l) : E(Rpcv(POIp),t´)] = - [∂(Area) : ∂[∂(t) : B(Rocv(POIo),t)]·n] symTrans_lineType= ^ translation should work for most [syms,exprs], those that are in trans[,Expr]_Lucas_to_HFLN 04Jun2018 The translations [E(r´,t´) -> ETodv(POIp(t),t), B(r,t) -> BTodv(POIo,t)] SHOULD HAVE been done!? Instead, improper intermediate symbol substitutions were first made!!! >> Messed up bad... seems to involve out-of-sequence translations? +-----+ 06Jul2018 09:19 example#1 break qnial> symTranslate_string_test +-----+ symTranslate_string_test, Fri Jul 6 09:08:01 2018 symTranslate_string translates "simple symbols" and "composite expressions". # symTranslate_string_test example 1 : FAILED - result does NOT match standard t_input, t_standard, t_result = % - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) % - ∂[∂(t) : EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) % - ∂[∂(t): EIpds(POIo(t),t)]/Vons(particle)/cos(Aθpc(POIo(t),t)) symTrans_lineType= % translation should work for most "composite expressions" as they are in trans[,Expr]_old_HFLN_bads 04Jun2018 However, EIpds(POIo,t) was NOT translated! Instead, improper intermediate symbol substitutions were first made!!!, eg cos(???Aθpc(POIp)(POIo,t)) # symTranslate_string_test example 8 : OK - result matches standard t_input, t_standard, t_result = ^HLFN = q/c*(vr)/r´s^2 + vov/cEi(rp,tp) %^HLFN = Q(particle)/c*(Vonv_X_Rocv(POIo))/Rpcs(POIp)^2 + Vonv(particle)/cEIodv(POIp(t),t) %^HLFN = Q(particle)/c*(Vonv_X_Rocv(POIo))/Rpcs(POIp)^2 + Vonv(particle)/cEIodv(POIp(t),t) symTrans_lineType= ^ translation should work for all [syms,exprs], including Ei(rp,tp), which IS IN trans_Lucas_to_HFLN. +-----+ >> Now both [1,8] work!!!??? Why all of a sudden? symTranslate_string_test failed [5,5a,9,9a,10], OK [1,2,2a,3,4,6,6a,7,8,11] 06Jul2018 09:44 >> failed [5,5a,9,9a,10] - blanks spacing issue : >> 1. I don't want compression as [spaces,tabs] are important to alignment >> 2. BUT: substitution of symExpressions requires (for now) blanks compression, so substituted symExpr will be compressed OK - after iterative fixing of t_standards : symTranslate_string_test ALL OK Junk leftover code : +-----+ # QNial version # Note : # symbols - are symbol_character sequences, or compound phrases in a "headed parenthetical wrapping" # some such symbols are in trans_table, and thereby have a translation # expressions - are collections of symbols that have translations in transExpr_table # 18May2018 - no longer used : # WARNING!!! MUST use set_trans_table to choose right translation BEFORE running this # one of : ['Lucas_bads','Lucas_to_HLFN','HLFN_bads'] +-----+ 06Jul2018 removed from "symbols translate.ndf", symTranslate_file_Lucas : # WARNING!!! MUST use set_trans_table to choose right translation BEFORE running this # one of : ['Lucas_bads','Lucas_to_HLFN','HLFN_bads'] # 17May2018 symTranslate_file now does this automatically # 08********08 #] 07Jul2018 symbols_compare_Lucas - producing symDiff files of "leftover symbols" >> This does NOT seem to be working - it returns ALL symbols in "<" file? >> must test!! $ cd "/media/bill/PROJECTS/Lucas - Universal Force/" $ diff "symList bads HFLN.txt" "symList bads HFLN test half.txt" | grep "< " | sed "s/< //" >"symList bads HFLN test half result.txt" >> It worked perfectly!! # 08********08 #] 24Jul2018 Get rid of these - better to use general operators [readfile_list,readfile_table,writefile_table] see "fileops.ndf" # tranList_read_Lucas IS - [read,append,sort-unique,writefile] a li # www.BillHowell.ca 06Jul2018 initial # uses : readfile_table IS OP pname n_cols -> from fileops.ndf # % EACH [append,sort,cull] (transExpr_old_Lucas_to_HFLN transExpr_new_Lucas_to_HFLN transExpr_msg_Lucas_to_HFLN) ; tranList_readfile_Lucas IS OP p_tranList { LOCAL bads bads_msgList ; NONLOCAL d_Lucas d_QNial_mine d_QNial_temp ; % ; IF flag_break THEN BREAK ; ENDIF ; bads := readfile_list p_tranList ; trans_old trans_new trans_msg := link (execute (link 'trans_msg_' bads_acronym)) bads_msgList ; % ; } # tranList_writefile_Lucas 'HFLN' # tranList_writefile_Lucas IS - [read,append,sort-unique,writefile] a li # www.BillHowell.ca 06Jul2018 initial # uses : fileread_list IS OP pname -> from fileops.ndf # % EACH [append,sort,cull] (transExpr_old_Lucas_to_HFLN transExpr_new_Lucas_to_HFLN transExpr_msg_Lucas_to_HFLN) ; tranList_writefile_Lucas IS OP bads_acronym { LOCAL bads bads_msgList ; NONLOCAL d_Lucas d_QNial_mine d_QNial_temp ; % ; IF flag_break THEN BREAK ; ENDIF ; bads := readfile_list (link d_Lucas 'symList bads ' bads_acronym '.txt') ; bads_msgList := (gage shape bads) reshape (solitary link 'tranList_updates_Lucas: ' timestamp_YYMMDD_HMS) ; trans_old := link (execute (link 'trans_old_' bads_acronym)) bads ; trans_new := link (execute (link 'trans_new_' bads_acronym)) bads ; trans_msg := link (execute (link 'trans_msg_' bads_acronym)) bads_msgList ; % ; %sortup&cull based on trans_old, sortup_cull_listCollection is in "setup.ndf" ; trans_old trans_new trans_msg := sortup_cull_listCollection (trans_old trans_new trans_msg) ; n_rows := gage shape trans_old ; fot := open (link d_QNial_temp 'tranList new ' bads_acronym '.txt') "w ; FOR i WITH tell n_rows DO writefile fot (link ' ' `' trans_old@i `' ' ' `' trans_new@i `' ' ' `' trans_msg@i `' ) ; ENDFOR ; close fot ; } # tranList_writefile_Lucas 'HFLN' # 08********08 #] 30Aug2018 13:31 Re-run symTranslate_alltest of "symbols translate- tests.ndf" Re-run symTranslate_alltest of "symbols translate- tests.ndf" : +-----+ Summary of test results : /media/bill/PROJECTS/Qnial/code develop_test/alltest symTranslate 180830 13h30m28s.txt, date= 180830 13h30m # symTrans_test example 1 : OK - result matches standard # symTrans_test example 2 : OK - result matches standard # symTrans_test example 6 : OK - result matches standard # symTrans_test example 7 : OK - result matches standard # symTrans_test example 9 : OK - result matches standard # symTrans_test example 10 : OK - result matches standard # symTrans_test example 11 : OK - result matches standard # symTrans_test example 12 : OK - result matches standard # symTrans_test example 13 : OK - result matches standard # symTrans_test example 15 : OK - result matches standard # symTrans_test example 16 : OK - result matches standard # xprs_ExtractTranslate_test example 3 : OK - result matches standard # xprs_ExtractTranslate_test example 4 : OK - result matches standard # xprs_ExtractTranslate_test example 6 : OK - result matches standard # symExpr_sub_test example 1 : OK - result matches standard # symExpr_sub_test example 2 : OK - result matches standard # symExpr_sub_test example 3 : OK - result matches standard # symExpr_sub_test example 3a : OK - result matches standard # symExpr_sub_test example 4 : OK - result matches standard # symExpr_sub_test example 5 : OK - result matches standard # symExpr_sub_test example 6 : OK - result matches standard # symExpr_sub_test example 7 : OK - result matches standard # symExpr_sub_test example 10 : OK - result matches standard # symTranslate_string_test example 4 : OK - result matches standard # symTrans_test example 3 : FAILED - result does NOT match standard # symTrans_test example 4 : FAILED - result does NOT match standard # symTrans_test example 5 : FAILED - result does NOT match standard # symTrans_test example 8 : FAILED - result does NOT match standard # symTrans_test example 14 : FAILED - result does NOT match standard # xprs_ExtractTranslate_test example 1 : FAILED - result does NOT match standard # xprs_ExtractTranslate_test example 2 : FAILED - result does NOT match standard # xprs_ExtractTranslate_test example 2a : FAILED - result does NOT match standard # xprs_ExtractTranslate_test example 3a : FAILED - result does NOT match standard # xprs_ExtractTranslate_test example 5 : FAILED - result does NOT match standard # xprs_ExtractTranslate_test example 5a : FAILED - result does NOT match standard # xprs_ExtractTranslate_test example 6a : FAILED - result does NOT match standard # xprs_ExtractTranslate_test example 7 : FAILED - result does NOT match standard # symTranslate_string_test example 1 : FAILED - result does NOT match standard # symTranslate_string_test example 2 : FAILED - result does NOT match standard # symTranslate_string_test example 2a : FAILED - result does NOT match standard # symTranslate_string_test example 3 : FAILED - result does NOT match standard # symTranslate_string_test example 5 : FAILED - result does NOT match standard # symTranslate_string_test example 5a : FAILED - result does NOT match standard # symTranslate_string_test example 6 : FAILED - result does NOT match standard # symTranslate_string_test example 6a : FAILED - result does NOT match standard # symTranslate_string_test example 7 : FAILED - result does NOT match standard # symTranslate_string_test example 8 : FAILED - result does NOT match standard # symTranslate_string_test example 9 : FAILED - result does NOT match standard # symTranslate_string_test example 9a : FAILED - result does NOT match standard # symTranslate_string_test example 10 : FAILED - result does NOT match standard # symTranslate_string_test example 11 : FAILED - result does NOT match standard +-----+ As per "" +-----+ insert symTrans_lineType '#$%^&' symbols at the start of lines as needed : `# comment only - no translation or extraction of symbols `$ applies tranList_Lucas_bads to a string `% applies tranList_HFLN_bads to a string `^ applies tranList_Lucas_to_HFLN to a string, translated string has "%^" at start of line to help subsequent editing `& applies tranList_HFLN_to_Lucas to a string, translated string has "$&" at start of line to help subsequent editing symTrans_lineTypes are PERSISTENT for multiple lines - until a symTrans_lineType appears as the first character on a subsequent line. +-----+ But ONLY `$ `# and `^ are used in "symTrans IS OP symbol" !!!! I've pretty well assumed that : tranList_Lucas_to_HFLN has been rolled into tranList_HFLN tranList_HFLN_to_Lucas has been rolled into tranList_Lucas Therefore, `% should appear, not `^ in test sets. Furthermore - check on setup of tran[List, Expr] [Lucas, HFLN].txt this is in "symbols system loaddefs.ndf" : +-----+ trans_old_HFLN trans_new_HFLN trans_msg_HFLN := readfile_table (link d_Lucas 'tranList HFLN.txt') ; transExpr_old_HFLN transExpr_new_HFLN transExpr_msg_HFLN := readfile_table (link d_Lucas 'tranExpr HFLN.txt') ; trans_old_Lucas trans_new_Lucas trans_msg_Lucas := readfile_table (link d_Lucas 'tranList Lucas.txt') ; transExpr_old_Lucas transExpr_new_Lucas transExp_msg_Lucas := readfile_table (link d_Lucas 'tranExpr Lucas.txt') ; +-----+ I must therefore modify : +-----+ symTrans IS OP symbol { LOCAL symNew ; NONLOCAL symTrans_lineType trans_old_Lucas_bads trans_new_Lucas_bads trans_old_HFLN trans_new_HFLN ; % ; % find_Howell-choose returns a SINGLE (not a solitary!) ; IF (= `$ symTrans_lineType) THEN symNew := (find_Howell symbol trans_old_Lucas_bads) choose trans_new_Lucas_bads ; %write_debug trans_new@(find_Howell symbol trans_old_Lucas_bads) ; ELSEIF (= `% symTrans_lineType) THEN symNew := (find_Howell symbol trans_old_HFLN ) choose trans_new_HFLN ; %write_debug trans_new@(find_Howell symbol trans_old_HFLN ) ; ELSE symNew := fault '?symTrans ERROR: unknown symTrans_lineType' ; ENDIF ; IF (isfault symNew) THEN symNew := symbol ; ELSEIF (= null (gage shape symNew)) THEN symNew := first symNew ; ENDIF ; symNew } +-----+ to (removing "_bads") : +-----+ symTrans IS OP symbol { LOCAL symNew ; NONLOCAL symTrans_lineType trans_old_Lucas_bads trans_new_Lucas_bads trans_old_HFLN trans_new_HFLN ; % ; % find_Howell-choose returns a SINGLE (not a solitary!) ; IF (= `$ symTrans_lineType) THEN symNew := (find_Howell symbol trans_old_Lucas) choose trans_new_Lucas ; %write_debug trans_new@(find_Howell symbol trans_old_Lucas) ; ELSEIF (= `% symTrans_lineType) THEN symNew := (find_Howell symbol trans_old_HFLN ) choose trans_new_HFLN ; %write_debug trans_new@(find_Howell symbol trans_old_HFLN ) ; ELSE symNew := fault '?symTrans ERROR: unknown symTrans_lineType' ; ENDIF ; IF (isfault symNew) THEN symNew := symbol ; ELSEIF (= null (gage shape symNew)) THEN symNew := first symNew ; ENDIF ; symNew } +-----+ Double-check for other usage : $ find "/media/bill/PROJECTS/Qnial/MY_NDFS/" -maxdepth 1 -name "*" | tr \\n \\0 | xargs -0 -IFILE grep --with-filename --line-number "trans_new_Lucas_bads" "FILE" | grep --invert-match "Is a directory" $ find "/media/bill/PROJECTS/Qnial/MY_NDFS/" -maxdepth 1 -name "*" | tr \\n \\0 | xargs -0 -IFILE grep --with-filename --line-number "trans_old_Lucas_bads" "FILE" | grep --invert-match "Is a directory" OK - no other current uses Now change examples in "symbols translate- tests.ndf" : `^ to `%, and `& to `$ >> no change as it is correct now modify tests in "symbols translate- tests.ndf" >> OK, only 6 or 7 `^ to `% quick symTrans_test : >> Now all are OK! quick xprs_ExtractTranslate_test : >> yuchh! no results at all # 08********08 #] 30Aug2018 15:13 xprs_ExtractTranslate IS OP str >> Oops, still have [transExpr_old_Lucas_bads, transExpr_old_HFLN_bads] >> get rid of "_bads" see "/media/bill/PROJECTS/Qnial/code develop_test/z_special symTranlate, conversion to str_stdForm and typechanges within strings.txt" # 08********08 #] 30Aug2018 15:13 xprs_ExtractTranslate IS OP str >> Oops, still have [transExpr_old_Lucas_bads, transExpr_old_HFLN_bads] >> get rid of "_bads" reload via lq_symTests (which also runs lq_symbols) retry xprs_ExtractTranslate_test : >> had to re-adjust t_standards given amalgamation of # 30Aug2018 t_standard adjusted for : # tranList_Lucas_to_HFLN has been rolled into tranList_HFLN # tranList_HFLN_to_Lucas has been rolled into tranList_Lucas >> ERROR! Why? +-----+ t_name := '# xprs_ExtractTranslate_test example 5a' ; symTrans_lineType := `% ; t_input := ' + 1/Rocs(POIo)/c*dp[dt : | Ei(ro - vo*t,t) |] ] ' ; t_standard := ('dp[dt' '|Ei(ro - vo*t,t)|' 'Ei(ro - vo*t,t)' 'ro - vo*t') ('∂[∂(t)' 'EIods(POIp(t),t)' 'EIodv(POIp(t),t)' 'Rpcv(POIp)') ; t_result := xprs_ExtractTranslate t_input ; test_comment t_name t_input t_standard t_result ; write_testStr link 'symTrans_lineType= ' symTrans_lineType ; write_testStr 'translation should work for all expressions' ; write_testStr 'oops- spaces of "| Ei(ro - vo*t,t) |" not handled properly!?' ; +-----+ >> come back to this later ... 30Aug2018 16:44 Try symExpr_sub_test : >> ALL are OK!!! 30Aug2018 16:45 Try symTranslate_string_test : >> most failed!!! >> tests still have `^ Re-Try symTranslate_string_test : >> errors in t_standards!! OK, many fixes, but now works One problem left with an example? # 08********08 # 31Aug2018 08:52 Conundrum of the spaces! +-----+ # xprs_ExtractTranslate_test example 5a : FAILED - result does NOT match standard t_input, t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : | Ei(ro - vo*t,t) |] ] +---------------------------------------------------+---------------------------------------------------------+ |+-----+-----------------+---------------+---------+|+----------+----------------+----------------+----------+| ||dp[dt||Ei(ro - vo*t,t)||Ei(ro - vo*t,t)|ro - vo*t|||∂[∂(t)|EIods(POIp(t),t)|EIodv(POIp(t),t)|Rpcv(POIp)|| |+-----+-----------------+---------------+---------+|+----------+----------------+----------------+----------+| +---------------------------------------------------+---------------------------------------------------------+ +---------------------------------+----------------------------------------+ |+-----+---------------+---------+|+----------+----------------+----------+| ||dp[dt|Ei(ro - vo*t,t)|ro - vo*t|||∂[∂(t)|EIodv(POIp(t),t)|Rpcv(POIp)|| |+-----+---------------+---------+|+----------+----------------+----------+| +---------------------------------+----------------------------------------+ symTrans_lineType= % translation should work for all expressions oops- spaces of "| Ei(ro - vo*t,t) |" not handled properly!? +-----+ >> spaces should NOT appear around "|"!! sym_stdForm IS OP str { LOCAL blanks chrList chrListLast i in_blanks len spc symNew ; NONLOCAL chrs_blank ; % ; chrListLast := null ; chrList := str_to_unicodeList str ; len := gage shape chrList ; i := 0 ; % ; symNew := null ; WHILE (i < len) DO IF (in chrList@i chrs_blank) THEN null ; ELSEIF (in chrList@i chrs_symbols_HFLN) THEN IF (OR (in chrListLast chrs_blank) (in chrListLast chrs_paren_stop)) THEN symNew := link symNew ' ' chrList@i ; ELSE symNew := link symNew chrList@i ; ENDIF ; ELSEIF (in chrList@i chrs_math_spaced) THEN IF (in chrListLast chrs_blank) THEN spc := null ; ELSE spc := ' ' ; ENDIF ; symNew := link symNew spc chrList@i ' ' ; ELSEIF (= chrList@i ':') THEN symNew := link symNew chrList@i ' ' ; ELSE symNew := link symNew chrList@i ; ENDIF ; chrListLast := last symNew ; i := i + 1 ; ENDWHILE ; % ; symNew } The lines : ELSEIF (in chrList@i chrs_symbols_HFLN) THEN IF (OR (in chrListLast chrs_blank) (in chrListLast chrs_paren_stop)) prevent two simple symbols from being merged, example 'a b' -> 'ab' The lines : ELSEIF (in chrList@i chrs_math_spaced) THEN IF (in chrListLast chrs_blank) THEN retain blanks for chrs_math_spaced. Is "|" in chrs_math_spaced? '+-=' -> NO! so why does it retain spaces for xprs_ExtractTranslate_test example 5a ? >> OK - xprs_ExtractTranslate_test does NOT do sym_stdForm, so spaces AREN't removed, and expr with spaces aren't recognized. Rerun symbols_Strings_Extract_Translate_alltest : # xprs_ExtractTranslate_test example 5a : FAILED - result does NOT match standard >> NUTS! forgot to change t_standard Rerun symbols_Strings_Extract_Translate_alltest after fixing t_standard : >> It's ALL good! YEAH! # 08********08 #] 19Nov2018 Fix strOfType_extractFindTrans_symExpr Coming back from 2 months on other stuff qnial> strOfType_extractFindTrans_symExpr_test -->[stepv] ?.. Trn_len Trn_old Trn_new := trninfo Trntype 'Expr' -->[stepv] trn_len trn_old trn_new +----------------+---------+---------+ |transExpr_len_/%|?no_value|?no_value| +----------------+---------+---------+ >> Problem is trnInfo!! trnInfo IS OP trnName tblType should be : trnInfo IS OP tblType trnName Change : +-----+ trnInfo IS OP trnName tblType { LOCAL trn_len trn_new trn_old ; trn_len := link 'trans' tblType '_len_' trnName ; trn_old := link 'trans' tblType '_old_' trnName ; trn_new := link 'trans' tblType '_new_' trnName ; trn_len trn_old trn_new } strOfType_extractFindTrans_symExpr IS OP strOfType { LOCAL i symListInn symListNew trn_len trn_old trn_new ; NONLOCAL trnType ; % ; trn_len trn_old trn_new := trnInfo trnType 'Expr' ; symListInn symListNew := null null ; FOR i WITH (tell (execute trn_len)) DO IF (in_string (execute (link trn_old '@i')) strOfType) THEN symListInn := link symListInn (solitary (execute (link trn_old '@i'))) ; symListNew := link symListNew (solitary (execute (link trn_new '@i'))) ; ENDIF ; ENDFOR ; symListInn symListNew } +-----+ To : +-----+ trnInfo IS OP tblType { LOCAL trnName trn_len trn_old trn_new ; NONLOCAL trnType ; IF (= '/$' trnType) THEN trnName := 'Luca' ; ELSEIF (= '/%' trnType) THEN trnName := 'HFLN' ; ELSE trnName := 'ERROR' ; ENDIF ; trn_len := execute link 'trans' tblType '_len_' trnName ; trn_old := link 'trans' tblType '_old_' trnName ; trn_new := link 'trans' tblType '_new_' trnName ; trn_len trn_old trn_new } strOfType_extractFindTrans_symExpr IS OP strOfType { LOCAL i symListInn symListNew trn_len trn_old trn_new ; % ; trn_len trn_old trn_new := trnInfo 'Expr' ; symListInn symListNew := null null ; FOR i WITH (tell trn_len) DO IF (in_string (execute (link trn_old '@i')) strOfType) THEN symListInn := link symListInn (solitary (execute (link trn_old '@i'))) ; symListNew := link symListNew (solitary (execute (link trn_new '@i'))) ; ENDIF ; ENDFOR ; symListInn symListNew } +-----+ problem - how are these re-assigned from initial '/*' for both? qnial> trnType trnTypeOld +--+---------+ |/*|?no_value| +--+---------+ $ find "/media/bill/PROJECTS/Qnial/MY_NDFS/" -maxdepth 1 -type f -name "*.ndf" | tr \\n \\0 | xargs -0 -IFILE grep --with-filename --line-number "trnType" "FILE" symParn_translate IS OP symParn_old { LOCAL i symParn_new trn_len trn_old trn_new ; % ; trn_len trn_old trn_new := trnInfo 'Parn' ; % find_Howell-choose returns a SINGLE (not a solitary!) ; i := execute (link 'find_Howell symParn_old ' trn_old) ; symParn_new := execute (link trn_new '@i') ; IF (isfault symParn_new) THEN symParn_new := symParn_old ; ELSEIF (= null (gage shape symParn_new)) THEN symParn_new := first symParn_new ; ENDIF ; symParn_new } Test translate : qnial> symTranslate_alltest Summary of test results : /media/bill/PROJECTS/Qnial/code develop_test/181119 15h15m59salltest symTranslate.txt, date= 181119 15h15m # strOfType_extractFindTrans_symExpr_test example 1 : OK - result matches standard # strOfType_extractFindTrans_symExpr_test example 2 : OK - result matches standard # strOfType_extractFindTrans_symExpr_test example 2a : OK - result matches standard # strOfType_extractFindTrans_symExpr_test example 3 : OK - result matches standard # strOfType_extractFindTrans_symExpr_test example 3a : OK - result matches standard # strOfType_extractFindTrans_symExpr_test example 4 : OK - result matches standard # strOfType_extractFindTrans_symExpr_test example 5 : OK - result matches standard # strOfType_extractFindTrans_symExpr_test example 5a : OK - result matches standard # strOfType_extractFindTrans_symExpr_test example 6 : OK - result matches standard # strOfType_extractFindTrans_symExpr_test example 6a : OK - result matches standard # strOfType_extractFindTrans_symExpr_test example 7 : OK - result matches standard # symParn_translate_test example 1 : OK - result matches standard # symParn_translate_test example 2 : OK - result matches standard # symParn_translate_test example 3 : OK - result matches standard # symParn_translate_test example 4 : OK - result matches standard # symParn_translate_test example 5 : OK - result matches standard # symParn_translate_test example 6 : OK - result matches standard # symParn_translate_test example 7 : OK - result matches standard # symParn_translate_test example 8 : OK - result matches standard # symParn_translate_test example 9 : OK - result matches standard # symParn_translate_test example 10 : OK - result matches standard # symParn_translate_test example 11 : OK - result matches standard # symParn_translate_test example 12 : OK - result matches standard # symParn_translate_test example 13 : OK - result matches standard # symParn_translate_test example 14 : OK - result matches standard # symParn_translate_test example 15 : OK - result matches standard # symParn_translate_test example 16 : OK - result matches standard # strOfType_trn_symListsInnTrn_test example 1 : OK - result matches standard # strOfType_extTranSub_symGenl_test example 1 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 1 : FAILED - result does NOT match standard >> Almost there!? # strOfType_extTranSub_symGenl_test example 1 : FAILED - result does NOT match standard t_input, t_standard, t_result = % - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) % - ∂[∂(t) : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) % - ∂[∂(t) : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo,t)) trnType= /% >> incorrect t_standard! # strStdForm_extractTranslate_symGenl_test example 1 : FAILED - result does NOT match standard t_input, t_standard, t_result = % - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) % - ∂[∂(t) : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) % - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) trnType= /% >> Is there an exact copy if t_input in /% transExpr_table? (HFLN) NO - but any Expr in t_input should be translated! So current result is WRONG! Plus AOpc should be Aθpc # 08********08 #] 20Nov2018 I need more tests : [strOfType_trn_symListsInnTrn_test, strOfType_extTranSub_symGenl_test, strStdForm_extractTranslate_symGenl_test] Just copy and modify [symParn_translate_test, strOfType_extractFindTrans_symExpr_test] qnial> symTranslate_alltest >> Why is strOfType_extTranSub_symGenl_test run TWICE? Mislabeled strStdForm_extractTranslate_symGenl_test 21Nov2018 qnial> symTranslate_alltest # strOfType_extractFindTrans_symExpr_test example 1 : FAILED - result does NOT match standard # strOfType_extractFindTrans_symExpr_test example 5a : FAILED - result does NOT match standard # symParn_translate_test example 13 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 7 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 10 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 11 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 102 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 106 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 2 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 3 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 4 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 5 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 6 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 7 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 8 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 10 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 11 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 13 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 14 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 15 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 101 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 102 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 102a : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 103 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 103a : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 105 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 105a : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 106 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 106a : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 107 : FAILED - result does NOT match standard >> OK - most tests work for strOfType_extractFindTrans_symExpr_test symParn_translate_test strOfType_trn_symListsInnTrn_test strOfType_extTranSub_symGenl_test >> However, there are some deep-rooted problems to fix >> I also cleaned up [parn, expr] lists for translations >> BAD - most tests wrong for : strStdForm_extractTranslate_symGenl_test] >> but same good for : strOfType_extTranSub_symGenl_test So there is something wrong with strStdForm_extractTranslate_symGenl translation!? Change : +-----+ strStdForm_extractTranslate_symGenl IS OP strStdr { LOCAL i len textnew textout ; NONLOCAL trnType trnType_old ; % ; i := 0 ; len := gage shape strStdr ; textnew textout := null null ; % ; WHILE (i < len) DO IF (= strStdr@i '/') THEN IF ((i + 1) < len) THEN IF (= strStdr@(i + 1) '*') THEN textout := link textout '/*' (strOfType_extTranSub_symGenl textnew) ; textNew := null ; trnTypeSet '/*' ; i := i + 1 ; ELSEIF (= strStdr@(i + 1) '$') THEN textout := link textout '/$' (strOfType_extTranSub_symGenl textnew) ; textNew := null ; trnTypeSet '/$' ; i := i + 1 ; # strOfType_extTranSub_symGenl_test example 1 : FAILED - result does NOT match standard t_input, t_standard, t_result = % - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) % - ∂[∂(t) : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) % - ∂[∂(t) : EIpds(POIo,t)]/Vons(particle)/cos(Aθpc(POIo,t)) trnType= /% >> incorrect t_standard! # strStdForm_extractTranslate_symGenl_test example 1 : FAILED - result does NOT match standard t_input, t_standard, t_result = % - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) % - ∂[∂(t) : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) % - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) trnType= /% >> Is there an exact copy if t_input in /% transExpr_table? (HFLN) NO - but any Expr in t_input should be translated! So current result is WRONG! Plus AOpc should be Aθpc ELSEIF (= strStdr@(i + 1) '%') THEN textout := link textout '/%' (strOfType_extTranSub_symGenl textnew) ; textNew := null ; trnTypeSet '/%' ; i := i + 1 ; ELSEIF (= strStdr@(i + 1) '^') THEN textout := link textout '/%' (strOfType_extTranSub_symGenl textnew) ; textNew := null ; trnTypeSet trnType_old ; i := i + 1 ; ELSE textnew := link textnew strStdr@i ; i := i + 1 ; ENDIF ; ENDIF ; ELSE textnew := link textnew strStdr@i ; i := i + 1 ; ENDIF ; ENDWHILE ; link textout textnew } +-----+ To : +-----+ strStdForm_extractTranslate_symGenl IS OP strStdr { LOCAL i len textnew textout ; NONLOCAL trnType ; % ; i := 0 ; len := gage shape strStdr ; textnew textout := null null ; % ; WHILE (i < len) DO IF (= strStdr@i '/') THEN IF ((i + 1) < len) THEN IF (= strStdr@(i + 1) '*') THEN trnTypeSet '/*' ; i := i + 1 ; textout := link textout '/*' (strOfType_extTranSub_symGenl textnew) ; textNew := null ; ELSEIF (= strStdr@(i + 1) '$') THEN trnTypeSet '/$' ; i := i + 1 ; textout := link textout '/$' (strOfType_extTranSub_symGenl textnew) ; textNew := null ; ELSEIF (= strStdr@(i + 1) '%') THEN trnTypeSet '/%' ; i := i + 1 ; textout := link textout '/%' (strOfType_extTranSub_symGenl textnew) ; textNew := null ; ELSE textnew := link textnew strStdr@i ; i := i + 1 ; ENDIF ; ENDIF ; ELSE textnew := link textnew strStdr@i ; i := i + 1 ; ENDIF ; ENDWHILE ; link textout textnew } +-----+ Removed : +-----+ trnType_old no longer used ELSEIF (= strStdr@(i + 1) '^') THEN trnTypeSet trnType_old ; i := i + 1 ; textout := link textout '/%' (strOfType_extTranSub_symGenl textnew) ; textNew := null ; # trnTypeSet IS OP trnTypeInn - set trnType properly # 17Sep2018 initial trnTypeSet IS OP trnTypeInn { NONLOCAL trnType ; trnType_old := trnType ; trnType := trnTypeInn ; } +-----+ Observation : strStdForm_extractTranslate_symGenl OK when the strOfType doesn't change fails when the strOfType does change looks like symParn_translate always fails for strStdForm_extractTranslate_symGenl? but it usually succeeds with tests of strOfType_extTranSub_symGenl (the ONLY operator that calls it) not affected : strOfType_trn_symListsInnTrn Change To : +-----+ strStdForm_extractTranslate_symGenl IS OP strStdr { LOCAL i len textnew textout ; NONLOCAL trnType ; % ; i := 0 ; len := gage shape strStdr ; textnew textout := null null ; % ; WHILE (i < len) DO IF (= strStdr@i '/') THEN IF ((i + 1) < len) THEN IF (= strStdr@(i + 1) '*') THEN textout := link textout (strOfType_extTranSub_symGenl textnew) ; trnType textnew := '/*' '/*' ; i := i + 1 ; ELSEIF (= strStdr@(i + 1) '$') THEN textout := link textout (strOfType_extTranSub_symGenl textnew) ; trnType textnew := '/$' '/$' ; i := i + 1 ; ELSEIF (= strStdr@(i + 1) '%') THEN textout := link textout (strOfType_extTranSub_symGenl textnew) ; trnType textnew := '/%' '/%' ; i := i + 1 ; ELSE textnew := link textnew strStdr@i ; ENDIF ; ENDIF ; ELSE textnew := link textnew strStdr@i ; ENDIF ; i := i + 1 ; ENDWHILE ; link textout (strOfType_extTranSub_symGenl textnew) } +-----+ >> OK, that did it >> Remaining problems are "consistent" : # strOfType_extractFindTrans_symExpr_test example 1 : FAILED - result does NOT match standard # strOfType_extractFindTrans_symExpr_test example 5a : FAILED - result does NOT match standard # symParn_translate_test example 13 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 7 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 10 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 11 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 102 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 106 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 7 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 10 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 11 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 102 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 106 : FAILED - result does NOT match standard # strOfType_extractFindTrans_symExpr_test example 1 : FAILED - result does NOT match standard t_input, t_standard, t_result = % - dp[dt : EIpds(POIo,t)]/Vons(particle)/cos(AOpc(POIo,t)) +-------+------------+ |+-----+|+----------+| ||dp[dt|||∂[∂(t)|| |+-----+|+----------+| +-------+------------+ +-----+------+ |+---+|+----+| ||dp[|||∂[|| |+---+|+----+| +-----+------+ trnType= /% # strOfType_extractFindTrans_symExpr_test example 5a : FAILED - result does NOT match standard t_input, t_standard, t_result = + 1/Rocs(POIo)/c*dp[dt : | Ei(ro - vo*t,t) |] ] +---------------------------------+----------------------------------------+ |+-----+---------------+---------+|+----------+----------------+----------+| ||dp[dt|Ei(ro - vo*t,t)|ro - vo*t|||∂[∂(t)|EIodv(POIp(t),t)|Rpcv(POIp)|| |+-----+---------------+---------+|+----------+----------------+----------+| +---------------------------------+----------------------------------------+ +-------------------------------+----------------------------------+ |+---+---------------+---------+|+----+----------------+----------+| ||dp[|Ei(ro - vo*t,t)|ro - vo*t|||∂[|EIodv(POIp(t),t)|Rpcv(POIp)|| |+---+---------------+---------+|+----+----------------+----------+| +-------------------------------+----------------------------------+ trnType= /% translation should work for all expressions oops- spaces of "| Ei(ro - vo*t,t) |" not handled properly!? strOfType_extractFindTrans_symExpr_test does NOT do sym_stdForm, so spaces AREN't removed, and expr with spaces aren't recognized. For examples [1,5a] it appears that "dt" doesn't have tranParnHFLN translation? >> yes it does!! But I need to put back tranExpr[HFLN,Luca] for dp[... !!!??? NO! - just do separate parenthesis correction for [dp,∫,∮,∬] and DON'T use Expr for them! Re-test after fixing t_standards qnial> strOfType_extractFindTrans_symExpr_test >> all OK +-----+ PROBLEM : write_testStr '20Nov2018 WRONG! incomplete substitution. Why?' ; # strOfType_extTranSub_symGenl_test example 7 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 10 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 102 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 106 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 7 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 10 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 102 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 106 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 7 : FAILED - result does NOT match standard t_input, t_standard, t_result = /%dp[dt : |Ei(ro - vo*t,t)|] /%∂[∂(t) : EIods(POIp(t),t)] /%∂[∂(t) : |EIodv(POIp(t),t)|] trnType= /% # strStdForm_extractTranslate_symGenl_test example 10 : FAILED - result does NOT match standard t_input, t_standard, t_result = /%- has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. /%- has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/Rpcs(POIp)" in the first term in parenthesis. /%- has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/|Rocv(POIo) - Vonv(particle)*t|" in the first term in parenthesis. trnType= /% # strStdForm_extractTranslate_symGenl_test example 102 : FAILED - result does NOT match standard t_input, t_standard, t_result = /%- has the term "(ros*cosOo - vos*t)/|ro - vo*t|" in the first term in parenthesis. /%- has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/Rpcs(POIp)" in the first term in parenthesis. /%- has the term "(Rocs(POIo)*cos(Aθoc(POIo)) - Vons(particle)*t)/|Rocv(POIo) - Vonv(particle)*t|" in the first term in parenthesis. trnType= /% # strStdForm_extractTranslate_symGenl_test example 106 : FAILED - result does NOT match standard t_input, t_standard, t_result = /% = vos/c*Rocs(POIo)*sinOo*q/|rov - vo*t|^3*Pph /% = Vons(particle)/c*Rocs(POIo)*sin(Aθoc(POIo))*Q(particle)/Rpcs(POIp)^3*Rφpch /% = Vons(particle)/c*Rocs(POIo)*sin(Aθoc(POIo))*Q(particle)/|Rocv - Vonv(particle)*t|^3*Rφpch trnType= /% Maybe I need to go back and do Exprs first, then Parns? strOfType_extTranSub_symGenl Change : +-----+ strOfType_extTranSub_symGenl IS OP strOfType { LOCAL textnew symList_inn symList_trn ; % ; textnew := strOfType ; % ; % PART I - PARN translations ; % find symParns in strOfType, then find translations of each (no substitution yet!) ; symList_inn := cull strStd_extract_symParn strOfType ; symList_trn := EACH symParn_translate symList_inn ; IF (~= null symList_inn) THEN textnew := strOfType_trn_symListsInnTrn textnew symList_inn symList_trn ; ENDIF ; % ; % PART II - EXPR translations ; % find symExprs in strOfType, then find translations of each (no substitution yet!) ; symList_inn symList_trn := strOfType_extractFindTrans_symExpr textnew ; IF (~= null symList_inn) THEN textnew := strOfType_trn_symListsInnTrn textnew symList_inn symList_trn ; ENDIF ; textnew } +-----+ To : +-----+ strOfType_extTranSub_symGenl IS OP strOfType { LOCAL textnew symList_inn symList_trn ; % ; textnew := strOfType ; % ; % PART I - EXPR translations ; % find symExprs in strOfType, then find translations of each (no substitution yet!) ; symList_inn symList_trn := strOfType_extractFindTrans_symExpr textnew ; IF (~= null symList_inn) THEN textnew := strOfType_trn_symListsInnTrn textnew symList_inn symList_trn ; ENDIF ; % ; % PART II - PARN translations ; % find symParns in strOfType, then find translations of each (no substitution yet!) ; symList_inn := cull strStd_extract_symParn strOfType ; symList_trn := EACH symParn_translate symList_inn ; IF (~= null symList_inn) THEN textnew := strOfType_trn_symListsInnTrn textnew symList_inn symList_trn ; ENDIF ; textnew } +-----+ >> Interesting! >> strOfType_extTranSub_symGenl : mostly OK, but created new problem with : # strOfType_extTranSub_symGenl_test example 107 : FAILED - result does NOT match standard >> strStdForm_extractTranslate_symGenl : Worse mess (ignore examples 11) Previous : # strStdForm_extractTranslate_symGenl_test example 7 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 10 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 102 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 106 : FAILED - result does NOT match standard Current : # strStdForm_extractTranslate_symGenl_test example 6 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 7 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 10 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 102a : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 103 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 105 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 105a : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 106a : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 107 : FAILED - result does NOT match standard Only [7,10] are common to both Wrong [HFLN,Luca] selection for tran : [6,10,103] -> looks like AFTER trnType changed! Absolute not translated : [7,10,105a] -> [n,n,y] space between "|" and rest of expr Absoluted translated : [102,105,106a] -> [n,n,n] space between "|" and rest of expr mixed tran : [102a,105,105a,106a] -> looks like AFTER trnType changed! weird : 107 # 08********08 #] 20Nov2018 strOfType_trn_symListsInnTrn - don't use string_sub for Parns!!!! Change : +-----+ strOfType_trn_symListsInnTrn IS OP strOfType symList_inn symList_trn { LOCAL address i lengths mixList mixList_cull textnew symList_inn symList_trn symList_inn_chg symList_trn_chg symList_inn_grade symList_trn_grade symList_inn_cull symList_trn_cull ; % ; textnew := strOfType ; % ; %pick out only the syms that change from raw to trn!! ; symList_inn_chg symList_trn_chg := (EACHBOTH ~= symList_inn symList_trn ) EACHRIGHT sublist (symList_inn symList_trn ) ; % ; %sort the two lists [symList_inn_chg, symList_trn_chg] by >= length of symList_inn_chg. This is to force replacement of the largest sym[Parns,Exprs] first, so the simple syms don't prevent larger coherent translations ; lengths := EACH (gage shape) symList_inn_chg ; address := grade >= lengths ; %write '[lengths,address]= ' lengths address ; symList_inn_grade symList_trn_grade := address EACHRIGHT choose symList_inn_chg symList_trn_chg ; % ; %EACH write '[strOfType symList_inn symList_trn symList_inn_grade symList_trn_grade]= ' strOfType symList_inn symList_trn symList_inn_grade symList_trn_grade ; % ; %replace symList_inn_grade with symList_trn_grade one at at a time, as textnew changes with each substitution ; FOR i WITH tell gage shape symList_inn_grade DO textnew := string_sub symList_inn_grade@i symList_trn_grade@i textnew ; %write symList_inn_grade@i symList_trn_grade@i ; %write link (string i) ' : ' textnew ; ENDFOR ; % ; textnew } +-----+ To : +-----+ strOfType_trn_exprListsInnTrn IS OP strOfType exprList_inn exprList_trn { LOCAL address i lengths mixList mixList_cull textnew exprList_inn exprList_trn exprList_inn_chg exprList_trn_chg exprList_inn_grade exprList_trn_grade exprList_inn_cull exprList_trn_cull ; % ; textnew := strOfType ; % ; %pick out only the exprs that change from raw to trn!! ; exprList_inn_chg exprList_trn_chg := (EACHBOTH ~= exprList_inn exprList_trn ) EACHRIGHT sublist (exprList_inn exprList_trn ) ; % ; %sort the two lists [exprList_inn_chg, exprList_trn_chg] by >= length of exprList_inn_chg. This is to force replacement of the largest exprs first, so the simple exprs don't prevent larger coherent translations ; lengths := EACH (gage shape) exprList_inn_chg ; address := grade >= lengths ; %write '[lengths,address]= ' lengths address ; exprList_inn_grade exprList_trn_grade := address EACHRIGHT choose exprList_inn_chg exprList_trn_chg ; % ; %EACH write '[strOfType exprList_inn exprList_trn exprList_inn_grade exprList_trn_grade]= ' strOfType exprList_inn exprList_trn exprList_inn_grade exprList_trn_grade ; % ; %replace exprList_inn_grade with exprList_trn_grade one at at a time, as textnew changes with each substitution ; FOR i WITH tell gage shape exprList_inn_grade DO textnew := string_sub exprList_inn_grade@i exprList_trn_grade@i textnew ; %write exprList_inn_grade@i exprList_trn_grade@i ; %write link (string i) ' : ' textnew ; ENDFOR ; % ; textnew } +-----+ +-----+ PROBLEM : write_testStr '20Nov2018 WRONG! why? - big problem with partial symbol substitution!!!' ; # strOfType_extTranSub_symGenl_test example 11 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 11 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 11 : FAILED - result does NOT match standard t_input, t_standard, t_result = ∮[*dφ´ : dp[dt : Bi(r - v*t,t)]•n´ ∮[*∂(Aφpc(POIp)) : ∂[∂(t) : BIodv(POIo,t)]•??n´->Rpch(POIp,Vonv_X_Rpcv)?? ∮[*∂(Aφpc(POIp)) : ∂[∂(t) : BIodVonv(particle)(POIo,t)]•??n´->Roch(POIo,VonVonv(particle)_X_RpcVonv(particle))?? trnType= /% 20Nov2018 WRONG! why? - big problem! # 08********08 #] 27Nov2018 after changing strStd_extract_symParnPosn, now to fix [strOfType_extTranSub_symGenl, strStdForm_extractTranslate_symGenl] To check if transParnList sorting affects results, I created : # sort_transParnLists IS - QNial sorts Parn lists, cannot do expression lists as those must be ordered! Now it appears that strOfType_extTranSub_symGenl only does one or two substituitons of many? Did I enforce d[dt translation BEFORE substitutions? Problems with : qnial> strOfType_extTranSub_symGenl_test +---------------+ strOfType_extTranSub_symGenl_test, Tue Nov 27 17:22:42 2018 strOfType_extTranSub_symGenl ONLY translates "composite expressions" that have exact copies in transExpr_table. - otherwise it returns null - must be changed to properly test strOfType_extTranSub_symGenl. # strOfType_extTranSub_symGenl_test example 11a : FAILED - result does NOT match standard t_input, t_standard, t_result = ∮[*dφ´: dp[dt: Bi(r - v*t,t)]•n´ ∮[*∂(Aφpc(POIp)): ∂[∂(t): BIodv(POIo,t)]•??n´->Rpch(POIp,Vonv_X_Rpcv)?? ∮[*∂(Aφpc(POIp)): ∂[∂(t): BIodVonv(particle)(RpcVonv(particle)(POIp),t)]•??n´->Roch(POIo,VonVonv(particle)_X_RpcVonv(particle))?? trnType= /% NUTS!! substitution within Parn!?!?!? # strOfType_extTranSub_symGenl_test example 106 : FAILED - result does NOT match standard t_input, t_standard, t_result = = vos/c*Rocs(POIo)*sinOo*q/|rov - vo*t|^3*Pph = vos/c*Rocs(POIo)*sinOo*q/Rpcs(POIp)^3*Pph = vos/c*Rocs(POIo)*sinOo*q/Rpcs(POIp)^3*Pph trnType= /% 20Nov2018 WRONG! incomplete substitution. Why? strStd_extract_symParnPosn ERROR : != str_stdForm (sym_stdForm str_stdForm) produces wrong answer without sym_stdForm # strOfType_extTranSub_symGenl_test example 107 : FAILED - result does NOT match standard t_input, t_standard, t_result = HFLN = q/c*(vovrpv)/rps^2 + vov/cEi(rp,tp) HFLN = q/c*(vr)/rps^2 + vov/cEi(rp,tp) HFLN = q/c*(vr)/rps^2 + vov/cEi(rp,tp) trnType= /$ strStd_extract_symParnPosn ERROR : != str_stdForm (sym_stdForm str_stdForm) produces wrong answer without sym_stdForm # strOfType_extTranSub_symGenl_test example 107a : FAILED - result does NOT match standard t_input, t_standard, t_result = HFLN = q/c*(vovrpv)/rps^2 + vov/cEi(rp,tp) HFLN = q/c*(vr´)/r´s^2 + v/cEi(r´,t´) HFLN = q/c*(vr)/r´s^2 + v/cEi(r´,t´) trnType= /$ +---------------+ >> Example 11a is SCARY!!!??? >> Numerous other examples are actually wrong : write_testStr 'produces wrong answer without sym_stdForm' ; >> so sym_stdForm is critical to functioning # 08********08 #] 29Nov2018 strOfType_extTranSub_symGenl failures strStd_extract_symParnPosn ERROR : != str_stdForm (sym_stdForm str_stdForm) >> this error occurs with strOfType_extTranSub_symGenl_test examples : [2,2a?,5,6?,7,7a?,9,10(2),11,11a?,101,101a?,102,102a,102b,103,103a,104,105,105a,106,106a?,106b?,10,107a?] >> where "?" indicates that error occurred BEFORE other writestrs!? >> notice list of failed strOfType_extTranSub_symGenl_test : # strOfType_extTranSub_symGenl_test example 2 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 6 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 7 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 10 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 11 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 101 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 102 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 103 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 105 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 105a : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 106 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 106a : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 107 : FAILED - result does NOT match standard >> Although not an exact correspondance between the error and strOfType_extTranSub_symGenl_test, it's somewhat similar. Perhaps the "single letter" false substitution problem may be caused by recursion issues in strStd_extract_symParnPosn? For example - list versus string? Trace-break strStd_extract_symParnPosn and run only strOfType_extTranSub_symGenl_test example 2 : In "" I changed : IF (= str_stdForm (sym_stdForm str_stdForm)) THEN >> back to previous version : IF (isstring str_stdForm) THEN Redo strOfType_extTranSub_symGenl_test : >> Failures with [2,6,7, 11,11a,101, 105, 106, 107,107a] 10 total Compared to [2,6,7,10,11, 101,102,103,105,105a,106,106a,107 ] 13 total in previous run BUT, errors with t_standard : [2,many... can't see any difference!: [ >> much of t_standard problem is that strOfType_extTranSub_symGenl DOESN'T remove spaces!! (good!) some DON'T : [ 6 ,7 ,11,101 ,102 ,105 ,106 ,107 ] but some DO! : [2 ,6a,7a, 101a,102a,105a,106a,107a 2a, 102b,105b,106b ] bad recurse : [11,11a] r' problem : [107a] Fix t_standards : Failures with : [2,11a,101,106,107,107a] no difference? : [106] bad recurse : [11,11a] r' problem : [107a] no de-space : [6,7,11,101,102,105,106,107] Wait a minute! [2,2a] and [6,6a] contain the same tests!! Why does one remove spaces, but the other doesn't? I hadn't changed all examples to : t_result := strOfType_extTranSub_symGenl sym_stdForm t_input ; Try again : After several iterations, the translations work well for most, but there are several issues to address longer term. # 08********08 #] 29Nov2018 strStdForm_extractTranslate_symGenl_test failures Retry symTranslate_all_test after fixing strOfType_extTranSub_symGenl BUT : - will have to fix many t_standards - don't need to sym_stdForm t_inputs, as this is done by strOfType_extTranSub_symGenl Failures : # strOfType_extractFindTrans_exprs_test example 2 : FAILED - result does NOT match standard # strOfType_extractFindTrans_exprs_test example 3 : FAILED - result does NOT match standard # strOfType_trn_exprListsInnTrn_test example 2 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 11 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 101a : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 107 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 107a : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 1 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 3 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 4 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 5 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 7 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 10 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 11 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 15 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 101 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 102 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 103 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 105a : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 106 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 107 : FAILED - result does NOT match standard >> Focus on strStdForm_extractTranslate_symGenl_test Oops, change : +-----+ t_result := strStdForm_extractTranslate_symGenl t_input ; +-----+ To : +-----+ t_result := strStdForm_extractTranslate_symGenl sym_stdForm t_input ; +-----+ Oops again - comparators with chars nost strings! strStdForm_extractTranslate_symGenl -> Change : +-----+ '/' '*' '$' '%' +-----+ To : +-----+ `/ `* `$ `% +-----+ Re-run symTranslate_all_test after fixing t_standards for strStdForm_extractTranslate_symGenl_test : # strOfType_extTranSub_symGenl_test example 11 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 101a : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 107 : FAILED - result does NOT match standard # strOfType_extTranSub_symGenl_test example 107a : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 11 : FAILED - result does NOT match standard # strStdForm_extractTranslate_symGenl_test example 107 : FAILED - result does NOT match standard # 08********08 #] 29Nov2018 List of remaining problem examples after fixing [t_standards, strOfType_extractFindTrans_exprs_test, strOfType_extTranSub_symGenl_test, strStdForm_extractTranslate_symGenl_test] # strOfType_extTranSub_symGenl_test example 11 : FAILED - result does NOT match standard t_input, t_standard, t_result = ∮[ *dφ´ : dp[dt : Bi(r - v*t,t)]•n´ ∮[*∂(Aφpc(POIp)): ∂[∂(t): BIodv(particle)(Rpcv(particle)(POIp),t)]•??n´ - >Roch(POIo,Vonv(particle)_X_Rpcv(particle))?? ∮[*∂(Aφpc(POIp)): ∂[∂(t): BIodVonv(particle)(RpcVonv(particle)(POIp),t)]•??n´->Roch(POIo,VonVonv(particle)_X_RpcVonv(particle))?? trnType= /% NUTS!! excessive recursion substitution within Parn!?!?!? # strOfType_extTranSub_symGenl_test example 101a : FAILED - result does NOT match standard t_input, t_standard, t_result = % - dp[dt : EIpds(POIo, t)]/ Vons(particle)/cos(AOpc(POIo,t)) % - ∂[∂(t): Ei´/v/cos(θ´) % - ∂[∂(t): EIpds(POIo,t)]/vs/cos(AOpc(POIo,t)) trnType= /$ Incomplete "tranExpr Luca.txt" # strOfType_extTranSub_symGenl_test example 107 : FAILED - result does NOT match standard t_input, t_standard, t_result = HFLN = q/c*(vovrpv)/rps^2 + vov/cEi(rp,tp) HFLN = q/c*(vr)/r´s^2 + v/cEi(r´,t´) HFLN = q/c*(vr)/r´s^2 + v/cEi(r´,t´) trnType= /$ weird addition of extra space? # strOfType_extTranSub_symGenl_test example 107a : FAILED - result does NOT match standard t_input, t_standard, t_result = HFLN = q/c*(vovrpv)/rps^2 + vov/cEi(rp,tp) HFLN = q/c*(vr´)/r´s^2 + v/cEi(r´,t´) HFLN = q/c*(vr)/r´s^2 + v/cEi(r´,t´) trnType= /$ weird dropping of back-apo # strStdForm_extractTranslate_symGenl_test example 11 : FAILED - result does NOT match standard t_input, t_standard, t_result = /%∮[*dφ´ : dp[dt : Bi(r - v*t,t)]•n´ /%∮[*∂(Aφpc(POIp)): ∂[∂(t): BIodv(POIo,t)]•??n´ - >Rpch(POIp,Vonv_X_Rpcv)?? /%∮[*∂(Aφpc(POIp)): ∂[∂(t): BIodVonv(particle)(RpcVonv(particle)(POIp),t)]•??n´->Roch(POIo,VonVonv(particle)_X_RpcVonv(particle))?? NUTS!! excessive recursion substitution within Parn!?!?!? # strStdForm_extractTranslate_symGenl_test example 107 : FAILED - result does NOT match standard t_input, t_standard, t_result = /$HFLN = q/c*(vovrpv)/rps^2 + vov/cEi(rp,tp) /$HFLN = q/c*(vr´)/r´s^2 + v/cEi(r´,t´) /$HFLN = q/c*(vr)/r´s^2 + v/cEi(r´,t´) weird dropping of back-apo # 08********08 #] 30Nov2018 Tackle strOfType_extTranSub_symGenl_test example 1 # strOfType_extTranSub_symGenl_test example 11 : FAILED - result does NOT match standard t_input, t_standard, t_result = ∮[ *dφ´ : dp[dt : Bi(r - v*t,t)]•n´ ∮[*∂(Aφpc(POIp)): ∂[∂(t): BIodv(particle)(Rpcv(particle)(POIp),t)]•??n´ - >Roch(POIo,Vonv(particle)_X_Rpcv(particle))?? ∮[*∂(Aφpc(POIp)): ∂[∂(t): BIodVonv(particle)(RpcVonv(particle)(POIp),t)]•??n´->Roch(POIo,VonVonv(particle)_X_RpcVonv(particle))?? trnType= /% NUTS!! excessive recursion substitution within Parn!?!?!? Trace-break it : +-----+ qnial> strOfType_extTranSub_symGenl_test strOfType_extTranSub_symGenl_test, Fri Nov 30 10:33:03 2018 strOfType_extTranSub_symGenl ONLY translates "composite expressions" that have exact copies in transExpr_table. - otherwise it returns null - must be changed to properly test strOfType_extTranSub_symGenl. # strOfType_extTranSub_symGenl_test example 11 : FAILED - result does NOT match standard t_input, t_standard, t_result = ∮[ *dφ´ : dp[dt : Bi(r - v*t,t)]•n´ ∮[*∂(Aφpc(POIp)): ∂[∂(t): BIodv(particle)(Rpcv(particle)(POIp),t)]•??n´ - >Roch(POIo,Vonv(particle)_X_Rpcv(particle))?? ∮[*∂(Aφpc(POIp)): ∂[∂(t): BIodVonv(particle)(RpcVonv(particle)(POIp),t)]•??n´->Roch(POIo,VonVonv(particle)_X_RpcVonv(particle))?? trnType= /% NUTS!! excessive recursion substitution within Parn!?!?!? +-----+ >> Hilarious! it doesn't even call # 08********08 #] 30Nov2018 strOfType_extTranSub_symGenl - need to better handle translations! Change : +-----+ strOfType_extTranSub_symGenl IS OP strOfType { LOCAL textnew exprList_inn exprList_trn symList_inn symList_trn ; % ; textnew := strOfType ; % ; % PART I - symExpr translations ; % find symExprs in strOfType, then find translations of each (no substitution yet!) ; exprList_inn exprList_trn := strOfType_extractFindTrans_exprs textnew ; IF (~= null exprList_inn) THEN textnew := strOfType_trn_exprListsInnTrn textnew exprList_inn exprList_trn ; ENDIF ; % ; % PART II - PARN translations ; % find symParns in strOfType, then find translations of each (no substitution yet!) ; IF flag_break THEN BREAK ; ENDIF ; symList_inn symPosn_inn := strStd_extract_symParnPosn strOfType ; IF (~= null symList_inn) THEN symList_trn := EACH symParn_translate symList_inn ; textnew := strOfType_trn_parnListsInnTrn textnew symList_inn symList_trn ; ENDIF ; textnew } +-----+ To : +-----+ +-----+ # 08********08 #] 01Dec2018 removed - because of new [strOfType_extract_exprs, strOfType_translate_symGenl] +-----+ # loaddefs link d_Qnial_mine 'symbols translate.ndf' # strOfType_extractFindTrans_exprs IS OP strOfType - produces a list of [symExpr_old, symExpr_new] in strOfType # strOfType - is a str_stdForm of a given trnType # 03May2018 initial # 03May2018 - the current version expects the format of the string (eg [spaces,tabs,caps,etc]) to match the "dictionary" # I want NON-OVERLAPPING expressions - first found prevail, but all non-overlapping should be found # That doesn't prevent multiple occurences in str # 18May2018 Unfortunately, for expediency & speed, this is now anchored to Lucas project transExpr_tables # 03Sep2018 NOTE : strOfType_extractFindTrans_exprs MUST be fed a string strOfType in standard format to get proper symbols! # 12Sep2018 strOfType_extractFindTrans_exprs relies on trnType having been set properly # it ONLY translates with one trnType # 17Sep2018 make code more general (eg arbitrary lists of translation tables) # 17Sep2018 09:58 - must be fed one of trnTypes (eg '/$' '/%) ; # 18Nov2018 bisection search - would be nice (see "lists.ndf"), parns can be sorted, BUT expressions CANNOT be sorted! # 01Dec2018 Now redundant? (18Mar2019 - what is redundant???) strOfType_extractFindTrans_exprs IS OP strOfType { LOCAL i symListInn symListNew trn_len trn_old trn_new ; % ; trn_len trn_old trn_new := trnInfo 'Expr' ; symListInn symListNew := null null ; FOR i WITH (tell trn_len) DO IF (in_string (execute (link trn_old '@i')) strOfType) THEN symListInn := link symListInn (solitary (execute (link trn_old '@i'))) ; symListNew := link symListNew (solitary (execute (link trn_new '@i'))) ; ENDIF ; ENDFOR ; symListInn symListNew } # loaddefs link d_Qnial_mine 'symbols translate.ndf' # strOfType_trn_exprListsInnTrn IS OP strOfType exprList_inn exprList_trn - for exprs ONLY!!! # - [picks out changes, sorts by length] of exprList_inn, then subs exprList_trn into strOfType) # strOfType - is a str_stdForm of a given trnType # This can be used as a very general translator of ANY expr - can use [linked, ordered] expr transLists # www.BillHowell.ca 17Sep2018 sub-opped from long-standing strOfType_extractTranslate_symGenl # 18Sep2018 assumes that exprList_inn has been culled! strOfType_trn_exprListsInnTrn IS OP strOfType exprList_inn exprList_trn { LOCAL address i lengths mixList mixList_cull textnew exprList_inn exprList_trn exprList_inn_chg exprList_trn_chg exprList_inn_grade exprList_trn_grade exprList_inn_cull exprList_trn_cull ; % ; textnew := strOfType ; % ; %pick out only the exprs that change from raw to trn!! ; exprList_inn_chg exprList_trn_chg := (EACHBOTH ~= exprList_inn exprList_trn ) EACHRIGHT sublist (exprList_inn exprList_trn ) ; % ; %sort the two lists [exprList_inn_chg, exprList_trn_chg] by >= length of exprList_inn_chg. This is to force replacement of the largest exprs first, so the simple exprs don't prevent larger coherent translations ; lengths := EACH (gage shape) exprList_inn_chg ; address := grade >= lengths ; %write '[lengths,address]= ' lengths address ; exprList_inn_grade exprList_trn_grade := address EACHRIGHT choose exprList_inn_chg exprList_trn_chg ; % ; %EACH write '[strOfType exprList_inn exprList_trn exprList_inn_grade exprList_trn_grade]= ' strOfType exprList_inn exprList_trn exprList_inn_grade exprList_trn_grade ; % ; %replace exprList_inn_grade with exprList_trn_grade one at at a time, as textnew changes with each substitution ; FOR i WITH tell gage shape exprList_inn_grade DO textnew := string_sub exprList_inn_grade@i exprList_trn_grade@i textnew ; %write exprList_inn_grade@i exprList_trn_grade@i ; %write link (string i) ' : ' textnew ; ENDFOR ; % ; textnew } # loaddefs link d_Qnial_mine 'symbols translate.ndf' # strOfType_trn_parnListsInnTrn IS OP strOfType parnList_inn parnList_trn - for parns ONLY!!! # - [picks out changes, sorts by length] of parnList_inn, then subs parnList_trn into strOfType) # strOfType - is a str_stdForm of a given trnType # This can be used as a very general translator of ANY parn - can use [linked, ordered] cart parn transLists # www.BillHowell.ca 17Sep2018 sub-opped from long-standing strOfType_extractTranslate_symGenl # 18Sep2018 assumes that parnList_inn has been culled! # 20Nov2018 strOfType_trn_parnListsInnTrn - don't use string_sub for Parns!!!! # - puts letters in for Parns (= [base symbols, parenthesized exprs]) Don't guess and rely on luck!! : identify posn of all matched [parn, expr] -> those that overlap, size ordering parns can ONLY substitute for parns, not strings strOfType_trn_parnListsInnTrn IS OP strOfType parnList_inn parnList_trn { LOCAL address i lengths mixList mixList_cull textnew parnList_inn parnList_trn parnList_inn_chg parnList_trn_chg parnList_inn_grade parnList_trn_grade parnList_inn_cull parnList_trn_cull ; % ; textnew := strOfType ; % ; %pick out only the parns that change from raw to trn!! ; parnList_inn_chg parnList_trn_chg := (EACHBOTH ~= parnList_inn parnList_trn ) EACHRIGHT sublist (parnList_inn parnList_trn ) ; % ; %sort the two lists [parnList_inn_chg, parnList_trn_chg] by >= length of parnList_inn_chg. This is to force replacement of the largest parns first, so the simple parns don't prevent larger coherent translations ; lengths := EACH (gage shape) parnList_inn_chg ; address := grade >= lengths ; %write '[lengths,address]= ' lengths address ; parnList_inn_grade parnList_trn_grade := address EACHRIGHT choose parnList_inn_chg parnList_trn_chg ; % ; %EACH write '[strOfType parnList_inn parnList_trn parnList_inn_grade parnList_trn_grade]= ' strOfType parnList_inn parnList_trn parnList_inn_grade parnList_trn_grade ; % ; %replace parnList_inn_grade with parnList_trn_grade one at at a time, as textnew changes with each substitution ; FOR i WITH tell gage shape parnList_inn_grade DO textnew := string_sub parnList_inn_grade@i parnList_trn_grade@i textnew ; %write parnList_inn_grade@i parnList_trn_grade@i ; %write link (string i) ' : ' textnew ; ENDFOR ; % ; textnew } # loaddefs link d_Qnial_mine 'symbols translate.ndf' # symParn_translate IS OP symParnList_old - returns translation of symParn, or the symParn itself # 02May2018 for now symParn_translate searches entire trn_old list, but I should use an efficient search! # 03Sep2018 NOTE : symParnList_old must be in str_stdForm format to get proper symParnList_new! # 12Sep2018 symParn_translate relies on trnType having been set properly, as it ONLY translates with current trnType # 18Sep2018 "find_Howell IS OP item_sought list_to_search" is in setup.ndf # 18Sep2018 must handle error when symbol is NOT in trn_old symParn_translate IS OP symParnList_old { LOCAL i symParnList_new trn_len trn_old trn_new ; % ; trn_len trn_old trn_new := trnInfo 'Parn' ; % find_Howell-choose returns a SINGLE (not a solitary!) ; i := execute (link 'find_Howell symParnList_old ' trn_old) ; symParnList_new := execute (link trn_new '@i') ; IF (isfault symParnList_new) THEN symParnList_new := symParnList_old ; ELSEIF (= null (gage shape symParnList_new)) THEN symParnList_new := first symParnList_new ; ENDIF ; symParnList_new } # 08********08 #] 18Mar2019 It seems that I did a re-naming of operators as per : 01Dec2018 removed - because of new [strOfType_extract_exprs, strOfType_translate_symGenl] was : strOfType_extractFindTrans_exprs IS OP strOfType now : strOfType_extract_symGenls IS OP strOfType tblType strStdForm_extractTranslate_symGenl IS OP str_stdForm was : strOfType_trn_exprListsInnTrn IS OP strOfType exprList_inn exprList_trn now : strOfType_translate_symGenl IS OP strOfType ??? was : symParn_translate IS OP symParnList_old now : strOfType_translate_symGenl IS OP strOfType # 08********08 #] 20Mar2019 Run symbols [extract, translate] tests using new code # see setup.ndf : d_Qnial_mine d_Qnial_tests ' lq_symbBase - symbols [extraction,translation] system ' ' lq_symTests - tests of [strings, symbols [extraction,translation]] systems (loads lq_symBase) ' qnial> lq_symTests +---+ >>> loading start : symbols system loaddefs.ndf <<< loading ended : symbols system loaddefs.ndf >>> loading start : strings.ndf <<< loading ended : strings.ndf >>> loading start : symbols extract.ndf ?undefined identifier: GAGE SHAPE PARNSYMBLIST <***> ) RESHAPE 'parn' <<< loading ended : symbols extract.ndf errors found: 1 +---+ >> rest of output ignored - focus on : ?undefined identifier: GAGE SHAPE PARNSYMBLIST <***> ) RESHAPE 'parn' >> see "symbols extract- develop.txt" >> After trying a simple fix : qnial> lq_symTests +---+ >>> loading start : symbols system loaddefs.ndf <<< loading ended : symbols system loaddefs.ndf >>> loading start : strings.ndf <<< loading ended : strings.ndf >>> loading start : symbols extract.ndf <<< loading ended : symbols extract.ndf >>> loading start : symbols translate.ndf ?unexpected token or eol: 'Expr' ) ) <***> ) ; ?undefined identifier: TEXTOUT ( STROFTYPE_TRANSLATE_SYMGENL <***> TEXTNEW ) ; ?undefined identifier: LINE_IN := STRSTDFORM_EXTRACTTRANSLATE_SYMGENL <***> SYM_STDFORM STR ?undefined identifier: D_OUT ; FILE_TRANSLATE <***> l PNAME_OUT D_OUT <<< loading ended : symbols translate.ndf errors found: 4 +---+ >> rest of output ignored - focus on : ?unexpected token or eol: 'Expr' ) ) <***> ) ; >> in "symbols translate.ndf" : strOfType_translate_symGenl IS OP strOfType % find all [parnSymb,exprSymb] of trnType in strOfType, and their positions ; symb strt endd type tran := EACHBOTH link (strOfType_extract_symGenls EACHRIGHT (strOfType EACHRIGHT pair ('Parn' 'Expr'))) ; >> strOfType_extract_symGenls doesn't exist in "symbols extract.ndf"! >> strOfType_extract_symGenls is in "symbols translate.ndf" : +---+ # strOfType_extract_exprs IS OP strOfType - produces a list of expressions in strOfType strOfType_extract_symGenls IS OP strOfType tblType ... symbList posnStrt posnEndd typeList tranList } +---+ 11:43 # strOfType_extract_symGenls IS OP strOfType tblType - produces a list of expressions in strOfType >> this is dangerous with symbols?!!! >> was I only partially into modifying the ode, operator names]? (search above...) # enddoc