vim: thesaurus

263 views
Skip to first unread message

Guido Milanese

unread,
Feb 12, 2016, 4:44:19 AM2/12/16
to vim_use digest subscribers
Dear Experts,
I am using gvim (on xubuntu 15.10) for most of my daily work. I write
my scholarly work using LaTeX + BibTeX, and I normally use the
excellent LaTeX plugin. I recently tried TeXStudio, and the only
feature I found better was the easy access to the [Libre | Open]office
thesaurus. I browsed the archives of this group and googled a while,
but I did not find a real answer to this problem. Being no native
speaker of English this feature is particularly important for me. Is
the online thesaurus plugin the only possible solution?

Many thanks for your kind attention,
guido, italy

--
Guido Milanese - Professor of Classics - Docteur H.C. Paris ICP
http://docenti.unicatt.it/ita/guido_fabrizio_milanese

Russell Urquhart

unread,
Feb 12, 2016, 8:56:07 AM2/12/16
to vim...@googlegroups.com
Hi Guido,

I too use vim for my technical writing. AFAIK, i think the online thesaurus is the only thing available. (I hope we find out that there are other options.)

You might also want check out the Grammer checker plugin for vim:

http://www.vim.org/scripts/script.php?script_id=3223

If you find any other things, please share!


Russ
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Nicola

unread,
Feb 12, 2016, 11:21:17 AM2/12/16
to vim...@googlegroups.com
On 2016-02-12 09:44:05 +0000, Guido Milanese said:

> Dear Experts,
> I am using gvim (on xubuntu 15.10) for most of my daily work. I write
> my scholarly work using LaTeX + BibTeX, and I normally use the
> excellent LaTeX plugin. I recently tried TeXStudio, and the only
> feature I found better was the easy access to the [Libre | Open]office
> thesaurus. I browsed the archives of this group and googled a while,
> but I did not find a real answer to this problem. Being no native
> speaker of English this feature is particularly important for me. Is
> the online thesaurus plugin the only possible solution?

One thing that may be used directly with Vim is the file mthesaur.txt
from Gutenberg: http://www.gutenberg.org/files/3202/. But I haven't
found it terribly useful (way too many synonyms).

Another possibility is to download an .oxt file, change the suffix to
.zip, uncompress it, and open the thesaurus .dat file (it is a text
file). I have taken a quick look at one of them, and it should not be
too hard to turn it into a format usable by Vim: removing the first
line and the parts in parentheses should be enough.

Hope this helps,
Nicola


Nicola

unread,
Feb 12, 2016, 1:04:30 PM2/12/16
to vim...@googlegroups.com
On 2016-02-12 14:16:50 +0000, Nicola said:

> Another possibility is to download an .oxt file, change the suffix to
> .zip, uncompress it, and open the thesaurus .dat file (it is a text
> file). I have taken a quick look at one of them, and it should not be
> too hard to turn it into a format usable by Vim: removing the first
> line and the parts in parentheses should be enough.

Mmh, not so fast. Each entry in a .dat file has this form:

abbreviate|2
(verb)|reduce (generic term)
(verb)|abridge|foreshorten|shorten|cut|contract|reduce|...

You need to put each entry on a single line that looks like this:

abbreviate|reduce|abridge|foreshorten|...

This may be done, for example, with awk:

awk '/\|[0-9]+$/{if (NR!=1) print "";sub(/\|[0-9]+$/,"");printf
$0;next}{printf "|"$0}END{print "";}' th_en_US_v2.dat >th_en_US_v2.txt

(This command is a single line.)

Then, you may remove the spurious parts, like (verb) or (generic term).
That may be done by editing the thesaurus in Vim:

:%s/([^)]\+)//g

There are some other adjustments to be done, like || to be replaced
by |, and some spaces to be removed.

But, there is an inherent limitation in Vim (as far as I know). If you
ask for suggestions in LibreOffice/OpenOffice for 'abbreviate', you'll
get the list above. Vim, instead, will show you *all* the words in
*all* the lines in the thesaurus containing 'abbreviate'. So, for
example, since the thesaurus also contains:

bowdlerise|1
(verb)|bowdlerize|expurgate|...|abbreviate (generic term)|...

you'll get 'bowdlerise', too.

I wish there were an option to tell Vim to offer only the suggestions
in those lines of a thesaurus that *start* with a given word.

Nicola


Nicola

unread,
Feb 12, 2016, 1:18:20 PM2/12/16
to vim...@googlegroups.com
On 2016-02-12 18:04:09 +0000, Nicola said:

> On 2016-02-12 14:16:50 +0000, Nicola said:
>
>> Another possibility is to download an .oxt file, change the suffix to
>> .zip, uncompress it, and open the thesaurus .dat file (it is a text
>> file). I have taken a quick look at one of them, and it should not be
>> too hard to turn it into a format usable by Vim: removing the first
>> line and the parts in parentheses should be enough.
>
> Mmh, not so fast. Each entry in a .dat file has this form:
>
> abbreviate|2
> (verb)|reduce (generic term)
> (verb)|abridge|foreshorten|shorten|cut|contract|reduce|...

Another idea: one might set completefunc to call a function that searches
a file in the above format. Such function might even use the associated
.idx file for faster retrieval.

Nicola


David Woodfall

unread,
Feb 12, 2016, 1:55:29 PM2/12/16
to vim_use digest subscribers
>Dear Experts,
>I am using gvim (on xubuntu 15.10) for most of my daily work. I write
>my scholarly work using LaTeX + BibTeX, and I normally use the
>excellent LaTeX plugin. I recently tried TeXStudio, and the only
>feature I found better was the easy access to the [Libre | Open]office
>thesaurus. I browsed the archives of this group and googled a while,
>but I did not find a real answer to this problem. Being no native
>speaker of English this feature is particularly important for me. Is
>the online thesaurus plugin the only possible solution?
>
>Many thanks for your kind attention,
>guido, italy

