477 lines
24 KiB
Plaintext
477 lines
24 KiB
Plaintext
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"collapsed": true
|
||
},
|
||
"source": [
|
||
"# ഒരു മൃഗ വിദഗ്ദ്ധ സിസ്റ്റം നടപ്പിലാക്കൽ\n",
|
||
"\n",
|
||
"[AI for Beginners Curriculum](http://github.com/microsoft/ai-for-beginners) എന്നതിൽ നിന്നുള്ള ഒരു ഉദാഹരണം.\n",
|
||
"\n",
|
||
"ഈ സാംപിളിൽ, ചില ശാരീരിക സവിശേഷതകളെ അടിസ്ഥാനമാക്കി ഒരു മൃഗം നിർണ്ണയിക്കാൻ ഒരു ലളിതമായ അറിവ്-അടിസ്ഥാനമായ സിസ്റ്റം നാം നടപ്പിലാക്കും. സിസ്റ്റം താഴെ കാണുന്ന AND-OR മരത്താൽ പ്രതിനിധീകരിക്കാവുന്നതാണ് (ഇത് മുഴുവൻ മരത്തിന്റെ ഒരു ഭാഗമാണ്, നാം എളുപ്പത്തിൽ ചില കൂടുതൽ നിബന്ധനകൾ കൂട്ടിച്ചേർക്കാം):\n",
|
||
"\n",
|
||
"\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"## പിന്റുവിളിയുള്ള നമ്മുടെ സ്വന്തം വിദഗ്ധ സിസ്റ്റം ഷെല്\n",
|
||
"\n",
|
||
"പ്രൊഡക്ഷന് നിബന്ധനകളെ അടിസ്ഥാനമാക്കി വിജ്ഞാനപ്രസ്ഥാപനത്തിനായി ഒരു ലളിതമായ ഭാഷ നിർവചിക്കാൻ ശ്രമിക്കാം. നിബന്ധനകൾ നിർവചിക്കുന്നതിന് പൈത്തൺ ക്ലാസുകൾ കീഴ്വാചകമായി ഉപയോഗിക്കും. മൂലത: 3 തരം ക്ലാസുകൾ ഉണ്ടാകാം:\n",
|
||
"* `Ask` ഉപഭോക്താവിനോട് ചോദിക്കേണ്ട ഒരു ചോദ്യത്തെ പ്രതിനിധീകരിക്കുന്നു. ഇതിൽ സാധ്യതയുള്ള മറുപടികളുടെ സെറ്റ് പ്രത്യക്ഷപ്പെടുന്നു.\n",
|
||
"* `If` ഒരു നിബന്ധനയെ പ്രതിനിധീകരിക്കുന്നു, നിബന്ധനയുടെ ഉള്ളടക്കം സൂക്ഷിക്കാൻ ഇത് വെറും സിന്റാക്റ്റിക് ഷുഗർ ആണ്\n",
|
||
"* `AND`/`OR` കൂടെ/അല്ലെങ്കിൽ ശാഖകൾ പ്രതിനിധീകരിക്കുന്ന ക്ലാസുകളാണ്. അവക്കുള്ളവയുടെ പട്ടിക വെറും സൂക്ഷിക്കുന്നു. കോഡ് ലളിതമാക്കാൻ എല്ലാ പ്രവർത്തനക്ഷമതയും മാതൃകയായി `Content` ക്ലാസിൽ നിർവചിച്ചിരിക്കുന്നു.\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 1,
|
||
"metadata": {
|
||
"trusted": true
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"class Ask():\n",
|
||
" def __init__(self,choices=['y','n']):\n",
|
||
" self.choices = choices\n",
|
||
" def ask(self):\n",
|
||
" if max([len(x) for x in self.choices])>1:\n",
|
||
" for i,x in enumerate(self.choices):\n",
|
||
" print(\"{0}. {1}\".format(i,x),flush=True)\n",
|
||
" x = int(input())\n",
|
||
" return self.choices[x]\n",
|
||
" else:\n",
|
||
" print(\"/\".join(self.choices),flush=True)\n",
|
||
" return input()\n",
|
||
"\n",
|
||
"class Content():\n",
|
||
" def __init__(self,x):\n",
|
||
" self.x=x\n",
|
||
" \n",
|
||
"class If(Content):\n",
|
||
" pass\n",
|
||
"\n",
|
||
"class AND(Content):\n",
|
||
" pass\n",
|
||
"\n",
|
||
"class OR(Content):\n",
|
||
" pass"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"എന്റെ സിസ്റ്റത്തിൽ, പ്രവർത്തന സ്മൃതിയിൽ **വസ്തുതകളുടെ** പട്ടിക **ഗുണനിലവാര-മൂല്യ ജോഡികളുടെ** രൂപത്തിൽ ഉണ്ടായിരിക്കും. ജ്ഞാനശേഖരം ഒരു വലിയ നിഘണ്ടുവായി നിർവചിക്കാവുന്നതാണ്, ഇത് പ്രവർത്തനസ്മൃതിയിലേക്ക് ചേർക്കേണ്ട പുതിയ വസ്തുതകളായ പ്രവർത്തനങ്ങളെ AND-OR പ്രവചനങ്ങളായി പ്രകടിപ്പിച്ച നിബന്ധനകളുമായി ബന്ധിപ്പിക്കുന്നു. കൂടാതെ, ചില വസ്തുതകൾ `Ask` ചെയ്യാവുന്നതാണ്.\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 2,
|
||
"metadata": {
|
||
"trusted": true
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"rules = {\n",
|
||
" 'default': Ask(['y','n']),\n",
|
||
" 'color' : Ask(['red-brown','black and white','other']),\n",
|
||
" 'pattern' : Ask(['dark stripes','dark spots']),\n",
|
||
" 'mammal': If(OR(['hair','gives milk'])),\n",
|
||
" 'carnivor': If(OR([AND(['sharp teeth','claws','forward-looking eyes']),'eats meat'])),\n",
|
||
" 'ungulate': If(['mammal',OR(['has hooves','chews cud'])]),\n",
|
||
" 'bird': If(OR(['feathers',AND(['flies','lies eggs'])])),\n",
|
||
" 'animal:monkey' : If(['mammal','carnivor','color:red-brown','pattern:dark spots']),\n",
|
||
" 'animal:tiger' : If(['mammal','carnivor','color:red-brown','pattern:dark stripes']),\n",
|
||
" 'animal:giraffe' : If(['ungulate','long neck','long legs','pattern:dark spots']),\n",
|
||
" 'animal:zebra' : If(['ungulate','pattern:dark stripes']),\n",
|
||
" 'animal:ostrich' : If(['bird','long nech','color:black and white','cannot fly']),\n",
|
||
" 'animal:pinguin' : If(['bird','swims','color:black and white','cannot fly']),\n",
|
||
" 'animal:albatross' : If(['bird','flies well'])\n",
|
||
"}"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"പിന്മാറ്റ തത്വനിർണയം നടത്താൻ, നാം `Knowledgebase` ക്ലാസ് നിർവചിക്കാം. ഇതിൽ ഉൾപ്പെടുന്നതാണ്: \n",
|
||
"* പ്രവർത്തിക്കുന്ന `memory` - లక్షണങ്ങളെ മൂല്യങ്ങളിലേക്ക് മാപ്പ് ചെയ്യുന്ന ഡിക്ഷണറി \n",
|
||
"* മേൽ പറഞ്ഞ ഫോർമാറ്റിൽ നിശ്ചയിച്ചിരിക്കുന്ന Knowledgebase `rules` \n",
|
||
"\n",
|
||
"രണ്ടു പ്രധാന മേധാവിത്വങ്ങൾ: \n",
|
||
"* `get` ഒരു ലക്ഷണത്തിന്റെ മൂല്യം പ്രാപിക്കുന്നത്, ആവശ്യമായപ്പോൾ തത്വനിർണയം നടത്തുന്നു. ഉദാഹരണത്തിന്, `get('color')` കാഴ്ചകളുടെ മൂല്യം തരും (ആവശ്യമായെങ്കിൽ ചോദിക്കും, പിന്നീട് ഉപയോഗത്തിനായി പ്രവർത്തന സ്മൃതിയിൽ മൂല്യം സൂക്ഷിക്കും). ഞങ്ങൾ `get('color:blue')` എന്ന് ചോദിച്ചാൽ, അത് നിറം ചോദിക്കും, പിന്നെ നിറത്തിന്റെ അടിസ്ഥാനത്തിൽ `y`/`n` മൂല്യം വിധി ചെയ്യും. \n",
|
||
"* `eval` യഥാർത്ഥത്തത്വനിർണയം നടപ്പാക്കുന്നു, അർത്ഥം AND/OR വൃക്ഷം താണ്ടി സബ്ഗോളുകളെ മൂല്യനിർണയം ചെയ്യുന്നു, തുടങ്ങിയവ.\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 3,
|
||
"metadata": {
|
||
"trusted": true
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"class KnowledgeBase():\n",
|
||
" def __init__(self,rules):\n",
|
||
" self.rules = rules\n",
|
||
" self.memory = {}\n",
|
||
" \n",
|
||
" def get(self,name):\n",
|
||
" if ':' in name:\n",
|
||
" k,v = name.split(':')\n",
|
||
" vv = self.get(k)\n",
|
||
" return 'y' if v==vv else 'n'\n",
|
||
" if name in self.memory.keys():\n",
|
||
" return self.memory[name]\n",
|
||
" for fld in self.rules.keys():\n",
|
||
" if fld==name or fld.startswith(name+\":\"):\n",
|
||
" # print(\" + proving {}\".format(fld))\n",
|
||
" value = 'y' if fld==name else fld.split(':')[1]\n",
|
||
" res = self.eval(self.rules[fld],field=name)\n",
|
||
" if res!='y' and res!='n' and value=='y':\n",
|
||
" self.memory[name] = res\n",
|
||
" return res\n",
|
||
" if res=='y':\n",
|
||
" self.memory[name] = value\n",
|
||
" return value\n",
|
||
" # field is not found, using default\n",
|
||
" res = self.eval(self.rules['default'],field=name)\n",
|
||
" self.memory[name]=res\n",
|
||
" return res\n",
|
||
" \n",
|
||
" def eval(self,expr,field=None):\n",
|
||
" # print(\" + eval {}\".format(expr))\n",
|
||
" if isinstance(expr,Ask):\n",
|
||
" print(field)\n",
|
||
" return expr.ask()\n",
|
||
" elif isinstance(expr,If):\n",
|
||
" return self.eval(expr.x)\n",
|
||
" elif isinstance(expr,AND) or isinstance(expr,list):\n",
|
||
" expr = expr.x if isinstance(expr,AND) else expr\n",
|
||
" for x in expr:\n",
|
||
" if self.eval(x)=='n':\n",
|
||
" return 'n'\n",
|
||
" return 'y'\n",
|
||
" elif isinstance(expr,OR):\n",
|
||
" for x in expr.x:\n",
|
||
" if self.eval(x)=='y':\n",
|
||
" return 'y'\n",
|
||
" return 'n'\n",
|
||
" elif isinstance(expr,str):\n",
|
||
" return self.get(expr)\n",
|
||
" else:\n",
|
||
" print(\"Unknown expr: {}\".format(expr))"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"ഇപ്പോൾ നമുക്ക് നമ്മുടെ മൃഗജ്ഞാനകോശം 定義 ചെയ്ത് ചോദ്യംചെയ്യൽ നടത്താം. ഈ കോളിൽ നിങ്ങളോട് ചില ചോദ്യങ്ങൾ ചെയ്യും. സര്വ്വത്തരമായ ‘y’/‘n’ കണ്ടുപിടിച്ച് ഉത്തരം നൽകാം, അല്ലെങ്കിൽ കൂടുതൽ സ്വതന്ത്രമാർഗ്ഗങ്ങളുള്ള ചോദ്യങ്ങൾക്ക് (0..N) സംഖ്യ നൽകാം.\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 4,
|
||
"metadata": {
|
||
"trusted": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"hair\n",
|
||
"y/n\n",
|
||
"sharp teeth\n",
|
||
"y/n\n",
|
||
"claws\n",
|
||
"y/n\n",
|
||
"forward-looking eyes\n",
|
||
"y/n\n",
|
||
"color\n",
|
||
"0. red-brown\n",
|
||
"1. black and white\n",
|
||
"2. other\n",
|
||
"has hooves\n",
|
||
"y/n\n",
|
||
"long neck\n",
|
||
"y/n\n",
|
||
"long legs\n",
|
||
"y/n\n",
|
||
"pattern\n",
|
||
"0. dark stripes\n",
|
||
"1. dark spots\n"
|
||
]
|
||
},
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"'giraffe'"
|
||
]
|
||
},
|
||
"execution_count": 4,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"kb = KnowledgeBase(rules)\n",
|
||
"kb.get('animal')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"## മുന്നോട്ട് ഇൻഫറൻസിന് Experta ഉപയോഗിക്കുക\n",
|
||
"\n",
|
||
"അടുത്ത ഉദാഹരണത്തിൽ, നാം ജ്ഞാന പ്രതിനിധാനത്തിനുള്ള ലൈബ്രറികളിൽ ഒന്നായ [Experta](https://github.com/nilp0inter/experta) ഉപയോഗിച്ച് മുന്നോട്ട് ഇൻഫറൻസ് നടപ്പിലാക്കാൻ ശ്രമിക്കുമെന്നും. **Experta** പൈത്തണിൽ മുന്നോട്ട് ഇൻഫറൻസ് സിസ്റ്റങ്ങളും സൃഷ്ടിക്കാൻ വേണ്ട ഒരു ലൈബ്രറിയാണ്, ഇത് പാരമ്പര്യമായ പഴയ സിസ്റ്റമായ [CLIPS](http://www.clipsrules.net/index.html) നു സമാനമായിട്ടാണ് രൂപകൽപ്പന ചെയ്തിരിക്കുന്നത്.\n",
|
||
"\n",
|
||
"നാം പലതും പ്രശ്നങ്ങളില്ലാതെ മുന്നോട്ട് ചെയിനിംഗ് സ്വയം നടപ്പിലാക്കാമായിരുന്നു, പക്ഷേ നൈവ് നടപ്പാക്കലുകൾ സാധാരണയായി വളരെ കാര്യക്ഷമമല്ല. കൂടുതൽ ഫലപ്രദമായ റൂൾ മാച്ചിംഗിനായി പ്രത്യേക അല്ഗോരിതമായ [Rete](https://en.wikipedia.org/wiki/Rete_algorithm) ഉപയോഗിക്കുന്നു.\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 5,
|
||
"metadata": {
|
||
"trusted": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"Collecting git+https://github.com/nilp0inter/experta\n",
|
||
" Cloning https://github.com/nilp0inter/experta to /tmp/pip-req-build-7qurtwk3\n",
|
||
" Running command git clone --filter=blob:none --quiet https://github.com/nilp0inter/experta /tmp/pip-req-build-7qurtwk3\n",
|
||
" Resolved https://github.com/nilp0inter/experta to commit c6d5834b123861f5ae09e7d07027dc98bec58741\n",
|
||
" Installing build dependencies ... \u001b[?25ldone\n",
|
||
"\u001b[?25h Getting requirements to build wheel ... \u001b[?25ldone\n",
|
||
"\u001b[?25h Preparing metadata (pyproject.toml) ... \u001b[?25ldone\n",
|
||
"\u001b[?25hRequirement already satisfied: frozendict~=2.4.6 in /opt/conda/envs/ai4beg/lib/python3.12/site-packages (from experta==1.9.5.dev1) (2.4.7)\n",
|
||
"Collecting schema~=0.6.7 (from experta==1.9.5.dev1)\n",
|
||
" Downloading schema-0.6.8-py2.py3-none-any.whl.metadata (14 kB)\n",
|
||
"Downloading schema-0.6.8-py2.py3-none-any.whl (14 kB)\n",
|
||
"Building wheels for collected packages: experta\n",
|
||
" Building wheel for experta (pyproject.toml) ... \u001b[?25ldone\n",
|
||
"\u001b[?25h Created wheel for experta: filename=experta-1.9.5.dev1-py3-none-any.whl size=34804 sha256=888c459512a5e713f4b674caa9a0f96cfdf07ec0d6eb56cc318ce0653d218014\n",
|
||
" Stored in directory: /tmp/pip-ephem-wheel-cache-1eeii9zy/wheels/3d/e8/bb/22d7956359603fa8dd679aa09f5b8efb3f29991c3986fdc787\n",
|
||
"Successfully built experta\n",
|
||
"Installing collected packages: schema, experta\n",
|
||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2/2\u001b[0m [experta]\n",
|
||
"\u001b[1A\u001b[2KSuccessfully installed experta-1.9.5.dev1 schema-0.6.8\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import sys\n",
|
||
"!{sys.executable} -m pip install git+https://github.com/nilp0inter/experta"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 13,
|
||
"metadata": {
|
||
"trusted": true
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"from experta import *\n",
|
||
"#import experta"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"നാം നമ്മുടെ സംവിധാനത്തെ `KnowledgeEngine`-നെ subclasses ചെയ്യുന്ന ഒരു ക്ലാസ് ആയി นิർവ്വചിക്കും. ഓരോ നയം വേറിട്ട ഫങ്ക്ഷനായി `@Rule` അനോടേഷനോടുകൂടി นิർവ്വചിക്കപ്പെടുന്നു, ഇത് നയ 언제 പ്രവർത്തിക്കണം എന്ന് സൂചിപ്പിക്കുന്നു. നയത്തിനുള്ളിൽ, `declare` ഫംഗ്ഷൻ ഉപയോഗിച്ച് പുതിയ വാസ്തവങ്ങൾ ചേർക്കാൻ കഴിയും, ആ വാസ്തവങ്ങൾ ചേർത്താൽ മുന്നോട്ടുള്ള നിർവചന എഞ്ചിനിൽ കൂടുതൽ നയങ്ങൾ വിളിക്കപ്പെടും.\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 14,
|
||
"metadata": {
|
||
"trusted": true
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"class Animals(KnowledgeEngine):\n",
|
||
" @Rule(OR(\n",
|
||
" AND(Fact('sharp teeth'),Fact('claws'),Fact('forward looking eyes')),\n",
|
||
" Fact('eats meat')))\n",
|
||
" def cornivor(self):\n",
|
||
" self.declare(Fact('carnivor'))\n",
|
||
" \n",
|
||
" @Rule(OR(Fact('hair'),Fact('gives milk')))\n",
|
||
" def mammal(self):\n",
|
||
" self.declare(Fact('mammal'))\n",
|
||
"\n",
|
||
" @Rule(Fact('mammal'),\n",
|
||
" OR(Fact('has hooves'),Fact('chews cud')))\n",
|
||
" def hooves(self):\n",
|
||
" self.declare('ungulate')\n",
|
||
" \n",
|
||
" @Rule(OR(Fact('feathers'),AND(Fact('flies'),Fact('lays eggs'))))\n",
|
||
" def bird(self):\n",
|
||
" self.declare('bird')\n",
|
||
" \n",
|
||
" @Rule(Fact('mammal'),Fact('carnivor'),\n",
|
||
" Fact(color='red-brown'),\n",
|
||
" Fact(pattern='dark spots'))\n",
|
||
" def monkey(self):\n",
|
||
" self.declare(Fact(animal='monkey'))\n",
|
||
"\n",
|
||
" @Rule(Fact('mammal'),Fact('carnivor'),\n",
|
||
" Fact(color='red-brown'),\n",
|
||
" Fact(pattern='dark stripes'))\n",
|
||
" def tiger(self):\n",
|
||
" self.declare(Fact(animal='tiger'))\n",
|
||
"\n",
|
||
" @Rule(Fact('ungulate'),\n",
|
||
" Fact('long neck'),\n",
|
||
" Fact('long legs'),\n",
|
||
" Fact(pattern='dark spots'))\n",
|
||
" def giraffe(self):\n",
|
||
" self.declare(Fact(animal='giraffe'))\n",
|
||
"\n",
|
||
" @Rule(Fact('ungulate'),\n",
|
||
" Fact(pattern='dark stripes'))\n",
|
||
" def zebra(self):\n",
|
||
" self.declare(Fact(animal='zebra'))\n",
|
||
"\n",
|
||
" @Rule(Fact('bird'),\n",
|
||
" Fact('long neck'),\n",
|
||
" Fact('cannot fly'),\n",
|
||
" Fact(color='black and white'))\n",
|
||
" def straus(self):\n",
|
||
" self.declare(Fact(animal='ostrich'))\n",
|
||
"\n",
|
||
" @Rule(Fact('bird'),\n",
|
||
" Fact('swims'),\n",
|
||
" Fact('cannot fly'),\n",
|
||
" Fact(color='black and white'))\n",
|
||
" def pinguin(self):\n",
|
||
" self.declare(Fact(animal='pinguin'))\n",
|
||
"\n",
|
||
" @Rule(Fact('bird'),\n",
|
||
" Fact('flies well'))\n",
|
||
" def albatros(self):\n",
|
||
" self.declare(Fact(animal='albatross'))\n",
|
||
" \n",
|
||
" @Rule(Fact(animal=MATCH.a))\n",
|
||
" def print_result(self,a):\n",
|
||
" print('Animal is {}'.format(a))\n",
|
||
" \n",
|
||
" def factz(self,l):\n",
|
||
" for x in l:\n",
|
||
" self.declare(x)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"ഒരിക്കൽ നാം ഒരു നോളജ് ബെസ് നിർവ്വചിച്ചാൽ, ഞങ്ങൾ നമ്മുടെ വർകിംഗ് മെമ്മറിയിൽ ചില തുടങ്ങിയ വസ്തുതകൾ പൂരിപ്പിക്കുകയും പിന്നെ `run()` മെഥഡ് വിളിച്ച് ഇൻഫെറൻസ് നടത്തുകയും ചെയ്യും. നിങ്ങൾക്കാകാം ഫലം കാണാൻ, പുതിയ ഇൻഫെർഡ് വസ്തുതകൾ വർകിംഗ് മെമ്മറിയിലേക്ക് ചേർക്കപ്പെടുന്നുണ്ട്, മൃഗത്തെക്കുറിച്ചുള്ള അന്തിമ വസ്തുത ഉൾപ്പെടെ (ഞങ്ങൾ എല്ലാ തുടങ്ങന്ന വസ്തുതകളും ശരിയായി ക്രമീകരിച്ചെങ്കിൽ).\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 15,
|
||
"metadata": {
|
||
"trusted": true
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"Animal is tiger\n"
|
||
]
|
||
},
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"FactList([(0, InitialFact()),\n",
|
||
" (1, Fact(color='red-brown')),\n",
|
||
" (2, Fact(pattern='dark stripes')),\n",
|
||
" (3, Fact('sharp teeth')),\n",
|
||
" (4, Fact('claws')),\n",
|
||
" (5, Fact('forward looking eyes')),\n",
|
||
" (6, Fact('gives milk')),\n",
|
||
" (7, Fact('mammal')),\n",
|
||
" (8, Fact('carnivor')),\n",
|
||
" (9, Fact(animal='tiger'))])"
|
||
]
|
||
},
|
||
"execution_count": 15,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"ex1 = Animals()\n",
|
||
"ex1.reset()\n",
|
||
"ex1.factz([\n",
|
||
" Fact(color='red-brown'),\n",
|
||
" Fact(pattern='dark stripes'),\n",
|
||
" Fact('sharp teeth'),\n",
|
||
" Fact('claws'),\n",
|
||
" Fact('forward looking eyes'),\n",
|
||
" Fact('gives milk')])\n",
|
||
"ex1.run()\n",
|
||
"ex1.facts"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": []
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"---\n\n<!-- CO-OP TRANSLATOR DISCLAIMER START -->\n**തള്ളിപ്പറയൽ**: \nഈ ഡോക്യുമെന്റ് AI വിവർത്തന സേവനം [Co-op Translator](https://github.com/Azure/co-op-translator) ഉപയോഗിച്ച് വിവർത്തനം ചെയ്തതാണ്. ഞങ്ങൾ കൃത്യതയ്ക്കായി പ്രയത്നിക്കുന്നെങ്കിലും, സ്വയംകൃതമായ വിവർത്തനങ്ങളിൽ തെറ്റുകളോ അസാധുതകളോ ഉണ്ടായിരിയ്ക്കാം എന്നതിൽ ശ്രദ്ധിക്കുക. യഥാർത്ഥ ഡോക്യുമെന്റ് അതിന്റെ സ്വദേശഭാഷയിൽ തന്നതാണ് അധികാരമുള്ള ഉറവിടം. നിർണായക വിവരങ്ങൾക്ക് പ്രൊഫഷണൽ انسانی വിവർത്തനം ശുപാർശ ചെയ്യുന്നു. ഈ വിവർത്തനം ഉപയോഗിക്കുന്നതിൽ നിന്നുള്ള ഏതെങ്കിലും തെറ്റിദ്ധാരണകൾക്ക് ഞങ്ങൾ ഉത്തരവാദികളല്ല.\n<!-- CO-OP TRANSLATOR DISCLAIMER END -->\n"
|
||
]
|
||
}
|
||
],
|
||
"metadata": {
|
||
"kernelspec": {
|
||
"display_name": "Python 3.7.4 64-bit (conda)",
|
||
"metadata": {
|
||
"interpreter": {
|
||
"hash": "86193a1ab0ba47eac1c69c1756090baa3b420b3eea7d4aafab8b85f8b312f0c5"
|
||
}
|
||
},
|
||
"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.11.2"
|
||
},
|
||
"coopTranslator": {
|
||
"original_hash": "8ef43db4b9182239fd150a76bd494fdb",
|
||
"translation_date": "2026-01-17T02:05:45+00:00",
|
||
"source_file": "lessons/2-Symbolic/Animals.ipynb",
|
||
"language_code": "ml"
|
||
}
|
||
},
|
||
"nbformat": 4,
|
||
"nbformat_minor": 2
|
||
} |