{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Extract general Malaya entities" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "This tutorial is available as an IPython notebook at [Malaya/example/general-malaya-entities](https://github.com/huseinzol05/Malaya/tree/master/example/general-malaya-entities).\n", " \n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "This module only use Regex to extract entities.\n", " \n", "
" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import logging\n", "\n", "logging.basicConfig(level=logging.INFO)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO:torch.distributed.nn.jit.instantiator:Created a temporary directory at /tmp/tmppjdv8tfx\n", "INFO:torch.distributed.nn.jit.instantiator:Writing /tmp/tmppjdv8tfx/_remote_module_non_scriptable.py\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 2.91 s, sys: 3.7 s, total: 6.61 s\n", "Wall time: 2.13 s\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/home/husein/dev/malaya/malaya/tokenizer.py:214: FutureWarning: Possible nested set at position 3397\n", " self.tok = re.compile(r'({})'.format('|'.join(pipeline)))\n", "/home/husein/dev/malaya/malaya/tokenizer.py:214: FutureWarning: Possible nested set at position 3927\n", " self.tok = re.compile(r'({})'.format('|'.join(pipeline)))\n" ] } ], "source": [ "%%time\n", "import malaya" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load general Malaya entity model\n", "\n", "This model able to classify,\n", "\n", "1. date\n", "2. money\n", "3. temperature\n", "4. distance\n", "5. volume\n", "6. duration\n", "7. phone\n", "8. email\n", "9. url\n", "10. time\n", "11. datetime\n", "12. local and generic foods, can check available rules in `malaya.texts.entity.food`\n", "13. local and generic drinks, can check available rules in `malaya.texts.entity.food`\n", "\n", "We can insert BERT or any deep learning model by passing `malaya.entity.general_entity(model = model)`, as long the model has `predict` method and return `[(string, label), (string, label)]`. This is an optional." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "entity = malaya.entity.general_entity()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Examples" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {'2 oktober 2019': datetime.datetime(2019, 10, 2, 0, 0),\n", " 'minggu lalu': datetime.datetime(2023, 10, 5, 15, 43, 46, 99837)},\n", " 'money': {'3k ringgit': 'RM3000.0'},\n", " 'temperature': ['32 celcius'],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {'2 PM': datetime.datetime(2023, 10, 12, 14, 0)},\n", " 'datetime': {'2 ptg 2 oktober 2019': datetime.datetime(2019, 10, 2, 14, 0)},\n", " 'food': ['ayam goreng'],\n", " 'drink': ['milo o ais'],\n", " 'weight': []}" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('Husein baca buku Perlembagaan yang berharga 3k ringgit dekat kfc sungai petani minggu lepas, 2 ptg 2 oktober 2019 , suhu 32 celcius, sambil makan ayam goreng dan milo o ais')" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': ['husein.zol05@gmail.com'],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('contact Husein at husein.zol05@gmail.com')" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "{'date': {'esok': datetime.datetime(2023, 10, 13, 15, 43, 46, 144429)},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': ['nasi dagang'],\n", " 'drink': ['milo tarik', 'jus apple'],\n", " 'weight': []}" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('tolong tempahkan meja makan makan nasi dagang dan jus apple, milo tarik esok dekat Restoran Sebulek')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### date" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {'2/12/2022': datetime.datetime(2022, 2, 12, 0, 0)},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('husein balik rumah pada 2/12/2022')" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {'2 jan 2022': datetime.datetime(2022, 1, 2, 0, 0)},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('husein balik rumah pada 2 jan 2022')" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {'2022 mac 2': datetime.datetime(2022, 3, 2, 0, 0)},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('husein balik rumah pada 2022 mac 2')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### money" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {'2 ringgit': 'RM2'},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('harga buku 2 ringgit')" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {'rm2.50 ': 'RM2.50'},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('harga buku rm2.50 sen')" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {'5.34k ringgit': 'RM5340.0'},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('harga buku 5.34k ringgit')" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {'5.34m ringgit': 'RM5340000.0'},\n", " 'temperature': [],\n", " 'distance': ['5.34m'],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('harga buku 5.34m ringgit')" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {'5.34b ringgit': 'RM5340000000.0'},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('harga buku 5.34b ringgit')" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {'rm 5.2': 'RM5.2'},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('harga buku rm 5.2')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### temperature" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': ['21.3c'],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('suhu harini 21.3c')" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': ['21.3 c'],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('suhu harini 21.3 c')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### distance" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': ['10 batu'],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('sejauh 10 batu')" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': ['10.234 km'],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('sejauh 10.234 km')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### volume" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': ['21.2ml'],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('volume 21.2ml')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### duration" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': ['2jam'],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {'2jam': datetime.datetime(2023, 10, 12, 13, 43, 49, 942979)},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('duration 2jam')" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': ['sejam'],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('duration sejam')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### phone" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': ['013-1111111'],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('no telepon 013-1111111')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### email" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': ['husein@email.com'],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('email at husein@email.com')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### URL" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': ['https://huseinhouse.com'],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('website di https://huseinhouse.com')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Time" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {'pukul 2': datetime.datetime(2023, 10, 2, 0, 0)},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('pada pkul 2')" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {'pukul 2.14': datetime.datetime(2023, 10, 12, 2, 14)},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('pada pkul 2.14')" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {'2:58:59': datetime.datetime(2023, 10, 12, 2, 58, 59),\n", " 'pukul 2:58:59': datetime.datetime(2023, 10, 12, 2, 58, 59)},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('pada pkul 2:58:59')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### datetime" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {'12/02/2022': datetime.datetime(2022, 12, 2, 0, 0)},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {'14:23:21': datetime.datetime(2023, 10, 12, 14, 23, 21)},\n", " 'datetime': {'12/02/2022 14:23:21': datetime.datetime(2022, 12, 2, 14, 23, 21)},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('saya gerak 12/02/2022 14:23:21')" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "{'date': {'12/02/2022': datetime.datetime(2022, 12, 2, 0, 0)},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {'2pm': datetime.datetime(2023, 10, 12, 14, 0)},\n", " 'datetime': {'12/02/2022 2pm': datetime.datetime(2022, 12, 2, 14, 0)},\n", " 'food': [],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('saya gerak 12/02/2022 2pm')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### local and generic foods" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': ['nasi goreng'],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('nasi goreng pattaya 1')" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': ['ayam penyet'],\n", " 'drink': [],\n", " 'weight': []}" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('ayam penyet 1')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### local and generic drinks" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': ['teh o ais'],\n", " 'weight': []}" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('teh o ais 1')" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': ['teh ice'],\n", " 'weight': []}" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('teh ice 1')" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': ['nescafe beng'],\n", " 'weight': []}" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('nescafe beng 1')" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'date': {},\n", " 'money': {},\n", " 'temperature': [],\n", " 'distance': [],\n", " 'volume': [],\n", " 'duration': [],\n", " 'phone': [],\n", " 'email': [],\n", " 'url': [],\n", " 'time': {},\n", " 'datetime': {},\n", " 'food': [],\n", " 'drink': ['jus rambutan'],\n", " 'weight': []}" ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "entity.predict('jus rambutan 1')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.8.10" }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }