From aafac55f7acfb8393e7ecde547f4df03804ae487 Mon Sep 17 00:00:00 2001 From: "Sean B. Palmer" Date: Sun, 7 Jun 2009 09:57:41 +0100 Subject: [PATCH] Added config option for specifying services to use. --- modules/dict.py | 68 ------------------------------------------- modules/etymology.py | 12 ++++---- modules/oblique.py | 30 ++++++++++++++++++- modules/wiktionary.py | 2 +- opt/freenode.py | 6 ++-- phenny | 21 ++++++++----- 6 files changed, 51 insertions(+), 88 deletions(-) diff --git a/modules/dict.py b/modules/dict.py index df9025d..ac29a2e 100755 --- a/modules/dict.py +++ b/modules/dict.py @@ -11,79 +11,11 @@ import re, urllib import web from tools import deprecated -formuri = 'http://wordnet.princeton.edu/perl/webwn?s=' - r_li = re.compile(r'(?ims)
  • .*?
  • ') r_tag = re.compile(r'<[^>]+>') r_parens = re.compile(r'(?<=\()(?:[^()]+|\([^)]+\))*(?=\))') r_word = re.compile(r'^[A-Za-z0-9\' -]+$') -@deprecated -def f_wordnet(self, origin, match, args): - """Gives the definition of a word using Wordnet.""" - command = 'w' - term = match.group(2) - term = term.encode('utf-8') - - if origin.sender != '#inamidst': - if not r_word.match(term): - msg = "Words must match the regexp %s" % r'^[A-Za-z0-9\' -]+$' - return self.msg(origin.sender, origin.nick + ": " + msg) - if ('--' in term) or ("''" in term) or (' ' in term): - self.msg(origin.sender, origin.nick + ": That's not in WordNet.") - return - - bytes = web.get(formuri + web.urllib.quote(term)) # @@ ugh! - items = r_li.findall(bytes) - - nouns, verbs, adjectives = [], [], [] - for item in items: - item = r_tag.sub('', item) - chunks = r_parens.findall(item) - # self.msg(origin.sender, item) - if len(chunks) < 2: continue - - kind, defn = chunks[0], chunks[1] - if command != 'wordnet': - defn = defn.split(';')[0] - if not defn: continue - defn = defn[0].upper() + defn[1:] - - if kind == 'n': - nouns.append(defn) - elif kind == 'v': - verbs.append(defn) - elif kind == 'adj': - adjectives.append(defn) - - if not (nouns or verbs or adjectives): - self.msg(origin.sender, "I couldn't find '%s' in WordNet." % term) - return - - while len(nouns + verbs + adjectives) > 3: - if len(nouns) >= len(verbs) and len(nouns) >= len(adjectives): - nouns.pop() - elif len(verbs) >= len(nouns) and len(verbs) >= len(adjectives): - verbs.pop() - elif len(adjectives) >= len(nouns) and len(adjectives) >= len(verbs): - adjectives.pop() - - if adjectives: - adjectives[-1] = adjectives[-1] + '.' - elif verbs: - verbs[-1] = verbs[-1] + '.' - elif nouns: - nouns[-1] = nouns[-1] + '.' - - for (i, defn) in enumerate(nouns): - self.msg(origin.sender, '%s n. %r: %s' % (term, i+1, defn)) - for (i, defn) in enumerate(verbs): - self.msg(origin.sender, '%s v. %r: %s' % (term, i+1, defn)) - for (i, defn) in enumerate(adjectives): - self.msg(origin.sender, '%s a. %r: %s' % (term, i+1, defn)) -f_wordnet.commands = ['wordnet'] -f_wordnet.priority = 'low' - uri = 'http://encarta.msn.com/dictionary_/%s.html' r_info = re.compile( r'(?:ResultBody">

    (.*?) )|(?:(.*?))' diff --git a/modules/etymology.py b/modules/etymology.py index 12da548..30257f2 100755 --- a/modules/etymology.py +++ b/modules/etymology.py @@ -22,7 +22,7 @@ abbrs = [ 'cf', 'lit', 'etc', 'Ger', 'Du', 'Skt', 'Rus', 'Eng', 'Amer.Eng', 'Sp', 'Fr', 'N', 'E', 'S', 'W', 'L', 'Gen', 'J.C', 'dial', 'Gk', '19c', '18c', '17c', '16c', 'St', 'Capt', 'obs', 'Jan', 'Feb', 'Mar', - 'Apr', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'c', 'tr' + 'Apr', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'c', 'tr', 'e', 'g' ] t_sentence = r'^.*?(?> sys.stderr, 'Warning: ignoring spurious arguments' + # Step Two: Check Dependencies + + check_python_version() # require python2.4 or later + check_dotdir() # require ~/.phenny, or make it and exit + # Step Three: Load The Configurations config_modules = []