{
"cells": [
{
"cell_type": "markdown",
"id": "d06f1e82-1895-4e3e-b88d-b67f857ddb56",
"metadata": {},
"source": [
"# Test/create feature 'unaccented' and 'transliteration'"
]
},
{
"cell_type": "markdown",
"id": "c692f7e1-df4f-43bf-b80f-0b0e4fa1e329",
"metadata": {},
"source": [
"## Table of content \n",
"* 1 - test]\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "ebc96637-30a9-4561-9c46-44f60330804a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"en arkhe en o logos, kai o logos en pros ton theon, kai theos en o logos.\n",
"εν αρχη ην ο λογος, και ο λογος ην προς τον θεον, και θεος ην ο λογος.\n"
]
}
],
"source": [
"import os\n",
"from unidecode import unidecode\n",
"import unicodedata\n",
"\n",
"# Following variable should contain the relative path to the tf file to read \n",
"# FileToRead = \"..//tf//0.4//word.tf\"\n",
"\n",
"def make_transliteration(text):\n",
" return unidecode(text)\n",
"\n",
"\n",
"def remove_accents(text):\n",
" return ''.join(c for c in unicodedata.normalize('NFD', text) if unicodedata.category(c) != 'Mn')\n",
"\n",
"greek_text_with_accents = \"ἐν ἀρχῇ ἦν ὁ λόγος, καὶ ὁ λόγος ἦν πρὸς τὸν θεόν, καὶ θεὸς ἦν ὁ λόγος.\"\n",
"transliterated_text = make_transliteration(greek_text_with_accents)\n",
"unaccented_text= remove_accents(greek_text_with_accents)\n",
"\n",
"print(transliterated_text) \n",
"print(unaccented_text)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3c7357a9-5de4-4a66-ae41-00273a573f5c",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}