emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <eric.schulte@gmx.com>
To: Marcelo de Moraes Serpa <celoserpa@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: building tagcloud datastructure in elisp
Date: Wed, 12 Sep 2012 12:58:40 -0600	[thread overview]
Message-ID: <87sjanrrtr.fsf@gmx.com> (raw)
In-Reply-To: <CACHMzOHitX5sDPu5AN+voFCN15NMAZLsPRXo4Un5t43HOe1gjA@mail.gmail.com> (Marcelo de Moraes Serpa's message of "Wed, 12 Sep 2012 13:41:35 -0500")

Marcelo de Moraes Serpa <celoserpa@gmail.com> writes:

> Hi list,
>
> How hard would it be to parse a bunch of org files and build an elisp data
> structure (Hash?) that represents a tagcloud? All tags in all headlines and
> subtrees should be taken into account (for all org files that are parsed).
> Could I use org-element to help me parse this or is there a better way?
>
> I'm just learning the org API, and I've only done a bunch of elisp hacks,
> so any insight would be greatly appreciated!
>
> Thanks,
>
> - Marcelo.

My favorite method of getting word frequencies from text files is the
following.  Sometimes it is easier to just Org-mode files as text files
rather than to use e-lisp.

    # -*- shell-script -*-
    many=20 # to print the 20 most popular words
    cat org-file.org \
        |tr -cs A-Za-z '\n' \
        |tr A-Z a-z \
        |sort \
        |uniq -c \
        |sort -rn \
        |sed ${many}q \
        |sed 's/^ *//' \
        |sed 's/\([^ ]*\) \([^ ]*\)/\2:\1/' \
        |tr '\n' ' ' \
        |sed 's/ $/\n/'

Adapted from http://www.leancrew.com/all-this/2011/12/more-shell-less-egg/

Best,

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

  reply	other threads:[~2012-09-12 18:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-12 18:41 building tagcloud datastructure in elisp Marcelo de Moraes Serpa
2012-09-12 18:58 ` Eric Schulte [this message]
2012-09-12 23:34 ` Jonathan Leech-Pepin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sjanrrtr.fsf@gmx.com \
    --to=eric.schulte@gmx.com \
    --cc=celoserpa@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).