Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Searching and replacing multiple values in Google Refine

I'd like to search and replace multiple values in a column with a single function with GREL (or anything other) in Google Refine.

For example:
1. replace(value, "Buch", "bibo:Book")
2. replace(value, "Zeitschrift", "bibo:Journal")
3. replace(value, "Patent", "bibo:Patent")
4. and many more.

Is there a way to do this with one GREL expression?

like image 467
CH_ Avatar asked Feb 25 '14 12:02

CH_


1 Answers

For your first three, you can do:

value.replace("Buch", "bibo:Book").replace("Zeitschrift", "bibo:Journal").replace("Patent", "bibo:Patent")

Depending how many your "many more" is, that pattern may suffice. Otherwise you could investigate some type of table lookup (which might be easier in Python than GREL - just choose Jython for your expression language).

like image 74
Tom Morris Avatar answered Sep 28 '22 00:09

Tom Morris