一、案例定位

Activity 2 使用 Excel PY() + Copilot 產生 Python code,從 AddressDescription 抽取 HouseMaterial、HouseLocation、OtherAddressDetails,再把 Python dynamic output 貼回 Raw table 作 values。

二、學習目標

三、案例情境

線索需要 house material、相對位置等結構資訊,但原資料只存在 free-text AddressDescription。

四、開始資料

Input Output
Raw!A1:Q21 保留全部原欄
AddressDescription HouseMaterial
AddressDescription HouseLocation
AddressDescription OtherAddressDetails

五、Excel/R/AI 分析方法

Copilot 生成 Pandas + re code:先用 regex 尋找如 stone/wooden 等 material,再抽取 near/above/below/behind 等 location phrase,其餘文字放 OtherAddressDetails。執行後將 Python Output 改成 Excel Value。

六、計算結果

Python 結果是 dynamic range,來源說明不能直接轉成 Excel table;作者複製 R1:T21,在 Raw sheet 的 R1 以 Paste Special → Values 貼回,最終新增三欄。

七、結果分析與管理解讀

Regex extraction 依賴事先列出的 patterns,因此沒有列入 pattern 的描述可能落入 Other,而不是代表「沒有資訊」。AI 生成的 regex 應用實際地址樣本測試 recall/precision。

八、AI 提問詞

請先列出你打算辨識的 material/location patterns,再用 5 筆不同 AddressDescription 測試。無法可靠分類的內容保留在 OtherAddressDetails,不要強迫套入已知類別。

九、思考/情境變動