Compare commits
No commits in common. "8752b6225ce75a5cd5f87404f29105dbc874b91a" and "600536794db347c29e86e2c865d6936c95d2d414" have entirely different histories.
8752b6225c
...
600536794d
|
@ -12,7 +12,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 5,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
|
@ -20,10 +20,7 @@
|
||||||
"data_path = this_dir_path / \"Data\"\n",
|
"data_path = this_dir_path / \"Data\"\n",
|
||||||
"verb_path = data_path / \"PVC\" / \"Data\" / \"TXT\" / \"verb.txt\"\n",
|
"verb_path = data_path / \"PVC\" / \"Data\" / \"TXT\" / \"verb.txt\"\n",
|
||||||
"processed_past_verb_path = data_path / \"verbs_past_PVC.json\"\n",
|
"processed_past_verb_path = data_path / \"verbs_past_PVC.json\"\n",
|
||||||
"processed_present_verb_path = data_path / \"verbs_present_PVC.json\"\n",
|
"processed_present_verb_path = data_path / \"verbs_present_PVC.json\""
|
||||||
"\n",
|
|
||||||
"# You can download the PVC data from https://www.peykaregan.ir/dataset/%D9%85%D8%AC%D9%85%D9%88%D8%B9%D9%87-%D8%A7%D9%81%D8%B9%D8%A7%D9%84-%D8%AA%D8%B5%D8%B1%DB%8C%D9%81%E2%80%8C%D8%B4%D8%AF%D9%87-%D9%81%D8%A7%D8%B1%D8%B3%DB%8C\n",
|
|
||||||
"# After downloading, unzip the data and place it in a directory called Data."
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,20 +2,19 @@
|
||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 39,
|
"execution_count": 7,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import requests\n",
|
"import requests\n",
|
||||||
"from bs4 import BeautifulSoup\n",
|
"from bs4 import BeautifulSoup\n",
|
||||||
"from pathlib import Path\n",
|
"from pathlib import Path\n",
|
||||||
"from tqdm import tqdm\n",
|
"from tqdm import tqdm"
|
||||||
"import json"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 3,
|
"execution_count": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
|
@ -28,7 +27,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 4,
|
"execution_count": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
|
@ -58,19 +57,19 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 16,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"name": "stderr",
|
"name": "stderr",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"100%|██████████| 4167/4167 [00:33<00:00, 122.76it/s]\n"
|
"100%|██████████| 4167/4167 [00:22<00:00, 186.02it/s]\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"results = []\n",
|
"result = {}\n",
|
||||||
"\n",
|
"\n",
|
||||||
"for verb in tqdm(verbs):\n",
|
"for verb in tqdm(verbs):\n",
|
||||||
" with open(htmls_path / (verb + \".html\"), \"r\") as f:\n",
|
" with open(htmls_path / (verb + \".html\"), \"r\") as f:\n",
|
||||||
|
@ -81,27 +80,10 @@
|
||||||
" past_stem = stems[0].text\n",
|
" past_stem = stems[0].text\n",
|
||||||
" present_stem = stems[1].text\n",
|
" present_stem = stems[1].text\n",
|
||||||
"\n",
|
"\n",
|
||||||
" structures = soup.select(\"div.section-wrapper.more-examples\")\n",
|
" result[verb] = {}\n",
|
||||||
" for structure in structures:\n",
|
"\n",
|
||||||
" examples = structure.findAll(\"div\", {\"class\": \"example\"})\n",
|
" result[verb][\"past_stem\"] = past_stem\n",
|
||||||
" for example in examples:\n",
|
" result[verb][\"present_stem\"] = present_stem"
|
||||||
" result = {}\n",
|
|
||||||
" result[\"verb\"] = verb\n",
|
|
||||||
" result[\"past_stem\"] = past_stem\n",
|
|
||||||
" result[\"present_stem\"] = present_stem\n",
|
|
||||||
" result[\"structure\"] = str(structure.findAll(\"div\", {\"class\": \"valency\"})[0])\n",
|
|
||||||
" result[\"text\"] = example.text\n",
|
|
||||||
" results.append(result)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 59,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"with open(output_verb_path, \"w\", encoding=\"utf-8\") as f:\n",
|
|
||||||
" json.dump(results, f, ensure_ascii=False, indent=4)"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user