Skip to content

Instantly share code, notes, and snippets.

@xiaoouwang
Last active November 10, 2021 13:18
Show Gist options
  • Save xiaoouwang/5345dc0290bf90f5702e9e660a97eaca to your computer and use it in GitHub Desktop.
Save xiaoouwang/5345dc0290bf90f5702e9e660a97eaca to your computer and use it in GitHub Desktop.
error_statistics.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"trusted": true,
"ExecuteTime": {
"start_time": "2021-11-10T13:04:38.577055Z",
"end_time": "2021-11-10T13:04:42.387554Z"
}
},
"cell_type": "code",
"source": "# example of french\n\nimport language_tool_python\n\ntool = language_tool_python.LanguageTool('fr') #\n\ndef log_errors(obj):\n for error in obj:\n print(\"The potential error span is:\")\n print({text[error.offset:(error.offset+error.errorLength)]})\n print(f\"The error category is {error.category}\")",
"execution_count": 1,
"outputs": []
},
{
"metadata": {
"trusted": true,
"ExecuteTime": {
"start_time": "2021-11-10T13:17:56.513778Z",
"end_time": "2021-11-10T13:17:56.728444Z"
}
},
"cell_type": "code",
"source": "text = 'c\\'est incroyale et ce son de joli filles.'\nmatches = tool.check(text)\n\nprint(f\"the original sentence is \\n{text}\\n\\n\")\nprint(f\"the proposed sentence correction is \\n{tool.correct(text)}\\n\\n\\n\")\n\nlog_errors(matches)\n \nprint(f\"\\n\\n\\nThe total number of errors is {len(matches)}\")",
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"text": "the original sentence is \nc'est incroyale et ce son de joli filles.\n\n\nthe proposed sentence correction is \nC'est incroyable et ce son de jolies filles.\n\n\n\nThe potential error span is:\n{\"c'\"}\nThe error category is CASING\nThe potential error span is:\n{'incroyale'}\nThe error category is TYPOS\nThe potential error span is:\n{'joli filles'}\nThe error category is AGREEMENT\n\n\n\nThe total number of errors is 3\n",
"name": "stdout"
}
]
}
],
"metadata": {
"interpreter": {
"hash": "40d3a090f54c6569ab1632332b64b2c03c39dcf918b08424e98f38b5ae0af88f"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.7.6",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"varInspector": {
"window_display": false,
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"library": "var_list.py",
"delete_cmd_prefix": "del ",
"delete_cmd_postfix": "",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"library": "var_list.r",
"delete_cmd_prefix": "rm(",
"delete_cmd_postfix": ") ",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
]
},
"toc": {
"nav_menu": {},
"number_sections": true,
"sideBar": false,
"skip_h1_title": true,
"base_numbering": 1,
"title_cell": "Table des matières",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
},
"nbTranslate": {
"hotkey": "alt-t",
"sourceLang": "en",
"targetLang": "fr",
"displayLangs": [
"*"
],
"langInMainMenu": true,
"useGoogleTranslate": true
},
"gist": {
"id": "5345dc0290bf90f5702e9e660a97eaca",
"data": {
"description": "error_statistics.ipynb",
"public": true
}
},
"_draft": {
"nbviewer_url": "https://gist.github.com/5345dc0290bf90f5702e9e660a97eaca"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment