{"id":204,"date":"2004-06-15T20:12:52","date_gmt":"2004-06-15T18:12:52","guid":{"rendered":"http:\/\/blogs.bl0rg.net\/neingeist-neu\/2004\/06\/15\/editierabstand-oder-so-ahnlich\/"},"modified":"2008-06-04T17:08:20","modified_gmt":"2008-06-04T15:08:20","slug":"editierabstand-oder-so-ahnlich","status":"publish","type":"post","link":"https:\/\/blogs.bl0rg.net\/neingeist\/2004\/06\/15\/editierabstand-oder-so-ahnlich\/","title":{"rendered":"Editierabstand oder so \u00e4hnlich"},"content":{"rendered":"<p>Und noch ein wenig Lisp-Code, diesmal eine <a href=\"http:\/\/wwwiaim.ira.uka.de\/Teaching\/VorlesungKogSys\/pdf\/03Uebungsblatt.pdf\">\u00dcbungsaufgabe<\/a> f\u00fcr meine <a href=\"http:\/\/wwwiaim.ira.uka.de\/Teaching\/VorlesungKogSys\/index.html\"> Vorlesung Kognitive Systeme<\/a>. Es ging darum, das Wort mit der gr\u00f6\u00dften \u00c4hnlichkeit zu *word-from* aus der Liste *words-to* herauszufinden. H\u00f6herer Score bedeutet hier eine h\u00f6here \u00c4hnlichkeit, in den Vorlesungen Info II und Info IV war das andersherum definiert (Editierabstand) und die Matrix anders initialisiert.<\/p>\n<pre>(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_defparametercm_defvar.html\">defparameter<\/a> *word-from* \"DAABBCADBBA\")\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_defparametercm_defvar.html\">defparameter<\/a> *words-to* '(\"DDABCBA\" \"BAAATTCDBA\" \"DAABCCACBBA\" \"DAABBAABB\" \"AABDBCDBBC\"))\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_defparametercm_defvar.html\">defparameter<\/a> *word-to* nil)\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_defparametercm_defvar.html\">defparameter<\/a> *matrix* nil)\r\n\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_defun.html\">defun<\/a> run ()\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/sym_declare.html\">declare<\/a> (special *word-to*))\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_dolist.html\">dolist<\/a> (*word-to* *words-to*)\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/stagenfun_doc_umentationcp.html\">setf<\/a> *matrix* (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_make-array.html\">make-array<\/a> (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/syscla_list.html\">list<\/a> (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_1plcm_1-.html\">1+<\/a> (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_length.html\">length<\/a> *word-from*)) (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_1plcm_1-.html\">1+<\/a> (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_length.html\">length<\/a> *word-to*))) :initial-element nil))\r\n(init-matrix)\r\n(do-score)\r\n(show-matrix)))\r\n\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_defun.html\">defun<\/a> init-matrix ()\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_dotimes.html\">dotimes<\/a> (x (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_array-dimension.html\">array-dimension<\/a> *matrix* 0))\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/stagenfun_doc_umentationcp.html\">setf<\/a> (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/acc_aref.html\">aref<\/a> *matrix* x 0) 0))\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_dotimes.html\">dotimes<\/a> (y (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_array-dimension.html\">array-dimension<\/a> *matrix* 1))\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/stagenfun_doc_umentationcp.html\">setf<\/a> (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/acc_aref.html\">aref<\/a> *matrix* 0 y) 0)))\r\n\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_defun.html\">defun<\/a> show-matrix ()\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_format.html\">format<\/a> t \"        \")\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_dotimes.html\">dotimes<\/a> (x (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_length.html\">length<\/a> *word-from*))\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_format.html\">format<\/a> t \"~G   \" (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/acc_subseq.html\">subseq<\/a> *word-from* x (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_1plcm_1-.html\">1+<\/a> x))))\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_format.html\">format<\/a> t \"~%\")\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_dotimes.html\">dotimes<\/a> (y (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_array-dimension.html\">array-dimension<\/a> *matrix* 1))\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/speope_if.html\">if<\/a> (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_zerop.html\">zerop<\/a> y)\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_format.html\">format<\/a> t \"  \")\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_format.html\">format<\/a> t \"~G \" (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/acc_subseq.html\">subseq<\/a> *word-to* (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_1plcm_1-.html\">1-<\/a> y) y)))\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_dotimes.html\">dotimes<\/a> (x (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_array-dimension.html\">array-dimension<\/a> *matrix* 0))\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_format.html\">format<\/a> t \"~3D \" (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/acc_aref.html\">aref<\/a> *matrix* x y)))\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_format.html\">format<\/a> t \"~%\"))\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_format.html\">format<\/a> t \"~%\"))\r\n\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_defun.html\">defun<\/a> score (x y)\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_apply.html\">apply<\/a> #'max\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/syscla_list.html\">list<\/a>           (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/speope_if.html\">if<\/a> (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_equal.html\">equal<\/a> (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/acc_subseq.html\">subseq<\/a> *word-from* (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_1plcm_1-.html\">1-<\/a> x) x)\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/acc_subseq.html\">subseq<\/a> *word-to* (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_1plcm_1-.html\">1-<\/a> y) y))\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/var_plcm_plplcm_plplpl.html\">+<\/a> (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/acc_aref.html\">aref<\/a> *matrix* (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_1plcm_1-.html\">1-<\/a> x) (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_1plcm_1-.html\">1-<\/a> y)) 2)\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/var_plcm_plplcm_plplpl.html\">+<\/a> (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/acc_aref.html\">aref<\/a> *matrix* (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_1plcm_1-.html\">1-<\/a> x) (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_1plcm_1-.html\">1-<\/a> y)) -1))\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/var_plcm_plplcm_plplpl.html\">+<\/a> (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/acc_aref.html\">aref<\/a> *matrix* (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_1plcm_1-.html\">1-<\/a> x) y) -3)\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/var_plcm_plplcm_plplpl.html\">+<\/a> (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/acc_aref.html\">aref<\/a> *matrix* x (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_1plcm_1-.html\">1-<\/a> y)) -2))))\r\n\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_defun.html\">defun<\/a> do-score ()\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_loop.html\">loop<\/a> for y from 1 to (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_length.html\">length<\/a> *word-to*) do\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/mac_loop.html\">loop<\/a> for x from 1 to (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/fun_length.html\">length<\/a> *word-from*) do\r\n(<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/stagenfun_doc_umentationcp.html\">setf<\/a> (<a href=\"http:\/\/www.lisp.org\/HyperSpec\/Body\/acc_aref.html\">aref<\/a> *matrix* x y) (score x y)))))<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Und noch ein wenig Lisp-Code, diesmal eine \u00dcbungsaufgabe f\u00fcr meine Vorlesung Kognitive Systeme. Es ging darum, das Wort mit der gr\u00f6\u00dften \u00c4hnlichkeit zu *word-from* aus der Liste *words-to* herauszufinden. H\u00f6herer Score bedeutet hier eine h\u00f6here \u00c4hnlichkeit, in den Vorlesungen Info II und Info IV war das andersherum definiert (Editierabstand) und die Matrix anders initialisiert. (defparameter [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[14,15],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.bl0rg.net\/neingeist\/wp-json\/wp\/v2\/posts\/204"}],"collection":[{"href":"https:\/\/blogs.bl0rg.net\/neingeist\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.bl0rg.net\/neingeist\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.bl0rg.net\/neingeist\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.bl0rg.net\/neingeist\/wp-json\/wp\/v2\/comments?post=204"}],"version-history":[{"count":0,"href":"https:\/\/blogs.bl0rg.net\/neingeist\/wp-json\/wp\/v2\/posts\/204\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.bl0rg.net\/neingeist\/wp-json\/wp\/v2\/media?parent=204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.bl0rg.net\/neingeist\/wp-json\/wp\/v2\/categories?post=204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.bl0rg.net\/neingeist\/wp-json\/wp\/v2\/tags?post=204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}