[liblouis-liblouisxml] Re: Provide example?

  • From: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Thu, 2 Jul 2009 17:09:53 +0200

Hello,

Michael Whapples, le Thu 02 Jul 2009 15:26:13 +0100, a écrit :
> I have to say for examples of using liblouis from C then the programs 
> included with liblouis are probably good examples.

Ok, I will install lou_translate.c for a very simple example and
lou_allround.c for a more complex one.

> As for using it from python, the doc strings give good details, there 
> doesn't seem to be any big surprises when I tried it. However may be a 
> document listing some examples might be good, as the examples could be 
> reused as doctests. Anyway here are some examples from my quick look at 
> it. These examples should work in doctest.
> 
> >>> import louis
> 
> Show a US grade2 translation of a unicode string with no typeform 
> information
> 
> >>> louis.translateString(['en-us-g2.ctb'], u'Hello world', None, 0)
> u',hello _w'
> 
> Now do a translation using bold for the string
> 
> >>> louis.translateString(['en-us-g2.ctb'], u'Hello world', 
> [louis.bold]*11, 0)
> u',hello __w'
> 
> There seems to be a bug there that bold indicator is not added to Hello.
> 
> Now do a translation using cursor position.
> 
> >>> louis.translate(['en-us-g2.ctb'], u'Hello world', None, 5, 0)
> (u',hello _w', [0, 0, 1, 2, 3, 4, 5, 6, 6], [1, 2, 3, 4, 5, 6, 7, 7, 7, 
> 7, 7], 6)

I think that's precisely what we need. Could that be included in pydoc
louis, in the DESCRIPTION part for instance?

Samuel
For a description of the software and to download it go to
http://www.jjb-software.com

Other related posts: