public NeuralNetworkRule(ResourceBundle messages, Language language, ScoredConfusionSet confusionSet, Word2VecModel word2VecModel) throws IOException { super(messages); super.setCategory(Categories.TYPOS.getCategory(messages)); this.subjects = confusionSet.getConfusionTokens(); this.descriptions = confusionSet.getTokenDescriptions(); this.minScore = confusionSet.getScore(); try { InputStream W1Stream = streamFor(word2VecModel.getPath(), "W_fc1.txt"); InputStream b1Stream = streamFor(word2VecModel.getPath(), "b_fc1.txt"); Classifier tmpClassifier; try { InputStream W2Stream = streamFor(word2VecModel.getPath(), "W_fc2.txt"); InputStream b2Stream = streamFor(word2VecModel.getPath(), "b_fc2.txt"); //System.out.println("deep rule for " + confusionSet.toString()); tmpClassifier = new TwoLayerClassifier(word2VecModel.getEmbedding(), W1Stream, b1Stream, W2Stream, b2Stream); } catch (FileNotFoundException e) { tmpClassifier = new SingleLayerClassifier(word2VecModel.getEmbedding(), W1Stream, b1Stream); } classifier = tmpClassifier; } catch (FileNotFoundException e) { throw new IOException("Weights for confusion set " + confusionSet.toString() + " are missing", e); } this.id = createId(language); }
public NeuralNetworkRule(ResourceBundle messages, Language language, ScoredConfusionSet confusionSet, Word2VecModel word2VecModel) throws IOException { super(messages); super.setCategory(Categories.TYPOS.getCategory(messages)); this.subjects = confusionSet.getConfusionTokens(); this.descriptions = confusionSet.getTokenDescriptions(); this.minScore = confusionSet.getScore(); try { InputStream W1Stream = streamFor(word2VecModel.getPath(), "W_fc1.txt"); InputStream b1Stream = streamFor(word2VecModel.getPath(), "b_fc1.txt"); Classifier tmpClassifier; try { InputStream W2Stream = streamFor(word2VecModel.getPath(), "W_fc2.txt"); InputStream b2Stream = streamFor(word2VecModel.getPath(), "b_fc2.txt"); //System.out.println("deep rule for " + confusionSet.toString()); tmpClassifier = new TwoLayerClassifier(word2VecModel.getEmbedding(), W1Stream, b1Stream, W2Stream, b2Stream); } catch (FileNotFoundException e) { tmpClassifier = new SingleLayerClassifier(word2VecModel.getEmbedding(), W1Stream, b1Stream); } classifier = tmpClassifier; } catch (FileNotFoundException e) { throw new IOException("Weights for confusion set " + confusionSet.toString() + " are missing", e); } this.id = createId(language); }