From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 47BDBBBAF for ; Mon, 18 Jan 2010 03:33:17 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsMBACtXU0tQDPIxjWdsb2JhbACbewEBAQEJCQoJEQW4TIQyBIk5 X-IronPort-AV: E=Sophos;i="4.49,294,1262559600"; d="scan'208";a="41632091" Received: from smtp21.orange.fr ([80.12.242.49]) by mail2-smtp-roc.national.inria.fr with ESMTP; 18 Jan 2010 03:33:16 +0100 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2119.orange.fr (SMTP Server) with ESMTP id 8512F1C00639; Mon, 18 Jan 2010 03:33:16 +0100 (CET) Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2119.orange.fr (SMTP Server) with ESMTP id 757CE1C0072A; Mon, 18 Jan 2010 03:33:16 +0100 (CET) Received: from [192.168.1.102] (c-67-188-6-241.hsd1.ca.comcast.net [67.188.6.241]) by mwinf2119.orange.fr (SMTP Server) with ESMTP id 5AD151C00639; Mon, 18 Jan 2010 03:33:15 +0100 (CET) X-ME-UUID: 20100118023315372.5AD151C00639@mwinf2119.orange.fr X-ME-User-Auth: padator@wanadoo.fr Subject: Re: [Caml-list] porter's stemmer implementation Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: text/plain; charset=iso-8859-1 From: Yoann Padioleau In-Reply-To: <4B53B027.3060107@citycable.ch> Date: Sun, 17 Jan 2010 18:33:14 -0800 Cc: =?iso-8859-1?Q?Gr=E9goire_Seux?= , caml-list Content-Transfer-Encoding: quoted-printable Message-Id: <5F50ED1F-CFBF-4179-BEC8-5CB58D246BF5@wanadoo.fr> References: <1ae8fe881001162301y15093c32q23a3f274293fcc38@mail.gmail.com> <4B53B027.3060107@citycable.ch> To: guillaume.yziquel@citycable.ch X-Mailer: Apple Mail (2.1077) X-Spam: no; 0.00; guillaume:01 gregoire:01 ocaml:01 ocaml:01 henrik:01 usr:01 lib:01 usr:01 lib:01 sig:01 flags:01 henrik:01 guillaume:01 2.5:98 unbound:01 On Jan 17, 2010, at 4:49 PM, Guillaume Yziquel wrote: >=20 > Yoann Padioleau a =E9crit : >> On Jan 16, 2010, at 11:01 PM, Gr=E9goire Seux wrote: >> There is one in nltk, a very complete python library for NLP and = there is >> ocamlpython to link ocaml and python code. As the stemmer interface = is >> very simpler (string -> string), it's very easy to use ocamlpython to = do that. >> open Pycaml >> module Py =3D Python let modul =3D Py.cpr = (Pycaml.pyimport_importmodule "nltk_ocaml") >> let dict =3D Py.cpr (Pycaml.pymodule_getdict modul) >> let stem s =3D let py_str =3D Pycaml.pystring_fromstring s in >> let f =3D Py.cpr (Pycaml.pydict_getitemstring(dict, "stem")) in >> let args =3D Py.cpr (Pycaml.pytuple_fromsingle py_str) in >> let res =3D Py.cpr (Pycaml.pyeval_callobject (f,args)) in >> Pycaml.guarded_pystring_asstring res >=20 > I'm afraid I do not understand where you get your Python module from = and you Py.cpr value from. I get from the Debian pycaml package: Oops. I have an extra module called python.ml containing small helper functions: exception PythonError (* henrik have written similar things *) let check_python_return v =3D if v =3D Pycaml.pynull ()=20 then begin Pycaml.pyerr_print (); raise PythonError end else v =20 (* alias *) let cpr =3D check_python_return >=20 > # #require "pycaml";; > /usr/lib/ocaml/unix.cma: loaded > /usr/lib/ocaml/pycaml: added to search path > /usr/lib/ocaml/pycaml/pycaml.cma: loaded > # module X =3D Python;; > Error: Unbound module Python > # module X =3D Pycaml.Python;; > Error: Unbound module Pycaml.Python > # module X =3D Pycaml;; > module X : > sig > type funcptr =3D Pycaml.funcptr > type pyobject =3D Pycaml.pyobject > type funcent =3D funcptr * int * int > type pymodule_func =3D > Pycaml.pymodule_func =3D { > pyml_name : string; > pyml_func : pyobject -> pyobject; > pyml_flags : int; > pyml_doc : string; > } > type pyobject_type =3D > Pycaml.pyobject_type =3D > TupleType > | StringType > | IntType > | FloatType > | ListType > | NoneType > | CallableType >=20 > Where did you get your pycaml from? A mix of=20 * - Arty Yekes original pycaml 0.82, * - Henrik stuart port to python 2.5 * - Thomas Fischbacher heavy extension. >=20 > All the best, >=20 > --=20 > Guillaume Yziquel > http://yziquel.homelinux.org/ >=20