Last active
June 4, 2017 05:55
-
-
Save dan-zheng/c540928da85f6dbc43d7b5324ec64010 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "// Turby: data augmentation for text\nimport com.digitalreasoning.tda.*\n\n// Sample coreference texts\n// From: https://en.wikipedia.org/wiki/Coreference#Types_of_coreference\nval texts: List<String> = listOf(\n \"Every farmer who owns a donkey beats it.\",\n \"Every police officer who arrested a murderer insulted him.\"\n)\n\n// Initialize and configure coreference perturber\nval coreferencePerturber = CoreferencePerturber\ncoreferencePerturber.verbose = true\n\n// Get perturbations\ntexts.forEachIndexed { index, text ->\n println(\"Example ${index + 1}:\")\n val perturbations = coreferencePerturber.perturb(text)\n println()\n}", | |
"execution_count": 1, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "Example 1:\n\nOriginal sentences:\n(0): `Every farmer who owns a donkey beats it.`\n\nCoreference chains:\nCHAIN0-[\"Every farmer who owns a donkey\" in sentence 1]\nCHAIN2-[\"a donkey\" in sentence 1, \"it\" in sentence 1]\n\nPerturbed sentences:\nStrategy: transform mentions to representative mention\n(0): `Every farmer who owns a donkey beats a donkey.`\nStrategy: transform mentions to pronominal form\n(0): `He beats it.`\n(0): `Every farmer who owns it beats it.`\n\nExample 2:\n\nOriginal sentences:\n(0): `Every police officer who arrested a murderer insulted him.`\n\nCoreference chains:\nCHAIN0-[\"Every police officer who arrested a murderer\" in sentence 1]\nCHAIN2-[\"a murderer\" in sentence 1, \"him\" in sentence 1]\n\nPerturbed sentences:\nStrategy: transform mentions to representative mention\n(0): `Every police officer who arrested a murderer insulted a murderer.`\nStrategy: transform mentions to pronominal form\n(0): `He insulted him.`\n(0): `Every police officer who arrested him insulted him.`\n\n", | |
"name": "stdout" | |
} | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"name": "kotlin", | |
"display_name": "Kotlin", | |
"language": "kotlin" | |
}, | |
"language_info": { | |
"file_extension": "kt", | |
"name": "kotlin" | |
}, | |
"gist_id": "c540928da85f6dbc43d7b5324ec64010" | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment