Dictionary and Thesaurus Lookup in Emacs
Or, adding a feature to a piece of software that already has too many features.
Emacs is my preferred tool for editing LATEX documents. A few years ago I got tired of switching back and forth to a terminal or web browser every time I wanted to look up a word in the dictionary or thesaurus. To remedy this, I wrote a simple, 100-line Emacs Lisp plugin to look up words using the DICT protocol.
One can simply cut/paste this into their
.emacs file or make it a separate file in their elisp directory.
; -*-Emacs-Lisp-*- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; File: dict.el ; Description: Dict access functions ; Author: Evan Sultanik ; Created: Sun Aug 14 15:44:57 2005 ; Modified: Thu Nov 15 08:45:48 2007 ; Language: Emacs-Lisp ; Package: N/A ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ******************************************************* ;; ***** THIS IS AN ALPHA TEST VERSION (Version 0.2) ***** ;; ******************************************************* ;; ;; dict.el ;; Copyright (C) 2005 Evan Sultanik (http://www.sultanik.com/) ;; ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 1, or (at your option) ;; any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program; if not, write to the Free Software ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar dict-protocol-client “dict” “This is the name and/or path to the local copy of the DICT protocol client.”) (defconst dict-scratch-buffer-name “*dict*” “This is the name of the buffer in which the dict output is displayed.”) (defun dict-extract-word () “From the current buffer, extract and return the word under the cursor.” (let (start word) (save-excursion (forward-char 1) (backward-word 1) (setq start (point)) (forward-char 1) (if (not (re-search-forward “\\b”)) (error “Can’t find end of word”)) (buffer-substring start (point)) ))) (defun dict-lookup-word (word dict) “Look up the word WORD using the client, given by `dict-protocol-client’. The results will be displayed in the buffer given by `dict-scratch-buffer-name’. If DICT is nil, WORD is looked up from a thesaurus only.” (interactive “sWord to lookup? \nP”) (let ((dict-buffer (get-buffer-create dict-scratch-buffer-name))) (save-excursion (buffer-disable-undo (set-buffer dict-buffer)) (setq buffer-read-only nil) (setq disable-point-adjustment t) (erase-buffer) (display-buffer dict-buffer) (if (null dict) (call-process dict-protocol-client nil ;; no infile t ;; put output in the current buffer t ;; re-display as we get more output “-P” “-” “-d” “moby-thes” word) (call-process dict-protocol-client nil ;; no infile t ;; put output in the current buffer t ;; re-display as we get more output “-P” “-” word) ) (setq buffer-read-only t) (goto-char (point-min)) ) )) (defun thesaurus-lookup-word (word) (dict-lookup-word word nil)) (defun dictionary-lookup-word (word) (dict-lookup-word word t)) (defun thesaurus-lookup-word-in-text (exact) “Like `dict-lookup-word’, but uses the word under the cursor.” (interactive “P”) (thesaurus-lookup-word (dict-extract-word))) (defun dictionary-lookup-word-in-text (exact) “Like `dict-lookup-word’, but uses the word under the cursor.” (interactive “P”) (dictionary-lookup-word (dict-extract-word)))
This code assumes that you have the command
You can set a keyboard shortcut as follows:
(global-set-key (quote [f7]) ‘thesaurus-lookup-word-in-text) (global-set-key (quote [f8]) ‘dictionary-lookup-word-in-text)
Pressing the F7 and F8 keys will then look up the word under the cursor in the thesaurus or dictionary, respectively.
Ðis is a proposal (petition?) to reinstate phonetic orþography for dental fricatives in written English. Ðe letter “t”—ðe most common consonant and second-most common letter in ðe English language—has at least six possible phones (depending on dialect). Complicating matters is ðat ðe proper phone is dependent on context; digraphs like “th” can dictate phoneme, as can ðe position of ðe letter within a word and position in relation to ðe stressed syllable (dictating aspiration, as in “tomato”). Ðe phone for “t” is sometimes even word-dependent (þree examples: “connection” vs. “time” vs. “rotting”). Special cases abound.
Ðe “th” digraph alone can represent þree different phones: ðe voiced dental fricative (e.g., “this” and “the”), ðe unvoiced dental fricative (e.g., “thing” and “with”), or sometimes even ðe voiceless alveolar plosive (e.g., “Thailand” and “lighthouse”).
By reinstating ðe letters “ð” (Eth) and “þ” (Thorn) into ðe English alphabet (for, respectively, ðe voiced and unvoiced dental fricatives) we can eliminate much ambiguity.
While recently writing an article on the AAMAS conference, I was reminded of an incident back in 2002 that, in retrospect, is quite amusing. Although I have publicly recited the story in the past, I have never done so on my website. That, and enduring my incoherent scribblings of six years back makes me want to thrust unsharpened pencils into my eyes.
The prologue is a rather boring and, I must say, embarrassing story, the only pertinent details of which are that I am left in need of a US passport, posthaste.
It’s Saturday. My flight bound for Italy leaves Monday afternoon.
Philadelphia, the city from which I was to embark, has a 24/7 passport-related toll-free telephone hotline, which conveniently plays a recorded message on a loop stating, among other things, that the only possibility of getting a passport (forget a same-day passport) is to have an appointment, and the appointments are booked at least two weeks in advance. In order to book an appointment, there is an automated system available through a separate 1-900 (non-toll-free) number. It stated that it was impossible to speak to a human without an appointment.
Thank the lords for the Internets. There is one company that guarantees same-day passports: itseasypassport.com (the website doesn’t appear to work anymore). I call their 1-800 24/7 emergency hotline. The number just plays me a recording telling me to call a different number, this time in the 212 area code (New York City). I call the second number and am greeted by woman. Mind you, she does not pick up as if she were a receptionist; she greets me as if I had called her personal residence. Which, it turns out, I had. I ask for Its Easy Passports, prompting her to yell to her husband to pick up the phone.
The proprietor of this well-oiled establishment picks up the phone and immediately asks me, “Do you have a valid driver’s license? If so I can get you anything.” I explain my situation and tell him that I need a passport. “Do you want a Visa, too?”
Here are the instructions he gave me:
- Go to a building in NYC at 07:00 on Monday morning (he gave me the address);
- Call a guy named Mr. Mint (he gave me his cell phone #);
- Mr. Mint will alert the guards at the entrance to the building to let me in;
- Go in and go directly to the 10th floor (all of the other floors are “prisoner holding cells”);
- Get out of the elevator and across the hall there will be a room with a bunch of forms and a phone;
- Fill out the forms and when you are done call Mr. Mint again;
- Mr. Mint will come in and take the forms and he will give you a ticket;
- Pay Mr. Mint $100 cash; and
- Come back at 10:30 and you will get your passport.
As you might imagine, by this point I am very skeptical, so I ask the mystery man how his company ensures same-day passports (without being so rude as to directly ask if the resulting passport will be a forgery). He claimed that his company buys slots of appointments from the passport office and sells them to his customers. I look up the address the guy (whose name turns out to be Dave) gave me and it appears to be the address of the real NYC passport office, so the story checked out.
I decide to try this, as it’s my only hope. Sunday night I take the train up to NYC and stay at the Chinatown Holiday Inn. The next morning I walk to the passport office and there was already a line encircling the building. No one in the line spoke English. I enqueue and call Mr. Mint, but he does not answer. Without any other option, I walk to the front of the line and tell the guard that I am here for Its Easy Passports, and by this magic password he steps aside and lets me in. I take the elevator to the 10th floor and, sure enough, Mr. Mint is waiting. Everything went as planned and I hop on a train back down to Philly, got to the airport, and caught my flight at 17:00.
When did you get this passport‽
I just had it printed today.
Edit (10-08-2009): I’d like to clarify that, although It’s Easy Passport seemed sketchy at first, it turns out to be a legitimate company that provides an excellent service. I would recommend them to anyone in a similar situation to mine.
Cycling from Philadelphia, PA to Reston, VA
In which I once again make poor life decisions fueled by stubbornness.
A couple days ago, Rob Lass and I embarked on an epic journey from Philadelphia to Reston, VA (just outside of Washington, D.C.)… by bicycle. We had a business meeting in Reston—which is only about 160 miles away—so we figured we’d give cycling a shot. Deep down neither of us thought we could make it, but neither of us were man enough to admit that, so we tried anyway. One puncture, one bike-to-bike collision, one hail storm, weird sunburn, too many bad directions, and many, many hills later, we made it there and back in one piece. Overall, it was a very positive experience for the both of us.
Pictures are available here.
- For anyone that is reasonably in shape, long distance touring is 85% mental.
- Touring gear (e.g., racks and panniers) add a lot of weight, and weight makes a huge difference. I used a rack trunk and a handlebar bag, which made my bike top heavy and made steering awkward. It also prevented me from pulling a Natty Fab.
- Even if you wear sunscreen, you’ll get sunburn and tanned in the weirdest places (see the pictures linked above).
- Even though I used a fixed gear, I’m really glad I at least had a front brake; it was essential on the huge hills around the PA/MD border.
- Route 1 is the best way to get from Philadelphia to Baltimore. Much of Route 1 is a four lane highway, but there’s a huge shoulder that allows for two bikes to ride abreast. It’s also legal for bikes to ride along the shoulder.
- There is nothing between Kenett Square and the suburbs of Baltimore. Literally. We had to make an 8 mile detour just to get some lunch.
- GPS is invaluable, especially for finding the nearest restaurant, hotel, or convenience store when in the middle of nowhere, vi&., between Kenett Square and Baltimore.
- Never underestimate your appetite. All-you-can-eat places are great.
- You probably don’t want to ride further than White Marsh, Maryland after dark. This is coming from someone who lives in West Philly. White Marsh is really nice, though, and has a lot of great places to stay/eat, especially around to I-95.
- We were told that the Bike Washington cue sheet was the best way to get from Baltimore to D.C. It was great, however, it was originally written by people going the opposite direction (i.e., from D.C. to Baltimore). Therefore, some of the directions were wrong; for example, at mile 14.6 you really want to make a right onto Park Circle. Also, the warning about a big hill at mile 30.9 was really a downhill for us; we got really confused and thought we were lost because we never got to a big climb.
- Getting across D.C. from Union Station to the Francis Scott Key Bridge took a lot longer than expected.
- The Custis and W&OD trails are amazing.
- Taking a lot of turns on small roads takes a lot of time; it took us the same amount of time to get from Philly to Baltimore (~100 miles down Route 1) as it did to go from Baltimore to Reston (~65 miles on dozens of different roads).
- Riding through a hail storm is not fun.
Fixed Gear Gallery (FGG) is a daily-updated website that has a photo gallery of… you guessed it… fixed gear bicycles. Last Friday, a fellow by the name of Nathan Fabian submitted these pictures to the FGG. You might notice that the second picture on the page features Mr. Fabian executing a no-handed track stand, whilst making a lewd gesture at the camera. This is interesting, since the FGG discourages (and sometimes even disallows) pictures of bikes’ owners.
A thread on the Single Speed/Fixed Gear sub-forum on bikeforums.net was created complaining about the submission to FGG, simultaneously making fun of Mr. Fabian for the lewd gesture and ridiculous pose. The thread is available here. Photoshopping of the original images naturally ensued. This thread now has the potential to become like the now-famously epic, ~500-page-long, so-called “Sherdog Guido thread” (note: the thread was deleted, but a good recap video can be found here).
Here are some of my contributions to the Fabian thread:
.J&&&+. .+X0CwHM0+.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MMHHWHMMMHHH#NN$. ZWXZZZXOttI+:;1O: jXMMMMN#HH#NMHMMNMMMM#H@@mHHWXZl????;+!!????UUVOz=zlrXHHN####NMR. ?Xyuuuzrl=;;+=z! ?jWNNNMM#MNMMMMMMNMMM#MHH@gmHXvO=?=?;;+:`^^`+++;??=ltXWM#######HI ..dyyXuvrlzz?=lv .?WNMMMMMNNMM##NNM##NNNNNMMHHWXO=?????+:^^^:.;;;??=OvXWMNNNNN#MK: `XbWXuXv1zOOOwOl `?dMMMNNNNNNMMNMMMHM##MMNMMHXXVv???=??++::;:?;;???ztrXWMNN####NC` .dpSztOz+!++zOI! .dMMMMNMN##MMHMWHMMMMMMNMMHHSl====?++;;::^.:;;;??=lrXHMN###N##:` .dWHWXOz;;+++zwI jHMMNNN#NNMMNHM96!?OWMMHMkXZz=lzzzzzz&+?+;++???=zwqHMMNNHHNMD+ .dHHbWZz;;+1OwI! `1XMNNMMMMNMNNNx++J+.vHMHH0z==ztrrvZwXWHHHkOzzzwWUWMNMM#MMNMk. ?WH@HH0z?;??zZl `jWNNHMNMMNNNMMNm+?+?zXgH0I???+1OXwOzzwkvzVI++dWHWHH#MMNNMMM0` .dMHMHWXOzzlzzI! jHNNMMNMM##NMMMMNs,.jXHH0l=?+;^`?OWWUUC11??+`zUVwWMMNMMMNNNl JXMMHSuuzrttrw0! `WMNMN#MMHHNMMMHMMkZ1XfWkll=+;+.^:.:!``+;;;+^+wuXMNMMNMMNMH: .dMMHWXvzvtrrwXk+. ?WMNN#MMMHH###HMMMS1dWWWw==????;;;::^.+?;?;:?zXHMNMMNNMMM6! .dH@HHWuzzzvrvzXHkOtOz+... `vMMNNNNN#M@HHHMSIzzWkWOl=??;;?;;;;;??=??+!?1XMNMMMMMMBC` .dMH@HHWXvrtttrvXkHZl==????+.. ?TMMMMN#NMMMMHZzz?OWkwOz??;;;??;;;++=z+++?;!?7????!`^` .dMMHHWXztlllltwXqRI1+?;;??;1=z+. +??7WH9!jXWWZ???+wWkwzz?????++zz+1zwwwAdI. .dMMHqkfWXvrtllrwWHk=?;;???;???lOw&. `.z0rwzO=?;;+vWHkwwzz?=zZ0VOOwwwwXU: .dMMMqHWXuzvOlttwXWHS??;?;????+zOtwXI` `1=zOrI??;;??zWHkXuOzzlz??zOOwzXS! JdMMHkpfZuuzwtttwXpH0?;;?;???zlllwZl` `+1ll=??;;;??zZWWkkXwOl==lzzOXuI ..dHHHHpVyZuzzrrrruyWW0???????==ztOZl` `+????;;;;;??==ZWHHkkAz++++lOWI .jWMMHpVyyZuzrrrrrzZWfk?????=lllwzwv` `++?;;?;;;??;?zOwXWHHHkmAwXU= .dMMMqWZZZZuuvrtttwZWHkl=====ztwuZv`. `+:;;;;??;????===trwU=! `.dMMHHWZuuuzrrrrttzZWbkOOl=ltrzXZC!` ``::;;??????=lttrwZ! `?WHMHfyyZuvrtttrtrzuXbHXXOltrwXW0:`` ``?;;;;???zztttOv `JWHHHyyyZXrrvrtlttvvwWHWXrrrwXWC!` `++;++1zOIz?! dMMHWVyyuuzvrttlltrvXWkHkuXwdHD!` ` .dMMHpfVyuuzzrrttrrvuZVkkfWZXW6!` zMMHpfVyuuzzvrrrrzuuXWkHppWK0:` jMMHppyZuuuzzzvvvzuZyWmgHWHS+` JMMHbfyZzuuuuzuuuZZZWHgmHH9z` dMMHqWyZuuuzzzzuZyVWWmg@H0v` `jMM@mkfVyZZuuZZyyVpbkH@H0!` JW@HkbpfVyyyyVyyVVpqH@M$` +WgmqpVyZZZZVfpfpbbHHMD` `dMMHbWyVyZZyVfpWWWHM$`` +UHHWWWZZyyyVffWWH9! `jWHHWyXXyXWWWHM9!` ?vHNNNNNMMM9=!` ?VHMBY7?!`
Crowds made bonfires… threw objects into them… [a] favorite object was cats—cats tied up in bags, cats suspended from ropes, or cats burned at the stake. Parisians liked to incinerate cats by the sackful, while the Courimauds (cour à miaud, or cat chasers) of Saint Chamond preferred to chase a flaming cat throughout the streets. In parts of Burgundy and Lorraine they danced around a kind of burning May pole with a cat tied to it. In the Metz region they burned a dozen cats at a time in a basket on top of a bonfire. The ceremony took place with great pomp in Metz itself, until it was abolished in 1765. The town dignitaries arrived in procession at the Place du Grand-Saulcy, lit the pyre, and a ring of riflemen from the garrison fired off volleys while the cats disappeared screaming in the flames.
I feel it is relevant and particularly enlightening to note that the French national anthem has a special verse, only to be sung by children, in which the singer pledges to enter the military, die in battle, and share a coffin with his or her parents.
I’m still not up to the blog-update-frequency at which I’d be content, however, this is partially due to my attending another conference. I am currently in Utrecht in the Netherlands for AAMAS. It’s very rainy here, and pretty chilly, but I am having a great time. I’ll post some pictures in the coming days, but, in the mean time, here are some interesting quotes that were uttered during a simulation workshop I attended the day before yesterday (most of which can be attributed to Moss and Castelfranchi):
For 10 years, the agents community has struggled to do something useful.
Formalism gives precision.
Game theory is a failed paradigm.
Verification does not imply Validation.
You can have prediction without a description of process. In social science, we know the process but cannot predict.
Parameterizing competition is not legitimate.
In agent-based simulation, formulation does not require quantification.
And my favorite…
The ‘Real World’ is a special case within the set of all possible worlds.
Spammers are getting smart!
In which spammers finally realize that OCR has yet to pass the Turing Test.
I received my first CAPTCHA spam today! It was basically a blank e-mail with an attached JPEG image. The image was altered such that it could not be read by any current optical text recognition (OCR) software. By stochastically altering the modifications to the image for each piece of spam that is sent, no two pieces of spam will look alike. Furthermore, the content is still human-readable, but, as mentioned above, is not yet discernible by any spam filtering software. The content of the image read as follows:
Профессиональные E-mail рассылки! Тел: (095) 968-76-23 Более 4-х лет на рыенке рекламы!
Basically, they are advertising a professional E-mail distribution service that’s been around for more than 4 years! I find it mildly amusing that they are advertising a phone number rather than an e-mail address or website.
Note: they misspelled “рыенке;” it should really be “рынке.”