diff options
author | Joe Robinson <joe@mumsnet.com> | 2014-09-18 16:00:56 +0100 |
---|---|---|
committer | Joe Robinson <joe@mumsnet.com> | 2014-09-18 16:00:56 +0100 |
commit | 193f2f9f0bf92f6fcfbceb71d0bd823bdd51f823 (patch) | |
tree | 86021d38482a105b52e435a570b7ee4d7d240195 /bladictionary.py | |
parent | eb1463d6f7613e10d6b4306d576d47f76eb7bc24 (diff) |
Made OED case insensitive, add error handling when no results found
Diffstat (limited to 'bladictionary.py')
-rwxr-xr-x | bladictionary.py | 9 |
1 files 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: |