Activity 2 使用 Excel PY() + Copilot 產生 Python code,從 AddressDescription 抽取 HouseMaterial、HouseLocation、OtherAddressDetails,再把 Python dynamic output 貼回 Raw table 作 values。
xl("Raw!A1:Q21", headers=True) 讀表。線索需要 house material、相對位置等結構資訊,但原資料只存在 free-text AddressDescription。
| Input | Output |
|---|---|
Raw!A1:Q21 |
保留全部原欄 |
AddressDescription |
HouseMaterial |
AddressDescription |
HouseLocation |
AddressDescription |
OtherAddressDetails |
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。
請先列出你打算辨識的 material/location patterns,再用 5 筆不同 AddressDescription 測試。無法可靠分類的內容保留在 OtherAddressDetails,不要強迫套入已知類別。