Date: Sat, 29 Nov 2008 23:58:45 -0800 From: Gary Kline <kline@thought.org> To: Polytropon <freebsd@edvax.de> Cc: FreeBSD Mailing List <freebsd-questions@freebsd.org> Subject: Re: for awk experts only. Message-ID: <20081130075845.GA2296@thought.org> In-Reply-To: <20081130080721.af3b36d9.freebsd@edvax.de> References: <20081130045944.GA94896@thought.org> <20081130061104.f595db7e.freebsd@edvax.de> <20081130061731.0691f5ea.freebsd@edvax.de> <20081130065209.GA98518@thought.org> <20081130080721.af3b36d9.freebsd@edvax.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Nov 30, 2008 at 08:07:21AM +0100, Polytropon wrote:
> On Sat, 29 Nov 2008 22:52:10 -0800, Gary Kline <kline@thought.org> wrote:
> > What you have above prints:
> >
> > foot 1 // noun
> > foot 0 // verb
> >
> > so doesn't work entirely, but is a good start.
>
> I'm so stupid. gsub() does not return the result of the
> substitution (as, for example, sprintf() would return the
> string), but the success of the substitution, 1 or 0.
>
>
>
> > (BTW, man gsub turned up
> > nothing, so I'm assuming thhat gsub it part of awk.
>
> Yes, gsub is listed in "man awk" because it's a function from
> within awk.
>
> I've just pkg_add'ed -r WordNet and tried:
>
> % wn foot -over | awk '/Overview/ { printf("%s %s\n", $4, ($3 == "noun") ? "n." : ""); }'
> foot n.
> foot
>
> Of couse, this handles only "noun". If you want to abbreviate
> other kinds of words (e. g. "verb" -> "v.", "adverb" -> "adv.",
> "adjective" -> "adj."), it would be better to implement a short
> awk script as a "wrapper" for the wn command. If you're only
> interested in the first result mentioned, you could test NR == 1.
>
> % wn foot -over | awk '/Overview/ && (NR == 2) { printf("%s %s\n", $4, ($3 == "noun") ? "n." : ""); }'
> foot n.
>
Yeah, "noun" -> "n.", "verb" -> "v.", "adj." -> "a." "adv" is all right.
Benn awhile since I wrote an awk script... but now's the time.
thanks much,
gary
>
>
> --
> Polytropon
> From Magdeburg, Germany
> Happy FreeBSD user since 4.0
> Andra moi ennepe, Mousa, ...
--
Gary Kline kline@thought.org http://www.thought.org Public Service Unix
http://jottings.thought.org http://transfinite.thought.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081130075845.GA2296>
