Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Yoann Padioleau <padator@wanadoo.fr>
To: guillaume.yziquel@citycable.ch
Cc: "Grégoire Seux" <kamaradclimber@gmail.com>,
	caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] porter's stemmer implementation
Date: Sun, 17 Jan 2010 18:33:14 -0800	[thread overview]
Message-ID: <5F50ED1F-CFBF-4179-BEC8-5CB58D246BF5@wanadoo.fr> (raw)
In-Reply-To: <4B53B027.3060107@citycable.ch>


On Jan 17, 2010, at 4:49 PM, Guillaume Yziquel wrote:

> 
> Yoann Padioleau a écrit :
>> On Jan 16, 2010, at 11:01 PM, Grégoire 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 = Python let modul = Py.cpr (Pycaml.pyimport_importmodule "nltk_ocaml")
>> let dict = Py.cpr (Pycaml.pymodule_getdict modul)
>> let stem s =   let py_str = Pycaml.pystring_fromstring s in
>>  let f = Py.cpr (Pycaml.pydict_getitemstring(dict, "stem")) in
>>  let args = Py.cpr (Pycaml.pytuple_fromsingle py_str) in
>>  let res = Py.cpr (Pycaml.pyeval_callobject (f,args)) in
>>  Pycaml.guarded_pystring_asstring res
> 
> 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 =
  if v = Pycaml.pynull () 
  then begin
    Pycaml.pyerr_print ();
    raise PythonError
  end
  else v
      
(* alias *)
let cpr = check_python_return


> 
> # #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 = Python;;
> Error: Unbound module Python
> # module X = Pycaml.Python;;
> Error: Unbound module Pycaml.Python
> # module X = Pycaml;;
> module X :
>  sig
>    type funcptr = Pycaml.funcptr
>    type pyobject = Pycaml.pyobject
>    type funcent = funcptr * int * int
>    type pymodule_func =
>      Pycaml.pymodule_func = {
>      pyml_name : string;
>      pyml_func : pyobject -> pyobject;
>      pyml_flags : int;
>      pyml_doc : string;
>    }
>    type pyobject_type =
>      Pycaml.pyobject_type =
>        TupleType
>      | StringType
>      | IntType
>      | FloatType
>      | ListType
>      | NoneType
>      | CallableType
> 
> Where did you get your pycaml from?

A mix of 
 * - Arty Yekes original pycaml 0.82,
 * - Henrik stuart port to python 2.5
 * - Thomas Fischbacher heavy extension.


> 
> All the best,
> 
> -- 
>     Guillaume Yziquel
> http://yziquel.homelinux.org/
> 




      reply	other threads:[~2010-01-18  2:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-17  7:01 Grégoire Seux
2010-01-17 19:12 ` [Caml-list] " Richard Jones
2010-01-17 19:33 ` Yoann Padioleau
2010-01-18  0:49   ` Guillaume Yziquel
2010-01-18  2:33     ` Yoann Padioleau [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5F50ED1F-CFBF-4179-BEC8-5CB58D246BF5@wanadoo.fr \
    --to=padator@wanadoo.fr \
    --cc=caml-list@inria.fr \
    --cc=guillaume.yziquel@citycable.ch \
    --cc=kamaradclimber@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox