Leo as backbone for dictionary reference service

106 views
Skip to first unread message

Matt Wilkie

unread,
Mar 1, 2018, 5:21:48 PM3/1/18
to leo-editor
A [dream-runner] post

Scenario:

An online dictionary that allows linking to a single specific definition of a word?

 

For example, suppose I want to refer to the specific definition of 'nut' as 'a perforated block usually of metal that has an internal screw thread and is used on a bolt or screw'.

 

This is the 3rd definition on the page http://www.merriam-webster.com/dictionary/nut, but Merriam-Webster only allows linking to the page, not a specific meaning.

 

Wiktionary allows linking to sections in a page, so we can link to Noun or Verb forms for example, but that's still too coarse for this scenario.

 

This a reboot of a question on english.stackexchange.com which was closed as being off-topic for that site. (And at 7 years old is long in the tooth, maybe there is an answer now that didn't exist then.)

 

From <https://softwarerecs.stackexchange.com/questions/48918/an-online-dictionary-that-allows-linking-to-a-single-specific-definition-of-a-wo>

 

 

This would be really cool, and Leo could be a great tool for it's backbone. I'm not thinking about the web service part, but the building the dictionary and then creating the html parts. What's the practical limit for number of nodes in Leo? There's no way I have time to try something like this, but I love the idea. ;-)


Link: workbook.leo#Ideas-->Leo Dictionary Service-->nut-->3



<?xml version="1.0" encoding="utf-8"?>
<!-- Created by Leo: http://leoeditor.com/leo_toc.html -->
<leo_file xmlns:leo="http://leoeditor.com/namespaces/leo-python-editor/1.1" >
<leo_header file_format="2"/>
<vnodes>
<v t="maphew.20180301140232.1" a="E"><vh>Leo Dictionary Service</vh>
<v t="maphew.20180301140249.1" a="E"><vh>nut</vh>
<v t="maphew.20180301140518.1" a="E"><vh>1</vh>
<v t="maphew.20180301140554.1" a="E"><vh>a</vh>
<v t="maphew.20180301140705.1"><vh>(1)</vh></v>
<v t="maphew.20180301140607.1"><vh>(2)</vh></v>
</v>
<v t="maphew.20180301140726.1"><vh>b</vh></v>
</v>
<v t="maphew.20180301141037.1" a="E"><vh>2</vh>
<v t="maphew.20180301141050.1"><vh>a</vh></v>
<v t="maphew.20180301141100.1"><vh>b</vh></v>
</v>
<v t="maphew.20180301141149.1"><vh>3</vh></v>
<v t="maphew.20180301141205.1"><vh>4</vh></v>
<v t="maphew.20180301141215.1"><vh>5</vh></v>
<v t="maphew.20180301141225.1" a="E"><vh>6</vh>
<v t="maphew.20180301141325.1"><vh>a</vh></v>
<v t="maphew.20180301141329.1"><vh>b</vh></v>
</v>
<v t="maphew.20180301141230.1"><vh>7</vh></v>
<v t="maphew.20180301141234.1"><vh>8</vh></v>
<v t="maphew.20180301141238.1"><vh>9</vh></v>
<v t="maphew.20180301141244.1"><vh>10</vh></v>
</v>
</v>
</vnodes>
<tnodes>
<t tx="maphew.20180301140232.1"></t>
<t tx="maphew.20180301140249.1"></t>
<t tx="maphew.20180301140518.1"></t>
<t tx="maphew.20180301140554.1"></t>
<t tx="maphew.20180301140607.1">the kernel of a nut</t>
<t tx="maphew.20180301140705.1">a hard-shelled dry fruit or seed with a separable rind or shell and interior kernel</t>
<t tx="maphew.20180301140726.1">a dry indehiscent one-seeded fruit with a woody pericarp</t>
<t tx="maphew.20180301141037.1"></t>
<t tx="maphew.20180301141050.1">a hard problem or undertaking</t>
<t tx="maphew.20180301141100.1">CORE, HEART</t>
<t tx="maphew.20180301141149.1">a perforated block usually of metal that has an internal screw thread and is used on a bolt or screw for tightening or holding something</t>
<t tx="maphew.20180301141205.1">the ridge in a stringed instrument (such as a violin) over which the strings pass on the upper end of the fingerboard</t>
<t tx="maphew.20180301141215.1">a small lump (as of butter)</t>
<t tx="maphew.20180301141225.1"></t>
<t tx="maphew.20180301141230.1">nuts plural : nonsense —often used interjectionally</t>
<t tx="maphew.20180301141234.1">slang : a person's head</t>
<t tx="maphew.20180301141238.1">usually vulgar : testis</t>
<t tx="maphew.20180301141244.1">the amount of money that must be earned in order to break even</t>
<t tx="maphew.20180301141325.1">a foolish, eccentric, or crazy person</t>
<t tx="maphew.20180301141329.1">enthusiast

    a movie nut
</t>
</tnodes>
</leo_file>



matt
Auto Generated Inline Image 1

Chris George

unread,
Mar 1, 2018, 5:30:41 PM3/1/18
to leo-editor
With Edwards help I cobbled together a script that uses the Wordnet database to generate an overview of a word. It outputs to the log pane.

I use the same script with changes to the wordnet command to generate synonyms as well.

The Wordnet dictionary is pretty comprehensive. It might provide a good local source of data to noodle with.

Chris



w = c.frame.body.wrapper


p = w.getSelectedText()


message = p.replace('"', "'")


command = '/usr/local/WordNet-3.0/bin/wn %s -over' % message




c.controlCommands.executeSubprocess(


    event=None,


    command=command,


)


Chris

Matt Wilkie

unread,
Mar 1, 2018, 7:33:55 PM3/1/18
to leo-editor

With Edwards help I cobbled together a script that uses the Wordnet database to generate an overview of a word. It outputs to the log pane.

thanks for this

Edward K. Ream

unread,
Mar 2, 2018, 3:20:46 AM3/2/18
to leo-editor
On Thu, Mar 1, 2018 at 4:21 PM, Matt Wilkie <map...@gmail.com> wrote:

​> ​
What's the practical limit for number of nodes in Leo?

​Good question.  I don't know the answer in all its details, but here are a few ideas:

1. Leo now supports representing outlines as sqlite databases, with .leo.db extension.  See this post. Afaik, there are no practical limits to such db's nor are there limits in Leo's ability to access them. 

2. Leo uses ​Python's sax parser to parse xml.  This is likely to be significantly slower than using sqlite-based code.

3. Leo scans the outline after loading it, looking for @<file> nodes.  This code skips @ignore trees, so you would want to put the entire outline tree under an @ignore directive.

4. Leo's tree drawing code would likely choke on showing more than a few thousand nodes.  There are several ways around this.  First, one could access the dictionary in a null gui, say from the Leo bridge.  Or one could hide the dict so that it never gets redrawn.

In short, it should be possible to represent a very large outline as a sqlite (.leo.db) file.

Edward

Edward K. Ream

unread,
Mar 2, 2018, 6:28:09 PM3/2/18
to leo-editor
On Friday, March 2, 2018 at 2:20:46 AM UTC-6, Edward K. Ream wrote:

> On Thu, Mar 1, 2018 at 4:21 PM, Matt Wilkie <map...@gmail.com> wrote:
 
> > ​What's the practical limit for number of nodes in Leo?

> 3. Leo scans the outline after loading it, looking for @<file> nodes.  This code skips @ignore trees, so you would want to put the entire outline tree under an @ignore directive.

#771 Support --outline-only command-line argument is a new issue that would skip this pass entirely.

I shall do this only if you actually need it.

Edward

Matt Wilkie

unread,
Mar 2, 2018, 10:15:11 PM3/2/18
to leo-editor

#771 Support --outline-only command-line argument is a new issue that would skip this pass entirely.

I shall do this only if you actually need it.

I don't need it, not right now. I have my hands full with other things. Mostly the intent of the post was to document and share an idea, so I could stop thinking about it and do other things, with the hopeful self-promise that I'd come back to it someday when I do have time.

matt

Edward K. Ream

unread,
Mar 3, 2018, 2:18:55 AM3/3/18
to leo-editor

​That's fine.  There is no milestone attached to this item.

Edward

Joe Orr

unread,
Mar 31, 2018, 4:19:53 PM3/31/18
to leo-editor
This gave me the idea to have Leo Vue be able to outline a page by pointing to it.

HTML5 has an outline spec, and there is an npm module for it, so this seemed like a fairly straightforward task. Turns out there aren't many pages that support the spec. Wikipedia supports the HTML4 spec, but it required a few hacks to get it to work.

Example:

Leo Vue now supports named nodes, so you can also write:

It is also possible to set up a copy of Leo Vue to take the target as a parameter:
 
So you can put any outlineUrl and title as params in the url above and it will attempt to outline it.

These pages make testing a target a bit easier:

I didn't yet find any other good candidates for outlining besides Wikipedia though.

Dictionary.com doesn't work, but there is wiktionary.com:
or

Joe

Edward K. Ream

unread,
Apr 2, 2018, 8:02:39 AM4/2/18
to leo-editor
On Sat, Mar 31, 2018 at 3:19 PM, Joe Orr <joe...@gmail.com> wrote:

​> ​
This gave me the idea to have Leo Vue be able to outline a page by pointing to it.
​...
 
​> ​
So you can put any outlineUrl and title as params in the url above and it will attempt to outline it.

​> ​
These pages make testing a target a bit easier:
> ​I didn't yet find any other good candidates for outlining besides Wikipedia though.

​Well, it's a great start. Many thanks for this work.

Edward

Edward K. Ream

unread,
Apr 2, 2018, 11:44:19 AM4/2/18
to leo-editor
On Monday, April 2, 2018 at 7:02:39 AM UTC-5, Edward K. Ream wrote:
On Sat, Mar 31, 2018 at 3:19 PM, Joe Orr <joe...@gmail.com> wrote:

​> ​
This gave me the idea to have Leo Vue be able to outline a page by pointing to it.

The HTML5 outline standard is bizarre.  All "nodes" are implicit. There is no indication whatever of outline structure. Instead, there is a "standard algorithm" for recognizing nodes. This is less a standard than a standard hack.

Anyway, Leo can clearly already write documents that represent html5 outlines.  I wonder whether that would be useful...

Edward
Reply all
Reply to author
Forward
0 new messages