diff options
| author | Joe Robinson <joe@lc8n.com> | 2020-11-08 15:14:29 +0000 | 
|---|---|---|
| committer | Joe Robinson <joe@lc8n.com> | 2020-11-08 15:14:29 +0000 | 
| commit | 3dfbd0064963af0e744806146a0f9ba6a6ec2f09 (patch) | |
| tree | 52b4423eb76574a44e3a0d896ff2b5a21df9aae8 | |
| parent | 2ada1031a438f938103230f0b95eb7d7b6f43fc6 (diff) | |
| parent | a8a6b4e3117fef17c63f0677aa43496ebdaf54e1 (diff) | |
Convert strings to ints
See merge request wjoe/bladictionary2!2
| -rwxr-xr-x | bladictionary.py | 9 | 
1 files changed, 4 insertions, 5 deletions
| diff --git a/bladictionary.py b/bladictionary.py index 9fe1827..6b33c08 100755 --- a/bladictionary.py +++ b/bladictionary.py @@ -214,11 +214,10 @@ def parse_oed(word):  	definition = ""  	word_type = ""  	for part in line.split(" ")[word_len:]: -  		#If we've reached a word type, add the current data to the list  		if part in types.keys():  			#Don't add empty definitions -			if id > 0 and definition != " " and definition: +			if int(id) > 0 and definition and definition != " ":  				item = Definition(word, id, "oed", word_type, definition, [], [], [])  				items.append(item)  				definition = "" @@ -348,7 +347,7 @@ def main():  	if word_dict == "oed":  		items = parse_oed(word) -	elif word_dict == "wn": +	elif word_dict == "wn" or word_dict == "wordnet":  		xml = get_xml(word, word_dict)  		if xml is None: @@ -410,7 +409,7 @@ def main():  		if all_types:  			found_type = False  			cur_id = type_id -			if item.id < page_num: +			if int(item.id) < page_num:  				if item.id != 0:  					continue  				elif item.id == 0 and page_num > 1: @@ -438,7 +437,7 @@ def main():  			else:  				# Ignore anything after a line break as this breaks output  				item_definition = item.definition.split("\n")[0] -				if item.id > 0: +				if int(item.id) > 0:  					definition = item.word_type + " " + str(item.id) + ": " + item_definition  				else:  					definition = item.word_type + ": " + item_definition | 
