我為兩個字符串列之間的字符串匹配百分比 (0-1) 創建了 UDF,當我執行以下查詢時遇到此錯誤。我想執行此代碼以獲取名稱匹配算法以顯示概率算法從 0- 1 值。我創建了兩個函數并在此函數中定義了兩個字符串列。CREATE OR REPLACE FUNCTION `rep-ds-us.nboorla.similarity`(name STRING, to_name STRING) RETURNS INT64 LANGUAGE js AS """/* * Data Quality Function - Fuzzy Matching * dq_fm_LevenshteinDistance * Based off of https://gist.github.com/andrei-m/982927 * input: Two strings to compare the edit distance of. * returns: Integer of the edit distance. */var a = in_a.toLowerCase();var b = in_b.toLowerCase(); if(a.length == 0) return b.length; if(b.length == 0) return a.length;var matrix = [];// increment along the first column of each rowvar i;for(i = 0; i <= b.length; i++){ matrix[i] = [i];}// increment each column in the first rowvar j;for(j = 0; j <= a.length; j++){ matrix[0][j] = j;}// Fill in the rest of the matrixfor(i = 1; i <= b.length; i++){ for(j = 1; j <= a.length; j++){ if(b.charAt(i-1) == a.charAt(j-1)){ matrix[i][j] = matrix[i-1][j-1]; } else { matrix[i][j] = Math.min(matrix[i-1][j-1] + 1, // substitution Math.min(matrix[i][j-1] + 1, // insertion matrix[i-1][j] + 1)); // deletion } }}return matrix[b.length][a.length];""";CREATE OR REPLACE FUNCTION `rep-ds-us.nboorla.conf`(name STRING, to_name STRING) AS (/* * Data Quality Function - Fuzzy Matching * dq_fm_ldist_ratio * input: Two strings to compare. * returns: The Levenshtein similarity ratio. */(LENGTH(name) + LENGTH(to_name) - `rep-ds-us.nboorla.similarity`(name, to_name)) / (LENGTH(name) + LENGTH(to_name)));select t1.name,t2.to_name,`rep-ds-us.nboorla.conf`(t1.name,t2.to_name)from `rep-ds-us.r4e_mongo.ratings` t1 JOIN `rep-ds-us.r4e_mongo.mongo_repbiz_request_reviews` t2 on t2.id=t1.id limit 10但它給了我以下錯誤Query error: ReferenceError: in_a is not defined at UDF$1(STRING, STRING) line 9, columns 8-9 at [52:1]我錯過了什么嗎?
字符串匹配算法中的引用錯誤
慕娘9325324
2022-12-02 17:05:31