(String filename)
| 11 | } |
| 12 | |
| 13 | public static Tokenizer loadFromFile(String filename) { |
| 14 | try { |
| 15 | Scanner scanner = new Scanner(new File(filename)); |
| 16 | int size = Integer.parseInt(scanner.nextLine()); |
| 17 | String[] vocab = new String[size]; |
| 18 | for (int i = 0; i < size; i++) { |
| 19 | vocab[i] = scanner.nextLine(); |
| 20 | } |
| 21 | return new Tokenizer(vocab); |
| 22 | } catch (Exception ignored) { |
| 23 | } |
| 24 | return null; |
| 25 | } |
| 26 | |
| 27 | public double[] tokenize(String text) { |
| 28 | double[] values = new double[vocab.length]; |