summaryrefslogtreecommitdiff
path: root/bladictionary.java
diff options
context:
space:
mode:
Diffstat (limited to 'bladictionary.java')
-rw-r--r--bladictionary.java61
1 files changed, 54 insertions, 7 deletions
diff --git a/bladictionary.java b/bladictionary.java
index 82f6ce8..8f887b2 100644
--- a/bladictionary.java
+++ b/bladictionary.java
@@ -40,6 +40,8 @@ public class bladictionary {
Boolean definition = false;
Boolean definition2 = false;
Boolean wn = false;
+ Boolean foldoc = false;
+ int fcount = 0;
String result = "";
//Read every line
while ((line = br.readLine()) != null)
@@ -52,14 +54,29 @@ public class bladictionary {
{
wn = true;
}
-
- if(wn)
+ else if (line.equals("<Id>foldoc</Id>"))
{
+ //Read tech definitions too
+ foldoc = true;
+ if(result.equals(""))
+ {
+ result = result+"tech: ";
+ }
+ else
+ {
+ result = result+"; tech: ";
+ }
+ fcount++;
+ }
+ if(wn||foldoc)
+ {
+
//Look for start of a definition
if (line.contains("<WordDefinition>"))
{
definition = true;
+ definition2 = true;
}
//If we found a definition tag
@@ -68,16 +85,22 @@ public class bladictionary {
//if it's the end of the word definition, stop reading
if(line.contains("</WordDefinition>"))
{
- definition = false;
+ definition = false;
+ wn = false;
+ foldoc = false;
}
else
{
-
+ if(wn)
+ {
if (line.substring(0,2).equals("n ") || line.substring(0,2).equals("v ")
|| line.substring(0,4).equals("adj ") || line.substring(0,4).equals("adv "))
{
+ if(!result.equals(""))
+ {
+ result = result+"; ";
+ }
definition2 = true;
- //System.out.println(line);
}
if(definition2)
@@ -87,13 +110,37 @@ public class bladictionary {
{
parts = line.split("\\[");
- result = result + parts[0] + "; ";
+ result = result + parts[0];
}
else
{
definition2 = false;
}
}
+ }
+ //We only want one of these definitions
+ else if(foldoc && fcount <=1 && !line.equals("")&&definition2)
+ {
+ //Delete bits in <>s, don't need this
+ line = line.replaceAll("&lt;.*?&gt; ","");
+ //Get rid of {}s around words
+ line = line.replaceAll("\\{","");
+ line = line.replaceAll("\\}","");
+
+ //Split it at a . - We only want the first sentence
+ parts=line.split("\\.");
+
+ if(parts.length>1)
+ {
+ definition2 = false;
+ result = result + parts[0];
+ }
+ else
+ {
+ result = result + line;
+ }
+
+ }
}
}
@@ -112,4 +159,4 @@ public class bladictionary {
}
-} \ No newline at end of file
+}