Skip to content

Instantly share code, notes, and snippets.

@taroushirani
Last active May 15, 2020 08:37
Show Gist options
  • Save taroushirani/16bc581ab737ccc4ede80feb94c81620 to your computer and use it in GitHub Desktop.
Save taroushirani/16bc581ab737ccc4ede80feb94c81620 to your computer and use it in GitHub Desktop.
Untitled2.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Untitled2.ipynb",
"provenance": [],
"mount_file_id": "1K34g79y88zabgPxkAgkClmJBJRO08tnn",
"authorship_tag": "ABX9TyPtnPj5K3Q+l7r+3fblFN50",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/taroushirani/16bc581ab737ccc4ede80feb94c81620/untitled2.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "3TvuPDb3Ug-o",
"colab_type": "code",
"outputId": "09c59b8d-dfdc-4e9b-bc32-8a603fca138c",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 258
}
},
"source": [
"!pip install nnmnkwii"
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"Requirement already satisfied: nnmnkwii in /usr/local/lib/python3.6/dist-packages (0.0.20)\n",
"Requirement already satisfied: scipy in /usr/local/lib/python3.6/dist-packages (from nnmnkwii) (1.4.1)\n",
"Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (from nnmnkwii) (4.41.1)\n",
"Requirement already satisfied: bandmat>=0.7 in /usr/local/lib/python3.6/dist-packages (from nnmnkwii) (0.7)\n",
"Requirement already satisfied: cython>=0.28.0 in /usr/local/lib/python3.6/dist-packages (from nnmnkwii) (0.29.17)\n",
"Requirement already satisfied: fastdtw in /usr/local/lib/python3.6/dist-packages (from nnmnkwii) (0.3.4)\n",
"Requirement already satisfied: pysptk>=0.1.17 in /usr/local/lib/python3.6/dist-packages (from nnmnkwii) (0.1.18)\n",
"Requirement already satisfied: sklearn in /usr/local/lib/python3.6/dist-packages (from nnmnkwii) (0.0)\n",
"Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.6/dist-packages (from scipy->nnmnkwii) (1.18.4)\n",
"Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from pysptk>=0.1.17->nnmnkwii) (1.12.0)\n",
"Requirement already satisfied: decorator in /usr/local/lib/python3.6/dist-packages (from pysptk>=0.1.17->nnmnkwii) (4.4.2)\n",
"Requirement already satisfied: scikit-learn in /usr/local/lib/python3.6/dist-packages (from sklearn->nnmnkwii) (0.22.2.post1)\n",
"Requirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.6/dist-packages (from scikit-learn->sklearn->nnmnkwii) (0.14.1)\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "Nhj186LhUnEY",
"colab_type": "code",
"colab": {}
},
"source": [
"from nnmnkwii.io import hts"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "4Rk55bPYU7F5",
"colab_type": "code",
"colab": {}
},
"source": [
"binary_dict, continuous_dict = hts.load_question_set(\"/content/drive/My Drive/nnmnkwii_gallery/data/questions_jp.hed\")\n"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "5FXG4WICVS6m",
"colab_type": "code",
"outputId": "9a015f2e-6426-445e-f4e8-cbbc98b0d5bf",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
}
},
"source": [
"k2_re = continuous_dict[len(continuous_dict)-2]\n",
"k3_re = continuous_dict[len(continuous_dict)-1]\n",
"print(k2_re, k3_re)"
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"re.compile('\\\\+(\\\\d+)\\\\-') re.compile('\\\\-(\\\\d+)\\\\\\\\\\\\$')\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "uTMBOVljVnZX",
"colab_type": "code",
"outputId": "e0f4494f-0e1b-477e-9c41-e8eeb1aa0d59",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 105
}
},
"source": [
"import re\n",
"with open(\"/content/drive/My Drive/nnmnkwii_gallery/data/NIT-ATR503/label_phone_align/nitech_jp_atr503_m001_a01.lab\", 'r') as f:\n",
" line = f.readline()\n",
" print(line)\n",
" matched = k2_re.search(line)\n",
" print(matched)\n",
" matched = k3_re.search(line)\n",
" print(matched)"
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"0 3900000 xx^xx-sil+a=r/A:xx+xx+xx/B:xx-xx_xx/C:xx_xx+xx/D:07+xx_xx/E:xx_xx!xx_xx-xx/F:xx_xx#xx_xx@xx_xx|xx_xx/G:4_3%0_xx_xx/H:xx_xx/I:xx-xx@xx+xx&xx-xx|xx+xx/J:2_9/K:2+5-26\n",
"\n",
"<_sre.SRE_Match object; span=(168, 171), match='+5-'>\n",
"None\n"
],
"name": "stdout"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment