[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] building tagcloud datastructure in elisp
From: |
Eric Schulte |
Subject: |
Re: [O] building tagcloud datastructure in elisp |
Date: |
Wed, 12 Sep 2012 12:58:40 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) |
Marcelo de Moraes Serpa <address@hidden> 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