One-liners

From Apertium
Revision as of 15:34, 13 June 2010 by Pyry (talk | contribs)
Jump to navigation Jump to search

Useful (mostly) bash one-liners

  • Perl regular-expression for removing all tags after the initial: perl -pe 's/(\^[^<]+<[^>]+>)(<\w+>)*\$/\1\$/g;'

^Lemma<V><Pres><Sg>$ -> ^Lemma<V>$

  • Get unknown words from chunked text and sort by frequency: sed 's/\$\W*\^/$\n^/g' | grep '@' | sed 's/><.*/>$/g' | sort -f | uniq -ci | sort -gr
  • Strip newlines: sed ':a;N;$!ba;s/\n//g'