我想在 Google Refine 中使用 GREL(或其他任何东西)的单个函数搜索和替换列中的多个值。
例如:
1. replace(value, "Buch", "bibo:Book")
2. replace(value, "Zeitschrift", "bibo:Journal")
3. replace(value, "Patent", "bibo:Patent" )
4. 还有更多。
有没有办法用一个 GREL 表达式来做到这一点?
我想在 Google Refine 中使用 GREL(或其他任何东西)的单个函数搜索和替换列中的多个值。
例如:
1. replace(value, "Buch", "bibo:Book")
2. replace(value, "Zeitschrift", "bibo:Journal")
3. replace(value, "Patent", "bibo:Patent" )
4. 还有更多。
有没有办法用一个 GREL 表达式来做到这一点?
对于前三个,您可以执行以下操作:
value.replace("Buch", "bibo:Book").replace("Zeitschrift", "bibo:Journal").replace("Patent", "bibo:Patent")
根据您的“更多”的数量,该模式可能就足够了。否则,您可以研究某种类型的表查找(在 Python 中这可能比 GREL 更容易——只需选择 Jython 作为您的表达式语言)。
要在单个 GREL 行中执行此操作:
replace(value,/(.+)/,"bibo:$1")
我用它来用逗号重新格式化一列数字字符串:
1,317
2,000
1,055
GREL 表达式
replace(value,/(\d),(\d)/,"$1$2")
返回
1317 2000 1055
然后我可以将其用作数字。