@@ -0,0 +1,2042 @@
+package org.krugler.yalder;%0A%0Aimport java.io.DataInputStream;%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStreamReader;%0Aimport java.util.Collection;%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0Aimport java.util.regex.Matcher;%0Aimport java.util.regex.Pattern;%0A%0Aimport org.apache.commons.io.FileUtils;%0Aimport org.krugler.yalder.hash.HashLanguageModel;%0Aimport org.krugler.yalder.text.TextLanguageModel;%0A%0Apublic class ModelLoader %7B%0A%0A    public static Collection%3CBaseLanguageModel%3E loadModelsFromResources() %7B%0A        // TODO use language-detector code to find/load resources%0A        return null;%0A    %7D%0A    %0A    public static Collection%3CBaseLanguageModel%3E loadModelsFromDirectory(File dirFile, boolean isBinary) throws IOException %7B%0A        Set%3CBaseLanguageModel%3E result = new HashSet%3C%3E();%0A        %0A        String modelSuffix = isBinary ? %22bin%22 : %22txt%22;%0A        for (File file : FileUtils.listFiles(dirFile, new String%5B%5D%7BmodelSuffix%7D, true)) %7B%0A            String filename = file.getName();%0A            Pattern p = Pattern.compile(String.format(%22yalder_model_(.+).%25s%22, modelSuffix));%0A            Matcher m = p.matcher(filename);%0A            if (!m.matches()) %7B%0A                continue;%0A            %7D%0A%0A            // Verify that language is valid%0A            LanguageLocale.fromString(m.group(1));%0A            %0A            if (isBinary) %7B%0A                try (DataInputStream dis = new DataInputStream(new FileInputStream(file))) %7B%0A                    HashLanguageModel binaryModel = new HashLanguageModel();%0A                    binaryModel.readAsBinary(dis);%0A                    result.add(binaryModel);%0A                %7D %0A            %7D else %7B%0A                try (InputStreamReader isr = new InputStreamReader(new FileInputStream(file), %22UTF-8%22)) %7B%0A                    TextLanguageModel textModel = new TextLanguageModel();%0A                    textModel.readAsText(isr);%0A                    result.add(textModel);%0A                %7D%0A            %7D%0A        %7D%0A%0A        return result;%0A    %7D%0A%7D%0A

Add first cut at model loader