Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation: Library Carpentry OpenRefine Episode 11 #166

Open
joelnitta opened this issue Aug 5, 2021 · 0 comments
Open

Translation: Library Carpentry OpenRefine Episode 11 #166

joelnitta opened this issue Aug 5, 2021 · 0 comments

Comments

@joelnitta
Copy link
Member

Translation: Library Carpentry OpenRefine Episode 11

Original lesson: https://librarycarpentry.org/lc-open-refine/11-using-arrays-transformations/index.html


  • PO fileの編集についてはREADMEをご参照ください
  • あなたが翻訳し始めたと分かるように、翻訳を始める前にこのイシューを自分に割り振って(assign)、あるいはコメントを書いて下さい。
  • 翻訳が終わったら、プルリクエストを開いて、このイシューを参照・リンクして下さい。

i18n/po/lc-open-refine.ja.po

Lines 1659 to 1762 in bb59a56

#: lc-open-refine/_episodes/11-using-arrays-transformations.md:1
# Front Matter
msgid "---\n"
"title: \"Transformations - Handling Arrays\"\n"
"teaching: 5\n"
"exercises: 15\n"
"questions:\n"
"- \"How do I use Arrays in data transformation?\"\n"
"objectives:\n"
"- \"Understand the purpose of Arrays in OpenRefine\"\n"
"- \"Use arrays as part of transformations in GREL\"\n"
"keypoints:\n"
"- \"Arrays cannot appear directly in an OpenRefine cell\"\n"
"- \"Arrays can be used in many ways using GREL expressions\"\n"
"---"
msgstr ""
#: lc-open-refine/_episodes/11-using-arrays-transformations.md:15
# header
msgid "## Arrays"
msgstr ""
#: lc-open-refine/_episodes/11-using-arrays-transformations.md:16
msgid "An 'Array' is a list of values, represented in Refine by the use of square brackets containing a list of values surrounded by inverted commas and separated by commas. For example an array listing the days of the week would look like:"
msgstr ""
#: lc-open-refine/_episodes/11-using-arrays-transformations.md:18
#: lc-open-refine/_episodes/11-using-arrays-transformations.md:30
msgid "[\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\",\"Sunday\"]"
msgstr ""
#: lc-open-refine/_episodes/11-using-arrays-transformations.md:20
msgid "Arrays can be sorted, de-duplicated, and manipulated in other ways in GREL expressions, but cannot appear directly in an OpenRefine cell. Arrays in OpenRefine are usually the result of a transformation. For example the ```split``` function takes a string, and changes it into an array based on a 'separator'. For example if a cell has the value:"
msgstr ""
#: lc-open-refine/_episodes/11-using-arrays-transformations.md:22
msgid "\"Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday\""
msgstr ""
#: lc-open-refine/_episodes/11-using-arrays-transformations.md:24
msgid "This can be transformed into an array using the ```split``` function\n"
"```\n"
"value.split(\",\")\n"
"```\n"
"This would create the array containing the days of the week:"
msgstr ""
#: lc-open-refine/_episodes/11-using-arrays-transformations.md:32
msgid "This can be combined with array operations like ```sort```. For example, assuming the cell contains the same value as above, then the function\n"
"```\n"
"value.split(\",\").sort()\n"
"```\n"
"would result in an array containing the days of the week sorted in alphabetical order:"
msgstr ""
#: lc-open-refine/_episodes/11-using-arrays-transformations.md:38
msgid "[\"Friday\",\"Monday\",\"Saturday\",\"Sunday\",\"Thursday\",\"Tuesday\",\"Wednesday\"]"
msgstr ""
#: lc-open-refine/_episodes/11-using-arrays-transformations.md:40
msgid "To output a value from an array you can either select a specific value depending on its position in the list (with the first position treated as 'zero'). For example\n"
"```\n"
"value.split(\",\")[0]\n"
"```\n"
"would extract the first value from the array created by the ```split``` function. In the above example this would be \"Monday\""
msgstr ""
#: lc-open-refine/_episodes/11-using-arrays-transformations.md:46
msgid "You can also join arrays together to make a 'String'. The GREL expression would look like\n"
"```\n"
"value.split(\",\").sort().join(\",\")\n"
"```\n"
"Taking the above example again, this would result in a string with the days of the week in alphabetical order, listed with commas between each day."
msgstr ""
#: lc-open-refine/_episodes/11-using-arrays-transformations.md:52
msgid ">## Reverse author names\n"
">You may already have done the boolean exercise and have a facet containing the names in natural order. In this case, select the 'true' facet and start with the step **\"1. On the ```Authors``` column use...\"**\n"
">\n"
">In this exercise we are going to use both the Boolean and Array data types.\n"
">If you look at the Authors column, you can see that most of the author names are written in the natural order. However, a few have been reversed to put the family name first.\n"
">\n"
">We can do a crude test for reversed author names by looking for those that contain a comma:\n"
">\n"
">1. Make sure you have already split the author names into individual cells using ```Edit cells->Split multi-valued cells``` (you should have done this in the Clustering lesson)\n"
">2. On the Authors column, use the dropdown menu and select ```Facet->Custom text facet...```\n"
">3. The ```Custom text``` facet function allows you to write GREL functions to create a facet\n"
">4. In the Expression box type ```value.contains(\",\").toString()```\n"
">5. Click ```OK```\n"
">6. Since the ```contains``` function outputs a Boolean value, you should see a facet that contains 'false' and 'true'. These represent the outcome of the expression, i.e. true = values containing a comma; false = values not containing a comma\n"
">7. In this facet select 'true' to narrow down to the author names that contain a comma\n"
">\n"
">Now we have narrowed down to the lines with a comma in a name, we can use the ```match``` function. The match function allows you to use regular expressions, and output the capture groups as an array, which you can then manipulate.\n"
">\n"
">1. On the ```Authors``` column use the dropdown menu and select ```Edit cells->Transform ```\n"
">2. In the Expression box type ```value.match(/(.*),(.*)/)``` The ```/```, means you are using a regular expression inside a GREL expression. The parentheses indicate you are going to match a group of characters. The ```.*``` expression will match any character(s) appearing 0, 1 or more times. So here we are matching any number of characters, a comma, and another set of any number of characters.\n"
">3. See how this creates an array with two members in each row in the Preview column\n"
">\n"
">To get the author name in the natural order you can reverse the array and join it back together with a space to create the string you need:\n"
">\n"
">1. In the Expression box, add to the existing expression until it reads ```value.match(/(.*),(.*)/).reverse().join(\" \")```\n"
">2. In the Preview view you should be able see this has reversed the array, and joined it back into a string\n"
">* Click ```OK```"
msgstr ""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant