summaryrefslogtreecommitdiff
path: root/bladictionary.py
diff options
context:
space:
mode:
Diffstat (limited to 'bladictionary.py')
-rwxr-xr-xbladictionary.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/bladictionary.py b/bladictionary.py
index 4ad0fd4..0adb568 100755
--- a/bladictionary.py
+++ b/bladictionary.py
@@ -7,7 +7,7 @@ import optparse
from lxml import etree
import sqlite3
-VERSION = "2.2.0"
+VERSION = "2.2.1"
class Definition(object):
#ID is relative to the word type, eg noun 1, noun 2, verb 1, verb 2, not to the entire list
@@ -310,6 +310,9 @@ def parse_foldoc(word, refer = False):
found = False
count_blank = 0
items = []
+ multiple = False
+ id = 0
+ skip = False
#If it's been referred from another definition, include the new word
if refer:
@@ -340,23 +343,38 @@ def parse_foldoc(word, refer = False):
count_blank += 1
if count_blank == 1:
continue
+ elif multiple:
+ skip = True
else:
break
#If the line is just one string enclosed in {}s, then it means "see also", so look up that word
- if line[0] == "{" and line[-1] == "}":
+ if len(line) > 0 and line[0] == "{" and line[-1] == "}":
item = parse_foldoc(line.strip("{} "), True)[0]
items.append(item)
return items
-
- for part in word_parts:
- definition += part.strip().replace("{", "").replace("}", "") + " "
+ if line[0:2] == "1.":
+ multiple = True
+
+ if multiple:
+ id_parts = line.split(".")
+ if id_parts[0].isdigit() and definition is not None and definition != "":
+ definition = definition[3:]
+ item = Definition(word, id, "foldoc", "tech", definition, [], [], [])
+ items.append(item)
+ id = id_parts[0]
+ definition = ""
+ skip = False
+
+ if not skip:
+ for part in word_parts:
+ definition += part.strip().replace("{", "").replace("}", "") + " "
if not found :
return
else:
- item = Definition(word, 0, "foldoc", "tech", definition, [], [], [])
+ item = Definition(word, id, "foldoc", "tech", definition, [], [], [])
items.append(item)
return items