Commit 0b899f01 authored by Alexander Ross Melnick's avatar Alexander Ross Melnick
Browse files

Added Dutch translation parsing

parent 2c65baba
Loading
Loading
Loading
Loading
+40 B (352 B)

File changed.

No diff preview for this file type.

+1 −0
Original line number Diff line number Diff line
@@ -4,4 +4,5 @@ public class Debug {
    // Set to true to enable debug messages. Set to false to disable debug messages
    public static boolean DEBUG = false; 
    public static boolean DEBUG_RobotsTXT = false;
    public static boolean DEBUG_Dutch = false;
}
+1027 −0

File added.

Preview size limit exceeded, changes collapsed.

+548 B (3.84 KiB)

File changed.

No diff preview for this file type.

+38 −0
Original line number Diff line number Diff line
@@ -71,4 +71,42 @@ public class RegexParser {
        String[] parts = url.split("/");
        return parts[parts.length - 1];
    }

    // Parse the Dutch dictionary
    public static String parseDutchDict(String line, int curPart) {
        String entry = null;
    
        // Regular expression pattern to match dictionary entries
        Pattern patternEntry = Pattern.compile("<div class=\"vocab\">(.*?)</div>");
        Matcher matcherEntry = patternEntry.matcher(line);
        if (matcherEntry.find() && curPart == 0) {
            entry = matcherEntry.group(1);
            return entry;
        } else if (matcherEntry.find() && curPart != 0) {
            return "$BAD";
        }
    
        // Regular expression pattern to match parts of speech
        Pattern patternPos = Pattern.compile("<div class=\"pos\">\\[(.*?)\\]</div>");
        Matcher matcherPos = patternPos.matcher(line);
        if (matcherPos.find() && curPart == 1) {
            entry = matcherPos.group(1);
            return entry;
        } else if (matcherPos.find() && curPart != 1) {
            return "$BAD";
        }
    
        // Regular expression pattern to match definitions
        Pattern patternDefinition = Pattern.compile("<div class=\"definition\">\\((.*?)\\)</div>");
        Matcher matcherDefinition = patternDefinition.matcher(line);
        if (matcherDefinition.find() && curPart == 2) {
            entry = matcherDefinition.group(1);
            return entry;
        } else if (matcherDefinition.find() && curPart != 2) {
            return "$BAD";
        }
    
        // Did not find a Duct Word, Part of Speech, or Definition
        return null;
    }
}
 No newline at end of file
Loading