From 7190f277ee443e20edbc415889e61b58e69e1b97 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Fri, 19 Sep 2014 14:30:27 +0100 Subject: Changed default to wordnet database --- bladictionary.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/bladictionary.py b/bladictionary.py index 39b4917..071d058 100755 --- a/bladictionary.py +++ b/bladictionary.py @@ -7,7 +7,7 @@ import optparse from lxml import etree import sqlite3 -VERSION = "2.1.3b" +VERSION = "2.1.4b" class Definition(object): #ID is relative to the word type, eg noun 1, noun 2, verb 1, verb 2, not to the entire list @@ -191,6 +191,7 @@ def parse_oed(word): for part in line.split(" ")[1:]: + if part in types: if id > 0: item = Definition(word, id, "oed", word_type, definition, [], [], []) @@ -252,17 +253,21 @@ def main(): if word_dict == "oed": items = parse_oed(word) - elif word_dict == "db": - items = get_sql(word) - else: - if word_dict == "" or word_dict is None: - word_dict = "wn" + elif word_dict == "wn": xml = get_xml(word, word_dict) if xml is None: return items = parse_xml(xml) + else: + if word_dict is None or word_dict == "": + word_dict = "db" + items = get_sql(word) + + if items is None or len(items) == 0: + print "No definition found for "+word + return line_length = 0 num_more = 0 @@ -273,9 +278,7 @@ def main(): else: max_length = 460 - if items is None or len(items) == 0: - print "No definition found for "+word - return + for item in items: -- cgit v1.2.3