diff options
author | Joe Robinson <joe@mumsnet.com> | 2014-09-18 15:55:10 +0100 |
---|---|---|
committer | Joe Robinson <joe@mumsnet.com> | 2014-09-18 15:55:10 +0100 |
commit | eb1463d6f7613e10d6b4306d576d47f76eb7bc24 (patch) | |
tree | 915862785995e4bd8cfc4158f897b3320a3c9b4b | |
parent | e6206b9511c1284c5406a5af21147ddbda406006 (diff) |
Fix error with wn definitions with only one definition
-rwxr-xr-x | bladictionary.py | 12 |
1 files 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: |