From owner-freebsd-questions@FreeBSD.ORG Sun Nov 30 07:59:05 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D1E1B1065672 for ; Sun, 30 Nov 2008 07:59:05 +0000 (UTC) (envelope-from kline@thought.org) Received: from aristotle.thought.org (aristotle.thought.org [209.180.213.210]) by mx1.freebsd.org (Postfix) with ESMTP id 7E7898FC0A for ; Sun, 30 Nov 2008 07:59:05 +0000 (UTC) (envelope-from kline@thought.org) Received: from thought.org (tao.thought.org [10.47.0.250]) (authenticated bits=0) by aristotle.thought.org (8.14.2/8.14.2) with ESMTP id mAU7xHml040697; Sat, 29 Nov 2008 23:59:17 -0800 (PST) (envelope-from kline@thought.org) Received: by thought.org (nbSMTP-1.00) for uid 1002 kline@thought.org; Sat, 29 Nov 2008 23:58:45 -0800 (PST) Date: Sat, 29 Nov 2008 23:58:45 -0800 From: Gary Kline To: Polytropon Message-ID: <20081130075845.GA2296@thought.org> References: <20081130045944.GA94896@thought.org> <20081130061104.f595db7e.freebsd@edvax.de> <20081130061731.0691f5ea.freebsd@edvax.de> <20081130065209.GA98518@thought.org> <20081130080721.af3b36d9.freebsd@edvax.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20081130080721.af3b36d9.freebsd@edvax.de> User-Agent: Mutt/1.4.2.3i X-Organization: Thought Unlimited. Public service Unix since 1986. X-Of_Interest: With 22 years of service to the Unix community. X-Spam-Status: No, score=-4.4 required=3.6 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.2.3 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on aristotle.thought.org Cc: FreeBSD Mailing List Subject: Re: for awk experts only. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Nov 2008 07:59:05 -0000 On Sun, Nov 30, 2008 at 08:07:21AM +0100, Polytropon wrote: > On Sat, 29 Nov 2008 22:52:10 -0800, Gary Kline 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