Adminbuntu

Everything for the Ubuntu Server Administrator

User Tools

Site Tools


Sidebar

Server Administration


Server Applications


At the Command Line


Elsewhere


Copyright 2013 Applied Conscious Technologies, LLC

Terms of Agreement

Contact


submit to reddit

wordplay:wordplay

Wordplay on Ubuntu Linux

Wordplay, the humorous use of words. Puns. Puzzles. Clever rearranging of letters. Fun with language.

Word Lists

Wordplay Scripts

wordplay nytimes blog: http://wordplay.blogs.nytimes.com/

wordplay defined: http://www.wordnik.com/words/wordplay


Word Diff

While diff shows the difference between two files line by line, sometimes it is useful to see how two files differ in the words they contain.

Words Different in 2 Files

This shows a list of words that are different between two files.

F1='1.txt' && F2='2.txt' && L1=$(cat $F1 | tr -cs A-Za-z\' '\n' | tr A-Z a-z | sort | uniq -u) && L2=$(cat $F2 | tr -cs A-Za-z\' '\n' | tr A-Z a-z | sort | uniq -u)  && ALL="$L1 $L2" && echo $ALL | tr '\ ' '\n' | sort | uniq -u

Words In Common in 2 Files

This shows a list of words that are in common between two files.

F1='1.txt' && F2='2.txt' && L1=$(cat $F1 | tr -cs A-Za-z\' '\n' | tr A-Z a-z | sort | uniq -u) && L2=$(cat $F2 | tr -cs A-Za-z\' '\n' | tr A-Z a-z | sort | uniq -u)  && ALL="$L1 $L2" && echo $ALL | tr '\ ' '\n' | sort | uniq -d

Palindromes

List Palindromes in a Word List

perl -lne 'print if $_ eq reverse' /usr/share/dict/words

Rhyming

The Rhyming Dictionary is an open source project. The rhyme command accepts a word as an argument and returns a list of rhyming words.

rhyme

Anagrams

Anagrams are words created by rearranging the letters of a word. For example orchestra can be rearranged into carthorse.

Wordplay Anagram Generator

Installation

sudo aptitude -y install wordplay

Using Wordplay

wordplay orchestra

An

Installation

sudo aptitude -y install an

Using An

an -m 3 'andrew p ault'

XKCD Break

xkcd

Crossword Solver

Enter the regex pattern you want to find at “^a….e$”, between the ^ and $.

cat /usr/share/dict/words | perl -e 'while(<>){ print if( /^a....e$/i ); }'

Wordnet

Curl Wordnet

Look up the definition for a word from dict.org (ie “unusual”):

curl --stderr /dev/null dict://dict.org/d:unusual | sed '/^[.,0-9].*$/d'

Wordnet

Using

Look up definition using Wordnet (for “unusual” as an example):

wn unusual -over

Installing Wordnet

sudo aptitude -y install wordnet

Wordnet Script

Word definition script:

#! /bin/bash
#
# display definition of a word
#
 
curl --stderr /dev/null dict://dict.org/d:$1 | sed '/^[.,0-9].*$/d'
 
echo -e "\nwordnet overview:"
wn $1 -over
 
echo -e "\nwordnet synonyms, adjectives:"
wn $1 -synsa
echo -e "\nwordnet synonyms, nouns:"
wn $1 -synsn

Thesaurus

Installation

sudo aptitude install sdcv dict-moby-thesaurus

Install the script

sudo vi /usr/bin/thes

Paste in the script, below. Then save the file.

Then, make the file executable.

sudo chmod +x /usr/bin/thes

The Script

from: http://linuxtidbits.wordpress.com/2008/01/30/command-line-dictionary/

#!/bin/bash
# thes - command line thesaurus
 
# Program name from it's filename
prog=${0##*/}
 
# Text color variables
txtbld=$(tput bold)             # Bold
bldred=${txtbld}$(tput setaf 1) #  red
bldwht=${txtbld}$(tput setaf 7) #  white
txtrst=$(tput sgr0)             # Reset
warn=${bldred}!${txtrst}
 
# Display usage if full argument isn't given
if [[ -z "$@" ]]; then
  echo " $prog <word> - command line thesaurus"
  exit
fi
 
# Suggest possible words if not in dictionary, otherwise define
wordchecknum=$(echo "$1" | aspell -a | sed '1d' | wc -m)
wordcheckprnt=$(echo "$1" | aspell -a | sed '1d' | sed 's/^.*: //')
 
if [[ $wordchecknum -gt "3" ]]; then
  echo -e "$warn ${bldwht}"$1"${txtrst} is not in the dictionary.  Possible alternatives:"
  echo -e "\n$wordcheckprnt" | fmt -w 76 | sed 's/^/  /g'
  echo
  exit
fi
 
# Lookup word and reformat/highlight
sdcv -u "Moby Thesaurus II" $1 | \
# lookup, delete extrenous first lines, delete last empty line
sed '1,3d' | sed '2d' | sed '/^*$/d' | \
# delete indent to reformat, add newlines at 76th character, and reident
sed 's/^   //g' | fmt -w 76 | sed 's/^/  /g'

Double Words

Check a file for double words.

diction mydoc.txt | grep 'Double word'

or

perl -0777 -ne 'print "$.: doubled $_\n" while /\b(\w+)\b\s+\b\1\b/gi'

Readability

Check a file for readability.

style mydoc.txt

Translation

Apertium

The Apertium project provides open source language translation.

project page: http://sourceforge.net/projects/apertium/

documentation: http://wiki.apertium.org/wiki/Main_Page

Using Apertium

echo "This is not in English." | apertium en-es

result:

Esto no es en inglés.

Usage

apertium [-d datadir] [-f format] [-u] [-a] {language-pair} [infile [outfile]]

Installation

Install apertium and the English/Spanish language package.

sudo aptitude install apertium apertium-en-es

Find available language packages:

aptitude search apertium 

Using Apertium

To see available languages that are available:

aptitude search apertium 

wordplay/wordplay.txt · Last modified: 2015/05/31 21:20 (external edit)