From 193f2f9f0bf92f6fcfbceb71d0bd823bdd51f823 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Thu, 18 Sep 2014 16:00:56 +0100 Subject: Made OED case insensitive, add error handling when no results found --- bladictionary.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bladictionary.py b/bladictionary.py index 936a75b..a64eb1c 100755 --- a/bladictionary.py +++ b/bladictionary.py @@ -6,7 +6,7 @@ import sys import shlex from lxml import etree -version = "2.0.8b" +version = "2.0.9b" class Definition(object): #ID is relative to the word type, eg noun 1, noun 2, verb 1, verb 2, not to the entire list @@ -165,14 +165,13 @@ def parse_oed(word): for line in file: word_part = line.split(" ")[0] - if word_part == word: + if word_part.lower() == word.lower(): word_line = line break; if word_line == "": return - print line prev_part = "" items = [] id = 0 @@ -224,6 +223,10 @@ def main(): num_more = 0 suppress_print = False + if items is None or len(items) == 0: + print "No definition found for "+word + return + for item in items: if word_type is "" or word_type == item.word_type: -- cgit v1.2.3