{ "cells": [ { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of Cantonese sentences: 58492\n" ] } ], "source": [ "can_sents = []\n", "\n", "with open(\"../train/common_voice.can\", \"r\") as common_voice_file, open(\"../train/wordshk.can\", \"r\") as wordshk_file,\\\n", " open(\"../train/novels.can\", \"r\") as novels_file,\\\n", " open(\"../train/abc.can\", \"r\") as abc_file:\n", " lines = common_voice_file.read().splitlines() + wordshk_file.read().splitlines() + novels_file.read().splitlines() + abc_file.read().splitlines()\n", " for line in lines:\n", " if len(line) >= 5:\n", " can_sents.append(line)\n", "\n", "print(\"Number of Cantonese sentences: \", len(can_sents))\n", "\n", "with open(\"bing.can\", \"w\") as f:\n", " for sent in can_sents:\n", " f.write(sent + \"\\n\")\n", " f.flush()\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.6" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }