summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Robinson <joe@mumsnet.com>2014-09-19 14:30:27 +0100
committerJoe Robinson <joe@mumsnet.com>2014-09-19 14:30:27 +0100
commit7190f277ee443e20edbc415889e61b58e69e1b97 (patch)
treef27223b72ce8453a1ce7e810f09f0e30aa8a3224
parente84387a29ca3227760cc2025015361a197d010a1 (diff)
Changed default to wordnet database
-rwxr-xr-xbladictionary.py21
1 files 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: