Re: [NTG-context] final thoughts on experiments with lua
Am 2019-01-09 um 20:57 schrieb Thomas A. Schmitz : > I've finished testing my lua script, and it does exactly what I need. I think > I'll write a small article about it for one of the next context group > proceedings, Hi Thomas, since I’m just starting to work on the current CG journal (sorry, life happens...), I might fit your article in. And a German version would be welcome for DANTE’s DTK. > 3. Lua's handling of tables is very efficient and fast. For analyzing my > Greek texts, I have to use huge tables for morphological parsing, with more > than 900,000 entries. Looking up words in these tables is around 3x faster in > Lua than in python! Nice to know. Maybe I should try to convert some of my Python code (esp. the ConTeXt related scripts)... > One final thought: one limitation that I still find cumbersome to work around > is the fact that associative arrays ("pairs" in Lua speak) do not have an > order. When I analyze my texts, I want book numbers, chapters, paragraphs > preserved in the order in which they are read (entered into the table). In > many cases, it is not possible (or extremely awkward) to sort these numbers, > since chapters may be numbered something like 2, 2a, 3, 3α, 3β etc. python > has the OrderedDict() in its collections module. In Lua, the best I could > find was entering the chapter numbers into an array (ipair) and then retrieve > it from there. Maybe there is a better way? Since Python’s usual dict is also unordered, I guess OrderedDict also just uses an index array under the hood. Python makes it easy to create new classes (also data types) that behave like something known. Don’t know how that would look in Lua... Python’s batteries are much bigger than Lua(TeX)’s. Of course Lua should be kept small, but there are always things missing. My Lua library for invoices with ConTeXt e.g. uses an object model from an obscure Lua library. Probably it would make more sense to use Lua’s tables in a native way than to insist on objects. I also missed a good GUI library (with widgets); I chose tekui and added some GUI-from-configuration stuff, but got stuck, since I’m comfortable with my CLI scripts anyway... Greetlings, Hraban --- https://www.fiee.net http://wiki.contextgarden.net https://www.dreiviertelhaus.de GPG Key ID 1C9B22FD ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] Lower limit of integrals shifted
Hi, the output of \setupmathematics[ integral=nolimits, ] \starttext \startTEXpage[offset=2bp] $\displaystyle\int_0^1x^2\,dx=\frac{1}{3}$ \stopTEXpage \stoptext is attached. Clearly, the lower limit in the integral is not correctly placed. With hope of a quick fix, Mikael ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] final thoughts on experiments with lua
On 1/9/2019 9:38 PM, Alan Braslau wrote: On Wed, 9 Jan 2019 20:57:21 +0100 "Thomas A. Schmitz" wrote: 3. Lua's handling of tables is very efficient and fast. For analyzing my Greek texts, I have to use huge tables for morphological parsing, with more than 900,000 entries. Looking up words in these tables is around 3x faster in Lua than in python! I have found, in my limited use (and understanding) of lua for data analysis is that it is indeed VERY fast, and not only beats python without comparison, it also handles quite large data sets without choking. and with a bit op optimization one can often squeeze out more It has become fashionable to use hardware GPUs to speed-up parallel calculation tasks, and this is now often done using libraries having python bindings. I wonder if python becomes the limiting factor in those applications? Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] final thoughts on experiments with lua
On 1/9/2019 8:57 PM, Thomas A. Schmitz wrote: I've finished testing my lua script, and it does exactly what I need. I think I'll write a small article about it for one of the next context group proceedings, but wanted to just give a very brief summary that might be of interest to some: Pure Lua is wonderful, but as the language is deliberately kept very small, one sometimes has to find rather cumbersome workarounds. If you run Lua under ConTeXt (with mtxrun --script), you get a version with batteries included, which is perfect for manipulating and analyzing text. Some areas that I found particularly impressive: 1. I've tried several times to make use of lpegs. Hans' code is full of it, and I know that it's fast and extremely versatile, but I found it difficult to wrap my head around its functioning and write useful code with lpegs. The ConTeXt wrapper makes this extremely easy; this is lpeg for the rest of us. It's really a delight to build patterns and see them work immediately! 2. The utf library and string manipulation with characters.(...) is absolutely necessary if you want to handle non-ASCII text because pure Lua gives very unexpected results in this area. These operations work wonderfully with the context libraries. 3. Lua's handling of tables is very efficient and fast. For analyzing my Greek texts, I have to use huge tables for morphological parsing, with more than 900,000 entries. Looking up words in these tables is around 3x faster in Lua than in python! > One final thought: one limitation that I still find cumbersome to work around is the fact that associative arrays ("pairs" in Lua speak) do not have an order. When I analyze my texts, I want book numbers, chapters, paragraphs preserved in the order in which they are read (entered into the table). In many cases, it is not possible (or extremely awkward) to sort these numbers, since chapters may be numbered something like 2, 2a, 3, 3α, 3β etc. python has the OrderedDict() in its collections module. In Lua, the best I could find was entering the chapter numbers into an array (ipair) and then retrieve it from there. Maybe there is a better way? for k, v in table.sortedhash(t) do end or if it's sequential, you can add to an indexed (of use the index sorted for complex cases) it all depends on use ... if you can be more specific ... All of this just to say how grateful I am for the way Hans, Taco, Wolfgang, Luigi, and the other developers have enhanced Lua. Thanks guys, you make my work much more pleasant and efficient! Thanks - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] Footnotes in float combinations missing in output
Hi there, hi Hans, I just want to let you know that footnotes insterted in float-combinations don't get rendered properly, i. e. only the last footnote is placed in the output. MWE: \starttext \startplacefigure[title={OuterCap\footnote{Outer footnote}}] \startfloatcombination[nx=3] \placefigure{Fnote1\footnote{Hello}}{\externalfigure[cow][width={.2\textwidth}]} \placefigure{Fnote2\footnote{small}}{\externalfigure[cow][width={.2\textwidth}]} \placefigure{Fnote3\footnote{world}}{\externalfigure[cow][width={.2\textwidth}]} \stopfloatcombination \stopplacefigure \stoptext gives the following: Can you confirm and tell me that it's not my fault? Greetings, Lars. ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] final thoughts on experiments with lua
On Wed, 9 Jan 2019 20:57:21 +0100 "Thomas A. Schmitz" wrote: > 3. Lua's handling of tables is very efficient and fast. For analyzing my > Greek texts, I have to use huge tables for morphological parsing, with > more than 900,000 entries. Looking up words in these tables is around 3x > faster in Lua than in python! I have found, in my limited use (and understanding) of lua for data analysis is that it is indeed VERY fast, and not only beats python without comparison, it also handles quite large data sets without choking. It has become fashionable to use hardware GPUs to speed-up parallel calculation tasks, and this is now often done using libraries having python bindings. I wonder if python becomes the limiting factor in those applications? Alan ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] final thoughts on experiments with lua
On Wed, Jan 9, 2019 at 8:57 PM Thomas A. Schmitz wrote: > > One final thought: one limitation that I still find cumbersome to work > around is the fact that associative arrays ("pairs" in Lua speak) do not > have an order. When I analyze my texts, I want book numbers, chapters, > paragraphs preserved in the order in which they are read (entered into > the table). In many cases, it is not possible (or extremely awkward) to > sort these numbers, since chapters may be numbered something like 2, 2a, > 3, 3α, 3β etc. python has the OrderedDict() in its collections module. > In Lua, the best I could find was entering the chapter numbers into an > array (ipair) and then retrieve it from there. Maybe there is a better way? > > table.sort (list [, comp]) Sorts list elements in a given order, in-place, from list[1] to list[#list]. If comp is given, then it must be a function that receives two list elements and returns true when the first element must come before the second in the final order (so that, after the sort, i < j implies not comp(list[j],list[i])). If comp is not given, then the standard Lua operator < is used instead -- luigi ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] final thoughts on experiments with lua
I've finished testing my lua script, and it does exactly what I need. I think I'll write a small article about it for one of the next context group proceedings, but wanted to just give a very brief summary that might be of interest to some: Pure Lua is wonderful, but as the language is deliberately kept very small, one sometimes has to find rather cumbersome workarounds. If you run Lua under ConTeXt (with mtxrun --script), you get a version with batteries included, which is perfect for manipulating and analyzing text. Some areas that I found particularly impressive: 1. I've tried several times to make use of lpegs. Hans' code is full of it, and I know that it's fast and extremely versatile, but I found it difficult to wrap my head around its functioning and write useful code with lpegs. The ConTeXt wrapper makes this extremely easy; this is lpeg for the rest of us. It's really a delight to build patterns and see them work immediately! 2. The utf library and string manipulation with characters.(...) is absolutely necessary if you want to handle non-ASCII text because pure Lua gives very unexpected results in this area. These operations work wonderfully with the context libraries. 3. Lua's handling of tables is very efficient and fast. For analyzing my Greek texts, I have to use huge tables for morphological parsing, with more than 900,000 entries. Looking up words in these tables is around 3x faster in Lua than in python! One final thought: one limitation that I still find cumbersome to work around is the fact that associative arrays ("pairs" in Lua speak) do not have an order. When I analyze my texts, I want book numbers, chapters, paragraphs preserved in the order in which they are read (entered into the table). In many cases, it is not possible (or extremely awkward) to sort these numbers, since chapters may be numbered something like 2, 2a, 3, 3α, 3β etc. python has the OrderedDict() in its collections module. In Lua, the best I could find was entering the chapter numbers into an array (ipair) and then retrieve it from there. Maybe there is a better way? All of this just to say how grateful I am for the way Hans, Taco, Wolfgang, Luigi, and the other developers have enhanced Lua. Thanks guys, you make my work much more pleasant and efficient! Thomas ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] further experiments with lua
On 1/9/19 9:47 AM, Hans Hagen wrote: mtxrun has al the basic modules in it but not the character ones (thinking of it, i can add an autoload for that, maybe i should do that) so you need: require "char-ini" Hans, Luigi, thanks a lot, that solves it! Maybe autoload or at least a small hint in cld-mkiv.pdf? Thomas ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] further experiments with lua
On Wed, Jan 9, 2019 at 9:47 AM Hans Hagen wrote: > > so you need: > > require "char-ini" > > local s = "Ä" > > also if not characters then require("char-ini") end local s = "Ä" print(characters.uccode(s)) -- luigi ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] nice overview of tex
> There are two extensive historic articles on tex here: > > http://walden-family.com/ieee/texhistory.html > — … LuaTEX is perhaps the most recent fundamentally new development in the TEX world. YES ! ;-) .F signature.asc Description: Message signed with OpenPGP using GPGMail ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] nice overview of tex
Hi, There are two extensive historic articles on tex here: http://walden-family.com/ieee/texhistory.html -- - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] further experiments with lua
On 1/9/2019 8:43 AM, Thomas A. Schmitz wrote: Hi Hans, I'm doing some further experiments with the utf and lpeg libraries. This code fails, and I don't understand why: local s = "Ä" print(characters.uccode(s)) mtxrun --script test.lua ./test.lua:3: attempt to index global 'characters' (a nil value) mtxrun has al the basic modules in it but not the character ones (thinking of it, i can add an autoload for that, maybe i should do that) so you need: require "char-ini" local s = "Ä" print(characters.uccode(s)) which will load char-def.lua (you really don't want that in mtxrun.lua embedded) and char-ini.lua Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___