4

I recently stumbled upon this question asking for recommendations for an offline command-line dictionary.

In the same spirit, is there any online command-line thesaurus available for Ubuntu?

0

3 Answers 3

1

Not on the Debian and Ubuntu repositories but you can try this one out from Github davidgu/thesaurus-cli.

Installation instructions and usage are on the repository link.

1
  • Thanks. Went through the code of the client, and it is astonishingly simple -- just parses thesaurus.com. Works on my raspberry pi (raspbian).
    – Nurmister
    Oct 1, 2018 at 18:24
1

This worked for me:

sudo apt install xclip notify-send dict

and then put this command on some keyboard shortcut

notify-send "$(dict -d moby-thesaurus "$(xclip -o -selection primary)")"

e.g in xfce4, where the above command is contained in the script "thesaurus.sh":

xfconf-query -c xfce4-keyboard-shortcuts -p "/commands/custom/<Super>t" -n -t string -s "thesaurus.sh"

Then highlight the word in question and press Super+t should pop up alternative words.

2
  • I get a N: Unable to locate package notify-send E: No packages found when I try to install it. It doesn't seem to be in Kubuntu. libnotify-bin is for Ubuntu and others, not Kubuntu.
    – emk2203
    Nov 22, 2021 at 21:24
  • For Kubuntu, it should be kdialog.
    – emk2203
    Nov 22, 2021 at 21:29
1

Wasn't able to run the proposed answer, failed in installation, also seems like thesaurus.com has gone javascript-only. So I quickly wrapped up this as I wanted this myself:

perl -wlE 'use Mojo::JSON qw/decode_json/; use Mojo::UserAgent; my $word = shift; my $tx = Mojo::UserAgent->new->get("https://www.thesaurus.com/browse/" . $word); if ($tx->res->body =~ /<script>window.INITIAL_STATE = (.*?);<\/script>/) { my $json = $1; $json =~ s/\bundefined\b/null/gmx; my @defs = @{ decode_json($json)->{searchData}->{relatedWordsApiData}->{data} }; print "$word:"; for my $def (@defs) { print "  $def->{definition}:"; print "    synonyms: " . join ", ", (map { $_->{term} } @{ $def->{synonyms} }); print "    antonyms: " . join ", ", (map { $_->{term} } @{ $def->{antonyms} }); } } else { die "$word not found" unless $word; }' clumsy
clumsy:
  crude, awkward:
    synonyms: bad-mannered, barbaric, bearish, cantankerous, churlish, cloddish, clodhopping, clownish, clumsy, coarse, countrified, gross, gruff, ill-bred, ill-mannered, impolite, inurbane, loud, loutish, lowbred, oafish, ornery, out-of-line, out-of-order, provincial, rough, rude, rustic, swinish, tasteless, ugly, uncivilized, uncouth, uncultured, uneducated, ungracious, unpoised, unpolished, unrefined, vulgar
    antonyms: delicate, gentle, smooth, sophisticated, refined, polished, nice, exciting, cultured, charming, pleasant, polite, mannerly, kind
  unskillful:
    synonyms: awkward, blundering, bungling, butterfingered, clumsy, gauche, graceless, inept, maladroit, unpolished
    antonyms: 
  vulgar, unpolished in manner:
    synonyms: awkward, backward, barnyard, boorish, cheap, cloddish, clumsy, coarse, crass, dirty, earthy, filthy, foul, grody, gross, ignorant, ill-bred, indecent, indelicate, inelegant, insensible, lewd, loud, loud-mouthed, loutish, lowbred, oafish, obscene, raunchy, raw, rough, rude, savage, smutty, tacky, tactless, uncouth, unenlightened, ungainly, unskillful
    antonyms: formal, polished, gentle, delicate, smooth, nice, pure, decent, clean, sophisticated, refined, stilted, planned, tasteful, moral, kind, polite
  vulgar, unpolished in manner:
    synonyms: awkward, backward, barnyard, boorish, cheap, cloddish, clumsy, coarse, crass, dirty, earthy, filthy, foul, grody, gross, ignorant, ill-bred, indecent, indelicate, inelegant, insensible, lewd, loud, loud-mouthed, loutish, lowbred, oafish, obscene, raunchy, raw, rough, rude, savage, smutty, tacky, tactless, uncouth, unenlightened, ungainly, unskillful
    antonyms: formal, polished, gentle, delicate, smooth, nice, pure, decent, clean, sophisticated, refined, stilted, planned, tasteful, moral, kind, polite
  cumbersome:
    synonyms: awkward, bulky, clumsy, heavy, hefty, ungainly, unmanageable, unwieldy
    antonyms: 
  tactless, unsophisticated:
    synonyms: awkward, bumbling, clumsy, crude, graceless, green, halting, ham-handed, heavy-handed, ignorant, ill-bred, ill-mannered, inelegant, inept, insensitive, lacking, maladroit, oafish, uncouth, uncultured, unhappy, unpolished, wooden
    antonyms: sophisticated, refined, polished, tasteful, tactful, mannerly, graceful, elegant
3
  • Would it be enough to install libmojolicious-perl, or do I need more modules? The line throws an error that mojo is missing -- can't locate Mojo/JSON.pm. When I install it, I still get malformed JSON string, neither tag, array, object, number, string or atom, at character offset 6708 (before "undefined,"key":"f6j...") at /usr/share/perl5/Mojo/JSON.pm line 31.
    – emk2203
    Nov 22, 2021 at 18:41
  • 1
    Sorry for late answer. It seems the "JSON" on the page is now using the value "undefined" in one of the fields. I have edited the answer with a fix to replace "undefined" with "null" so the JSON is parseable.
    – nicomen
    Dec 15, 2021 at 2:14
  • Thanks, works now as expected on 22.04.
    – emk2203
    Dec 15, 2021 at 21:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .