Check-in [887d7dac36]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | break long titles, man page updates |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
887d7dac36425dc20d428c4891c106d5 |
User & Date: | mario 2022-08-08 21:17:20 |
Context
2022-10-13
| ||
08:19 | introduce comment-preservation of original text check-in: 6a653f14b2 user: mario tags: trunk | |
2022-08-08
| ||
21:17 | break long titles, man page updates check-in: 887d7dac36 user: mario tags: trunk | |
2022-08-07
| ||
08:53 | Add --help flag, restructure a bit check-in: e6b2149002 user: mario tags: trunk | |
Changes
Changes to dingonyms/dingonyms.py.
︙ | ︙ | |||
48 49 50 51 52 53 54 | # | \--de | (-ot -wx -sd) | MIXED | # | \--no-antonyms | -na | FLAG | # | \--no-headers | -nh | FLAG | # | \--async | \--parallel \--io | FLAG | # # Flags can be abbreviated and also combined: `--thes --merrweb` would query two # services at once, or `--all` even all. While `--en` or `--de` run through language- | > | | | | | | | | | < < < | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | # | \--de | (-ot -wx -sd) | MIXED | # | \--no-antonyms | -na | FLAG | # | \--no-headers | -nh | FLAG | # | \--async | \--parallel \--io | FLAG | # # Flags can be abbreviated and also combined: `--thes --merrweb` would query two # services at once, or `--all` even all. While `--en` or `--de` run through language- # specific functions; and `--parallel` speeds up fetching, but may mangle output. # See the man page for more details. (There is a man page.) # # ### CONFIG IN ~/.dingrc (take care to change `3` to available index) # # > set searchmeth(3,name) {Synonyms (EN)} # > set searchmeth(3,type) {3} # > set searchmeth(3,dictfile) {} # > set searchmeth(3,separator) { :: } # > set searchmeth(3,language1) {Group} # > set searchmeth(3,language2) {Synonyms} # > set searchmeth(3,grepcmd) {dingonyms} # > set searchmeth(3,grepopts) {--async --thesaurus --merriamwebster --wordhippo} # > set searchmeth(3,maxlength) {30} # > set searchmeth(3,maxresults) {200} # > set searchmeth(3,minlength) {2} # > set searchmeth(3,shapedresult) {1} # > set searchmeth(3,foldedresult) {0} # # You might want to add one entry for each search backend even. # (Unique index, title/name, and grepopts --parameter each.) # # ### SETUP (pip3 install -U dingonyms) # # You might have to symlink `~/.local/bin/dingonyms` into `~/bin` after # installation. pip-package binaries are often only picked up in # terminal/interactive shells. # # ### Hijack as module # # Obviously this is primarily a CLI tool, but can be utilized per monkeypatching: # # > import dingonyms # > ls = [] # > dingonyms.out.alternatives = lambda *x: ls.append(x) # > dingonyms.lookup.merriamwebster("ornate") # # Notably a few more out.* methods could require overriding. # import sys, os, asyncio, re import requests, json, html, textwrap try: sys.stdout.reconfigure(encoding="utf-8") except: pass# and pray |
︙ | ︙ | |||
132 133 134 135 136 137 138 139 140 141 142 | return rows @staticmethod def alternatives(title, wordlist, fold=True): """ craft `Word :: Synonyms` lines """ if fold: wordlist = out.fold(wordlist) if out.no_antonyms and re.search("\{Ant|\{Near|π¬|β", title, re.U): return pipes = len(wordlist) - len(title.split("|")) title = title + (" |" * pipes) | > > > > > > | > > | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | return rows @staticmethod def alternatives(title, wordlist, fold=True): """ craft `Word :: Synonyms` lines """ if fold: wordlist = out.fold(wordlist) title = re.sub("([^|]{45,55})\\b(?=.*\w)", "\\1 |", title) title = re.sub("[\\x00-\x1F]", "", title) #print(f"==={title}===") if out.no_antonyms and re.search("\{Ant|\{Near|π¬|β", title, re.U): return pipes = len(wordlist) - len(title.split("|")) title = title + (" |" * pipes) print( re.sub( "[\\x00-\x1F]", "", f"{title} :: {' | '.join(wordlist)}" ) ) @staticmethod def site(name): """ output prefix for online service """ if out.no_headers: return print(f"β {'{'+name+'}'}") |
︙ | ︙ | |||
465 466 467 468 469 470 471 472 473 474 475 476 477 478 | def help(self, *w): """ ^h$ | help | print syntax and flags """ print("Syntax:\n dingonyms [--backend] word") #print(""" dictcc en-fr -- "word" """) print("Flags:") for name, method, doc in self._methods(): flag = re.findall("\s*([\w\-.]+)\s*\|", doc) help = re.findall("\|\s*(\w+\s*[^|]+(?<!\s))\s*$", doc) if flag: print(f" --{flag[0]:15}\t{help[0] if help else ''}") def _methods(self): # shorthand iterator | > | 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | def help(self, *w): """ ^h$ | help | print syntax and flags """ print("Syntax:\n dingonyms [--backend] word") #print(""" dictcc en-fr -- "word" """) print("Flags:") for name, method, doc in self._methods(): # lazy regex extraction of primary --parameter and |trailing explanation flag = re.findall("\s*([\w\-.]+)\s*\|", doc) help = re.findall("\|\s*(\w+\s*[^|]+(?<!\s))\s*$", doc) if flag: print(f" --{flag[0]:15}\t{help[0] if help else ''}") def _methods(self): # shorthand iterator |
︙ | ︙ |
Changes to dingonyms/man/dingonyms.1.
1 2 3 4 5 6 7 8 9 10 11 12 13 | .\"t .\" Automatically generated by Pandoc 2.5 .\" .TH "dingonyms" "1" "" "for ding" "Version 0.5" .hy .SH NAME .PP dingonyms \[em] basic synonym/antonym lookup tool .SH SYNOPSIS .PP \f[B]dingonyms\f[R] \[dq]word\[dq] .PP \f[B]dingonyms\f[R] [\f[I]\-\-thesaurus\f[R]] | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | .\"t .\" Automatically generated by Pandoc 2.5 .\" .TH "dingonyms" "1" "" "for ding" "Version 0.5" .hy .SH NAME .PP dingonyms \[em] basic synonym/antonym lookup tool .SH SYNOPSIS .PP \f[B]dingonyms\f[R] \[dq]word\[dq] .PP \f[B]dingonyms\f[R] [\f[I]\-\-thesaurus\f[R]] [\f[I]\-\-merriamwebster\f[R]] [\f[I]\-\-wordhippo\f[R]] \[dq]find\[dq] .PP \f[B]dingonyms\f[R] [\f[I]\-\-openthesaurus\f[R] | \f[I]\-\-woxikon\f[R] | \f[I]\-\-urban\f[R]] \[dq]Wort\[dq] .PP \f[B]dingonyms\f[R] [\f[I]\-\-reverso\f[R] | \f[I]\-\-fr\f[R] | \f[I]\-\-es\f[R] | \f[I]\-\-it\f[R] | \f[I]\-\-jp\f[R]] \[dq]bonjour\[dq] .PP \f[B]dingonyms\f[R] [\f[I]\-\-no\-antonyms\f[R]] [\f[I]\-\-async\f[R]] \f[I]\-\-all\f[R] \[dq]word\[dq] .PP \f[B]dictcc\f[R] [\f[I]en\-es\f[R] | \f[I]en\-ru\f[R] | \f[I]de\-nl\f[R] | \f[I]de\-it\f[R]] \[dq]translate\[dq] .SH DESCRIPTION .PP To be used as lookup tool for \f[B]ding\f[R](1). Scans the specified online service for synonyms. .PD 0 .P .PD It\[cq]s not very useful as CLI tool by itself, because of the particular dict formatting. .SH PARAMS .PP Parameters can be introdoced with any combination of \f[I]\-\f[R] or \f[I]\-\-\f[R] dashes or \f[I]+\f[R] signs. .PD 0 .P .PD Most can also be abbreviated (should cover some typos). .PP .TS tab(@); l l l. T{ Parameter T}@T{ |
︙ | ︙ | |||
130 131 132 133 134 135 136 | \-sd \[en]desyn T}@T{ DE T} T{ \-\-all T}@T{ | | | | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | \-sd \[en]desyn T}@T{ DE T} T{ \-\-all T}@T{ (\-t +mw +syn +rev +ot +wx +urban) T}@T{ MIXED T} T{ \-\-en T}@T{ (\-t +mw +syn +rev) T}@T{ MIXED T} T{ \-\-de T}@T{ (\-ot \-wx \-sd) |
︙ | ︙ | |||
165 166 167 168 169 170 171 | \-nh T}@T{ FLAG T} T{ \-\-async T}@T{ | | | | | | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | \-nh T}@T{ FLAG T} T{ \-\-async T}@T{ \-\-parallel ++io T}@T{ FLAG T} .TE .PP They can also be combined (\f[B]dingonyms\f[R] \f[I]\-t \-mw \-u\f[R] \[dq]find\[dq]), so two or more services get queried at once. .IP \[bu] 2 And obviously there\[cq]s also \f[I]\-\-all\f[R] to query most supported sites. .IP \[bu] 2 While \f[I]\-\-en\f[R] and \f[I]\-\-de\f[R] combine the other main services. .IP \[bu] 2 Reverso offers some alternative languages (\-fr, \-it, \-ru). .IP \[bu] 2 And \-\-dictcc that allows for pair\-language specifiers (\-en\-tr, |
︙ | ︙ | |||
202 203 204 205 206 207 208 | And \f[I]\-\-asnyc\f[R] speeds up the processing of multiple sites, at the cost of potentially intermingling their output. It\[cq]s a rather crude threading scheme, and no care has been taken to rewrite dingonyms to fully support that. It\[cq]s primarily meant for \-\-all and \-\-de, \-\-en. There\[cq]s preliminary support for asyncing selected sites as well (e.g.\ \f[B]dingonyms \-\-async ++thes ++merr ++urb | | | | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | And \f[I]\-\-asnyc\f[R] speeds up the processing of multiple sites, at the cost of potentially intermingling their output. It\[cq]s a rather crude threading scheme, and no care has been taken to rewrite dingonyms to fully support that. It\[cq]s primarily meant for \-\-all and \-\-de, \-\-en. There\[cq]s preliminary support for asyncing selected sites as well (e.g.\ \f[B]dingonyms \-\-async ++thes ++merr ++urb \[dq]word\[dq]\f[R]), where it would be less likely mash up antonyms. (The execution speed of the regex+print loops determines if there\[cq]s any mashup whenever HTTP requests complete at the same time.) .SH DICTCC .PP The dictcc mode is special, in that it provides an actual translation dictionary between different languages. The default mode is en\[->]de, but alternative \f[I]\-\-from\-to\f[R] options can be specified. Additionally there\[cq]s a commandline shortcut just for this backend: .PP \f[B]dictcc\f[R] \f[I]en\-it\f[R] \-\- \[dq]translate\[dq] .PP The \-\- is optional as is the \-\-lng\-lng dash prefix. Otherwise it\[cq]s the same as invoking dingonyms. .SH CONFIG .PP The search services can be configured through the GUI (somewhat fiddly with Change+New), or by editing \f[I]\[ti]/.dingrc\f[R] directly. |
︙ | ︙ |
Changes to dingonyms/man/dingonyms.md.
︙ | ︙ | |||
8 9 10 11 12 13 14 | SYNOPSIS ======== **dingonyms** \"word\" | | | | | | | | | | | | | | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | SYNOPSIS ======== **dingonyms** \"word\" **dingonyms** \[*\--thesaurus*] \[*\--merriamwebster*] \[*\--wordhippo*] \"find" **dingonyms** \[*\--openthesaurus* | *\--woxikon* | *\--urban*] \"Wort" **dingonyms** \[*\--reverso* | *\--fr* | *\--es* | *\--it* | *\--jp*] \"bonjour" **dingonyms** \[*\--no-antonyms*] \[*\--async*] *\--all* \"word" **dictcc** \[*en-es* | *en-ru* | *de-nl* | *de-it*] \"translate" DESCRIPTION =========== To be used as lookup tool for **ding**(1). Scans the specified online service for synonyms. It's not very useful as CLI tool by itself, because of the particular dict formatting. PARAMS ====== Parameters can be introdoced with any combination of *\-* or *\-\-* dashes or *\+* signs. Most can also be abbreviated (should cover some typos). | Parameter | Aliases | Class | |-------------------|---------------------------------------------|-------| | \--thesaurus | -t --thes | EN | | \--merriamwebster | -mw --merr \--webster \--merweb | EN | | \--synonym | -s --syn -\-synonym.com | EN | | \--reverso | \--rev // -fr -es -it -pt -nl -ru -jp | EN/\**| | \--wordhippo | -hippo --wordhip | EN | | \--mobythesaurus | -mby --moby | EN | | \--urban | -u --urb \--ubn |LEXICON| | \--dictcc | --en-es --en-it --de-fr --en-pt | DICT | | \--openthesaurus | -ot \--othes --open | DE | | \--woxikon | -wx \--woxi | DE | | \--synonyme_de | -sd --desyn | DE | | \--all | (-t +mw +syn +rev +ot +wx +urban) | MIXED | | \--en | (-t +mw +syn +rev) | MIXED | | \--de | (-ot -wx -sd) | MIXED | | \--no-antonyms | -na | FLAG | | \--no-headers | -nh | FLAG | | \--async | \--parallel \++io | FLAG | They can also be combined (**dingonyms** *-t -mw -u* \"find\"), so two or more services get queried at once. * And obviously there's also *\--all* to query most supported sites. * While *\--en* and *\--de* combine the other main services. * Reverso offers some alternative languages (-fr, -it, -ru). * And \--dictcc that allows for pair-language specifiers (-en-tr, -de-fr) Execution flags should/must be noted before any translation service: * The *\--no-antonyms* flag isn't consistently supported by all backends. (It's actually more effort to skip around unwanted data, rather just outputting it as it comes in.) * *\--no-headers* to omit the "β {Sitename}" titles before any output. * And *\--asnyc* speeds up the processing of multiple sites, at the cost of potentially intermingling their output. It's a rather crude threading scheme, and no care has been taken to rewrite dingonyms to fully support that. It's primarily meant for \--all and \--de, \--en. There's preliminary support for asyncing selected sites as well (e.g. **dingonyms \--async ++thes ++merr ++urb \"word\"**), where it would be less likely mash up antonyms. (The execution speed of the regex+print loops determines if there's any mashup whenever HTTP requests complete at the same time.) DICTCC ====== The dictcc mode is special, in that it provides an actual translation dictionary between different languages. The default mode is enβde, but alternative *\--from-to* options can be specified. Additionally there's a commandline shortcut just for this backend: **dictcc** *en-it* \-- \"translate\" The \-- is optional as is the \--lng-lng dash prefix. Otherwise it's the same as invoking dingonyms. CONFIG ====== |
︙ | ︙ |