如何能夠自動化需要從模式對話框輸入的平台的輸出?
下面是兩個例子。第一個在指定對話方塊中的所有選項時有效。
如果可以指定所有選項,我希望第二個以相同的方式工作。我的猜測是某些選項沒有使用正確的名稱或語法(不幸的是,Jmp 不提供任何調試資訊)。請參閱下面的範例(適用於 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>
通常,“重新編碼”對話框不可編寫腳本。 我已將您的反饋傳遞給 JMP 開發團隊,以供在 JMP 的未來版本中考慮。
感謝您使用 JMP!
謝謝你的回复——也許有一天 Levenshtein 距離會派上用場。
我正在尋找一種通過一般腳本來自動化平台最後一點的方法。 我知道沒有這方面的文檔 - 或者至少我找不到它 - 但正如您在我的第一個示例中看到的,當在調用時提供所有值時,可以避免模式對話框。 我不確定它是否適用於所有對話框,但由於它適用於一個對話框,我相信這很有可能一般都有效。 否則,我懇請開發人員完成這項工作,這樣我們就可以避免重複性任務並充分發揮平台和 Jmp 腳本的潛力!
不幸的是,沒有辦法讓模態對話框在不單擊它們的情況下消失,除非該框自行關閉。 在這種情況下,您可以自己編寫重新編碼腳本;最困難的部分是查找或編寫字符串距離函數。
下面的腳本可能會幫助您入門,但不要按原樣使用此距離函數:它的效率非常低!5 個字符的單詞之間的距離很大,但您可以看到“JANE”、“JAMES”和“JOE”都變成了“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;
);
);