From eb1463d6f7613e10d6b4306d576d47f76eb7bc24 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Thu, 18 Sep 2014 15:55:10 +0100 Subject: Fix error with wn definitions with only one definition --- bladictionary.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bladictionary.py b/bladictionary.py index ec5aff9..936a75b 100755 --- a/bladictionary.py +++ b/bladictionary.py @@ -6,7 +6,7 @@ import sys import shlex from lxml import etree -version = "2.0.7b" +version = "2.0.8b" class Definition(object): #ID is relative to the word type, eg noun 1, noun 2, verb 1, verb 2, not to the entire list @@ -42,9 +42,6 @@ def get_xml(word, word_dict): root = element break; - for element in root.iter("{http://services.aonaware.com/webservices/}WordDefinition"): - print element.text - return root def parse_xml(xml): @@ -94,7 +91,10 @@ def parse_xml(xml): if id_parts[0].isdigit() != True: word_type = id_parts[0] - id = id_parts[1] + if len(id_parts) < 2: + id = 1 + else : + id = id_parts[1] definition = line_parts[1].strip() + " " else: id = id_parts[0] @@ -231,7 +231,7 @@ def main(): num_more+=1 else: definition = item.word_type + " " + str(item.id) + ": " + item.definition - if line_length + len(definition) > 455: + if line_length + len(definition) > 458: suppress_print = True num_more+= 1 else: -- cgit v1.2.3