亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

字符串匹配算法中的引用錯誤

字符串匹配算法中的引用錯誤

慕娘9325324 2022-12-02 17:05:31
我為兩個字符串列之間的字符串匹配百分比 (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]我錯過了什么嗎?
查看完整描述

1 回答

?
四季花海

TA貢獻1811條經驗 獲得超5個贊

它給我以下錯誤

查詢錯誤:ReferenceError: in_a is not defined at UDF$1(STRING, STRING) line 9, columns 8-9 at [52:1]
我錯過了什么嗎?

您至少應該修復第一個函數的簽名,如下所示

CREATE OR REPLACE FUNCTION `rep-ds-us.nboorla.similarity`(in_a STRING, in_b STRING) RETURNS INT64 LANGUAGE js AS """

筆記; 以上回答了您當前的具體問題,可能無法解決與您使用的代碼相關的任何未來問題。


查看完整回答
反對 回復 2022-12-02
  • 1 回答
  • 0 關注
  • 85 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號