Hi Guido

I've been working on a thesaurus that uses aiksaurus:

https://github.com/slackhead/vim-vaiksaurus

It's quite a simple plugin and only requires aiksaurus from here:

http://aiksaurus.sourceforge.net/

Hope that you find it useful.

David

Guido Milanese

unread,
Feb 14, 2016, 9:57:10 AM2/14/16
to vim_use
With my warmest thanks to all those who replied to my question, I take the liberty of posting a sort of summary about "thesauri" and the like.

1. *ENGLISH ONLY*
1a. Spelling checkers
The internal spelling checkers are excellent -- several varieties of the language.

1b. Grammar checkers
As suggested by Russ <russur...@verizon.net> I tried the grammar checker plugin for the LanguageTool grammar checker: http://www.vim.org/scripts/script.php?script_id=3223
Very good, even if a bit slow.

1c. Thesauri
Following the example posted by Nicola <nvitac...@gmail.com>, I checked the word "abbreviate" with 3 different options, and this is what I've got:

/PLUGIN FOR ONLINE THESAURUS/
http://www.vim.org/scripts/script.php?script_id=4588
Main entry: abbreviate
Definition: verb shorten
Synonyms: abridge, compress, abstract, clip, condense, contract, cut,
digest, encapsulate, pare, prune, reduce, summarize, trim, boil down, cut
back, cut down, cut off, cut out, get to the meat, put in a nutshell, take
out
Definition: verb cut short an activity
Synonyms: abort, truncate, curtail, restrict, stop short

/PLUGIN FOR AIKSAURUS/
https://github.com/slackhead/vim-vaiksaurus
written and suggested by David Woodfall <da...@dawoodfall.net>
=== void =====================
abbreviate, abridge, bowdlerize, censor, cross out, delete, edit, erase,
expunge, expurgate, kill, omit, rescind, rub out, strike off, strike
out, void
=== truncate =================
abbreviate, abridge, abstract, bob, boil down, compress, condense, crop,
curtail, cut back, cut down, elide, epitomize, foreshorten, mow, nip,
prune, reap, recap, recapitulate, shave, shear, snub, stunt, sum up,
summarize, take in, telescope, truncate
=== reduce ===================
abbreviate, abridge, censor, circumscribe, compact, compress, concentrate,
condense, congest, consolidate, constrict, contract, cram, curtail,
decrease, draw in, knit, limit, narrow, pucker, purse, reduce, restrict,
shorten, solidify, strangle, wrinkle

ONLINE THESAURUS (no plugin as far as I know)
http://trovami.altervista.org/en/sinonimi
Synonyms of abbreviate:
(verb) reduce
(verb) abridge, foreshorten, shorten, cut, contract, reduce, decrease, lessen, minify, expand (antonym)

Different offer -- all of them useful in their own way.

#############################################

2. *NOT ENGLISH OR MORE THAN ONE LANGUAGE*
2a. Spelling checkers
The internal spelling checkers are excellent. I frequently use several languages in the same document. For example, English, Latin, and Italian. Using the internal spelling checker (set set spelllang=en,la,it) it's all right.

2b. Grammar checkers
The plugin mentioned at (1b) is OK, because, if you do not set a particular language at installation time, the programme reads the current setting from /spelllang=/. Good if you are writing in ONE language, anyway.

2c. Thesauri
* Standalone: only English -- see above.
* Online: see the online thesaurus (no plugin as far as I know)
http://trovami.altervista.org/en/sinonimi -- works for 9 languages.

As a conclusion, since in my case the reason why I was using TexStudio (writing LaTeX) was the English thesaurus, but for anything else I prefer (g)vim + the LaTeX plugin, I see no reason to leave (g)vim and I find it superior for the ability of spelling checker in various languages in the same document.

If this document may be of some general interest, I can elaborate it and keep it updated.
Thank you as usual, guido (italy)


Chong He

unread,
Apr 13, 2016, 1:16:49 AM4/13/16
to vim_use
I have written a plugin recently to use multiple backends for thesaurus checking and replacing. Currently i have only written 3 backends(thesaurus.com, mthesaur.txt and datamuse.com) for it and the checking is sequential, stopping at the first successful query to save query time. I wonder what can I do from this point to make it more useful.

https://github.com/Ron89/thesaurus_query.vim

Josef Fortier

unread,
Apr 14, 2016, 3:25:52 PM4/14/16
to vim_use
Hi Chong:

This looks quite nice :-) But it's worth noting in the README.md that it requires vim with python.

On Wednesday, April 13, 2016 at 12:16:49 AM UTC-5, Chong He wrote:
> https://github.com/Ron89/thesaurus_query.vim

Message has been deleted

Chong He

unread,
Apr 15, 2016, 2:40:44 AM4/15/16
to vim_use

Hi Josef,

Thanks for reminding, the message is added.

francois...@gmail.com

unread,
Jan 29, 2017, 2:45:52 PM1/29/17
to vim_use
I have written a few lines of code to use synonyms in Vim in multiple
languages. I have posted this in:

http://stackoverflow.com/questions/33453468/vim-thesaurus-file

this is the answer at the bottom of the page. I have already contacted Guido
Milanese, who found it useful. Along the lines of Nicola's suggestions, this
solution uses awk to access thesauri from LibreOffice. Other people on the
list may find it useful, although it should work only on Unix-like systems.
Reply all
Reply to author
Forward
0 new messages