Esempio n. 1
0
 public TaggerLSTM(
     final DeepTagger tagger,
     final double beta,
     final int maxTagsPerWord,
     final CutoffsDictionaryInterface cutoffs)
     throws IOException {
   super(
       cutoffs,
       beta,
       tagger.getTags().stream().map(Category::valueOf).collect(Collectors.toList()),
       maxTagsPerWord);
   this.tagger = tagger;
 }
Esempio n. 2
0
  @Override
  public List<List<ScoredCategory>> tag(final List<InputWord> words) {
    final List<String> input =
        words.stream().map(x -> translateBrackets(x.word)).collect(Collectors.toList());
    final float[][] scores = tagger.tag(input);
    final List<List<ScoredCategory>> result = new ArrayList<>();
    for (int i = 0; i < input.size(); i++) {
      final List<ScoredCategory> tagsForWord = getTagsForWord(scores[i]);
      result.add(tagsForWord);
    }

    return result;
  }
Esempio n. 3
0
 private static DeepTagger makeDeepTagger(final File modelFolder) throws IOException {
   // Apparently this is the easiest way to set the library path in code...
   System.setProperty("java.library.path", "lib");
   Field fieldSysPath;
   try {
     fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
     fieldSysPath.setAccessible(true);
     fieldSysPath.set(null, null);
   } catch (NoSuchFieldException
       | SecurityException
       | IllegalArgumentException
       | IllegalAccessException e) {
     throw new RuntimeException(e);
   }
   return DeepTagger.make(modelFolder);
 }