From c6a4cb754e3f61806e676d91b5efe9e9d342bf7f Mon Sep 17 00:00:00 2001 From: wojciechbatruszewicz Date: Fri, 31 Mar 2023 19:23:16 +0200 Subject: [PATCH] Mockups nlu --- SDMockup.ipynb | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/SDMockup.ipynb b/SDMockup.ipynb index e69de29..cfe656c 100644 --- a/SDMockup.ipynb +++ b/SDMockup.ipynb @@ -0,0 +1,100 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# ASR" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "def asr(inputText: str) -> str:\n", + " # Do something\n", + " inputText\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# NLU" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [], + "source": [ + "class Nlu:\n", + " def __init__(self, text: str):\n", + " self.text = text\n", + " self.slot = []\n", + " \n", + " def get_dialog_act(self):\n", + " act = \"question\" if \"?\" in self.text else \"\"\n", + " if \"imię\" in self.text:\n", + " self.slot.append((\"o_co\", \"imie\"))\n", + " return {\"act\": act, \"slot\": self.slot }\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'act': 'question', 'slot': [('o_co', 'imie')]}" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "nlu = Nlu(\"Jak masz na imię?\")\n", + "nlu.get_dialog_act()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SDenv", + "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.9" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +}