169 lines
3.5 KiB
Plaintext
169 lines
3.5 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import hazm\n",
|
||
|
"import json\n",
|
||
|
"from pathlib import Path"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"this_dir_path = Path().resolve()\n",
|
||
|
"data_path = this_dir_path / \"Data\"\n",
|
||
|
"past_verb_path = data_path / \"verbs_past_PVC.json\"\n",
|
||
|
"present_verb_path = data_path / \"verbs_present_PVC.json\""
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 19,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"with open(past_verb_path, \"r\") as f:\n",
|
||
|
" past_verbs = json.load(f)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"conj = hazm.Conjugation()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"['آجیدم', 'آجیدی', 'آجید', 'آجیدیم', 'آجیدید', 'آجیدند']"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 23,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"conj.perfective_past(past_verbs[\"1\"])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"['نآجیدم', 'نآجیدی', 'نآجید', 'نآجیدیم', 'نآجیدید', 'نآجیدند']\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"['نیاجیدم', 'نیاجیدی', 'نیاجید', 'نیاجیدیم', 'نیاجیدید', 'نیاجیدند']"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 27,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(conj.negative_perfective_past(past_verbs[\"1\"]))\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"def negation(verb: str):\n",
|
||
|
" verb = verb.split()\n",
|
||
|
" if verb[-1].startswith(\"آ\"):\n",
|
||
|
" verb[-1] = \"نیا\" + verb[-1][1:]\n",
|
||
|
" else:\n",
|
||
|
" verb[-1] = \"ن\" + verb[-1]\n",
|
||
|
" verb = \" \".join(verb)\n",
|
||
|
" return verb\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"[negation(verb) for verb in conj.perfective_past(past_verbs[\"1\"])]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"['آجیده شدم',\n",
|
||
|
" 'آجیده شدی',\n",
|
||
|
" 'آجیده شد',\n",
|
||
|
" 'آجیده شدیم',\n",
|
||
|
" 'آجیده شدید',\n",
|
||
|
" 'آجیده شدند']"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 29,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"conj.passive_perfective_past(past_verbs[\"1\"])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 17,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# فعلهای متعدی میتوانند مجهول شوند"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": ".env",
|
||
|
"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.10.15"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2
|
||
|
}
|