Hi I got interest in a solution posted here & put the suggested function in a bash script
leaving at ~/.bin
so, a dir
under path
. Then performed $chmod +x verbteacher.sh
for easy calling from $
anywhere in the command line but it does not work. I tried to, kind of, re-open the question & tried also the suggestion of following the above mentioned answer, kind of closely & putting the function in the .bashrc
file but it still does not work for me (& it seems is not the best (practice (I'm sorry))) so just hereby asking for some more help. I would appreciate it.

- 3
- 1
3 Answers
The function (directly from that answer, with only minor modifications):
verbteacher () {
wget -qO - http://conjugator.reverso.net/conjugation-english-verb-"$1".html | \
sed -n "/>Preterite\|>Past</{s@<[^>]*>@ @g;s/\s\+/ /g;/e I/s/.* I \([^ ]*\) you .*/Simple past: \1/;/ Past/s/ Past /Past participle: /;p}" ;
}
This can be put into your .bashrc
file which would define it for any new shell started (not the current shell session).
You could also turn it into a script:
#!/bin/sh
wget -qO - http://conjugator.reverso.net/conjugation-english-verb-"$1".html | \
sed -n "/>Preterite\|>Past</{s@<[^>]*>@ @g;s/\s\+/ /g;/e I/s/.* I \([^ ]*\) you .*/Simple past: \1/;/ Past/s/ Past /Past participle: /;p}"
This should be saved into a file that you make executable and put somewhere in a directory that is in your $PATH
.
Note: I have not looked carefully at what this code actually does. It may possibly be further improved. This answer is about the issue with just actually using the function provided.

- 333,661
I found an API that handles conjugations. I have created this function that will query it but it requires jq
. Also the output is rather verbose but I'm sure it can be pared down by someone that knows jq
better than me:
verbteacher () {
curl -s "http://api.ultralingua.com/api/conjugations/eng/$1" | jq '.[] | {tense: .partofspeech.tense, verb: .surfaceform}'
}
Usage:
$ verbteacher run
{
"tense": "infinitive",
"verb": "run"
}
{
"tense": "pastparticiple",
"verb": "run"
}
{
"tense": "presentparticiple",
"verb": "running"
}
{
"tense": "present",
"verb": "run"
}
{
"tense": "present",
"verb": "run"
}
{
"tense": "present",
"verb": "runs"
}
....

- 37,005
If you want the conjugations (on link address, after /conjugations/
you may choose the language you want to, in my case I choosed french /fra/
) values, write this on the last line of .bashrc
:
conjfra () {
curl -s "http://api.ultralingua.com/api/2.0/conjugations/fra/$1" | jq -r '.[] | {tense: .conjugations}'
}
Merci! EDIT: My bad! sorry for that, I forgot to add the tab space onset on second line, now is correct.

- 16
- 2
-
Thanks Mahanb Hamananda , I tried it but it should be sth missing as I only got as output:
parse error: Invalid numeric literal at line 1, column 10
Could you, please check it out?? I appreciate it. – RS. Montalvo Jan 21 '19 at 12:46 -
My bad! sorry for that, I forgot to add the tab space onset of second line, now is correct. – Mahanb Hamananda Jan 22 '19 at 02:26
.bashrc
and/or closed/reopened your terminal? If so what is the output of:declare -f verbteacher
. Also where did you hear it is not best practice to put functions in.bashrc
? – jesse_b Apr 06 '18 at 20:23$declare -f verbteacher
is:verbteacher () { wget -qO - http://conjugator.reverso.net/conjugation-english-verb-"$1".html | sed -n "/>Preterite\|>Past</{s@<[^>]*>@ @g;s/\s\+/ /g;/e I/s/.* I \([^ ]*\) you .*/Simple past: \1/;/ Past/s/ Past /Past participle: /;p}" }
– RS. Montalvo Apr 07 '18 at 01:05