Come è possibile automatizzare l'output da piattaforme che richiedono input da una finestra di dialogo modale?
Di seguito sono riportati due esempi. Il primo funziona quando si specificano tutte le opzioni nella finestra di dialogo.
Mi aspetterei che il secondo funzioni allo stesso modo se fosse possibile specificare tutte le opzioni. La mia ipotesi è che alcune opzioni non utilizzino i nomi o la sintassi corretti (purtroppo Jmp non fornisce alcuna informazione di debug). Vedi gli esempi sotto (funziona in Jmp 14 EA 7)...
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
//This Works when all options in Save Document Matrix are specified:
te=dt<<TEXT explorer=""></TEXT>
In generale, la finestra di dialogo Ricodifica non è programmabile tramite script. Ho trasmesso il tuo feedback al team di sviluppo di JMP affinché lo consideri in una versione futura di JMP.
Grazie per aver utilizzato JMP!
Grazie per la risposta, forse la distanza di Levenshtein tornerà utile un giorno.
Sto cercando un modo per automatizzare l'ultimo bit delle piattaforme tramite lo scripting in generale. Sono consapevole che non esiste documentazione per questo - o almeno non sono riuscito a trovarla - ma come vedi nel mio primo esempio, è possibile evitare la finestra di dialogo modale quando tutti i valori vengono forniti al momento della chiamata. Non sono sicuro che funzioni per tutte le finestre di dialogo, ma dal momento che ha funzionato per una, credo che ci siano buone possibilità che funzioni in generale. In caso contrario, chiedo agli sviluppatori di farlo funzionare, così possiamo evitare attività ripetitive e sfruttare tutto il potenziale delle piattaforme e dello scripting Jmp!
Sfortunatamente non c'è modo di far sparire le finestre di dialogo modali senza fare clic su di esse, a meno che la finestra non si chiuda da sola. In questo caso potresti scrivere tu stesso la ricodifica; la parte più difficile sarebbe trovare o scrivere una funzione di distanza stringa.
Lo script seguente potrebbe aiutarti ma non utilizzare questa funzione di distanza così com'è: è molto inefficiente!Una distanza di due parole con 5 caratteri è molta, ma puoi vedere che "JANE", "JAMES" e "JOE" diventano tutti "JANE".
Names default to here( 1 );
// FUNCTION TO CALCULATE DISTANCE BETWEEN STRINGS
//Rewrite of example C code from wikipedia:
//https://en.wikipedia.org/wiki/Levenshtein_distance
//very inefficient
// len_s and len_t are the number of characters in string s and t respectively
LevenshteinDistance_ = function({s, len_s, t, len_t},
// show(s || char(len_s) || t || char(len_t));
// base case: empty strings
if ( substr( s, 1, len_s ) == substr( t, 1, len_t ), 0, //strings match, distance is zero
len_s == 0, len_t, //s empty, distance is the length of t
len_t == 0, len_s, //t empty, distance is the length of s
// return minimum of delete char from s, delete char from t, and delete char from both
minimum(
LevenshteinDistance_(s, len_s - 1, t, len_t ) + 1,
LevenshteinDistance_(s, len_s , t, len_t - 1) + 1,
LevenshteinDistance_(s, len_s - 1, t, len_t - 1) +
if (substr(s, len_s, 1) == substr(t, len_t, 1), 0, 1) // test if last characters of the strings match
);
);
);
//Wrapper that finds strings lengths for you
LevenshteinDistance = function({s, t}, LevenshteinDistance_(s, length(s), t, length(t)));
// EXAMPLE
//data table
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "name recoded", Character, "Nominal" );
//replace names with the first name in the table having a Levenshtein
//distance of two or less when compared to that value
for( i = 1, i <= min(15, N Rows( dt )), i++, //for each row in the table
//if row one always use that value
Column( dt, "name recoded")[i] = if( i == 0, Column( dt, "name")[i], <BR />
newvalue = Column(dt, "name")[i]; //assume you will use this rows' value<BR />
match = 0; //flag indicating that a match is found
for( j = 1, j < i & match == 0, j++, //look at all previous rows to find a match
//if a match use the previous row value and stop looking for more matches
if( LevenshteinDistance( Column(dt, "name")[i], Column(dt, "name")[j] ) <= 2,
newvalue = Column(dt, "name")[j];
match = 1;
)
);
newvalue;
);
);