zemberek.core.logging.Log.warn()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中zemberek.core.logging.Log.warn()方法的一些代码示例,展示了Log.warn()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Log.warn()方法的具体详情如下:
包路径:zemberek.core.logging.Log
类名称:Log
方法名:warn

Log.warn介绍

暂无

代码示例

代码示例来源:origin: ahmetaa/zemberek-nlp

public Builder setCondition(Condition _condition) {
 if (condition != null) {
  Log.warn("Condition was already set.");
 }
 this.condition = _condition;
 return this;
}

代码示例来源:origin: ahmetaa/zemberek-nlp

public MorphemeState addIncoming(MorphemeTransition... suffixTransitions) {
 for (MorphemeTransition suffixTransition : suffixTransitions) {
  if (incoming.contains(suffixTransition)) {
   Log.warn("Incoming transition %s already exist in %s", suffixTransition, this);
  }
  incoming.add(suffixTransition);
 }
 return this;
}

代码示例来源:origin: ahmetaa/zemberek-nlp

public MorphemeState addOutgoing(MorphemeTransition... suffixTransitions) {
 for (MorphemeTransition suffixTransition : suffixTransitions) {
  if (outgoing.contains(suffixTransition)) {
   Log.warn("Outgoing transition %s already exist in %s", suffixTransition, this);
  }
  outgoing.add(suffixTransition);
 }
 return this;
}

代码示例来源:origin: ahmetaa/zemberek-nlp

/**
 * @param index Word for the index. if index is out of bounds, <UNK> is returned with warning.
 * Note that Vocabulary may contain <UNK> token as well.
 */
public String getWord(int index) {
 if (index < 0 || index >= vocabulary.size()) {
  Log.warn("Out of bounds word index is used:" + index);
  return unknownWord;
 }
 return vocabulary.get(index);
}

代码示例来源:origin: ahmetaa/zemberek-nlp

public P convertTo(E en, P defaultEnum) {
 P pEnum = conversionFromEToP.get(en.name());
 if (pEnum == null) {
  Log.warn("Could not map from Enum %s Returning default", en.name());
  return defaultEnum;
 }
 return pEnum;
}

代码示例来源:origin: ahmetaa/zemberek-nlp

public E convertBack(P en, E defaultEnum) {
  E eEnum = conversionFromPToE.get(en.name());
  if (eEnum == null) {
   Log.warn("Could not map from Enum %s Returning default", en.name());
   return defaultEnum;
  }
  return eEnum;
 }
}

代码示例来源:origin: ahmetaa/zemberek-nlp

public void add(DictionaryItem item) {
 if (itemSet.contains(item)) {
  Log.warn("Duplicated item:" + item);
  return;
 }
 if (idMap.containsKey(item.id)) {
  Log.warn("Duplicated item id of:" + item + " with " + idMap.get(item.id));
  return;
 }
 this.itemSet.add(item);
 idMap.put(item.id, item);
 itemMap.put(item.lemma, item);
}

代码示例来源:origin: ahmetaa/zemberek-nlp

public void addDictionaryItem(DictionaryItem item) {
 lock.writeLock().lock();
 try {
  addTransitions(item);
 } catch (Exception e) {
  Log.warn("Cannot generate stem transition for %s with reason %s", item, e.getMessage());
 } finally {
  lock.writeLock().unlock();
 }
}

代码示例来源:origin: ahmetaa/zemberek-nlp

@Override
public void execute(Runnable command) {
 boolean acquired = false;
 do {
  try {
   semaphore.acquire();
   acquired = true;
  } catch (InterruptedException e) {
   Log.warn("Interrupted Exception when acquiring semaphore.", e);
  }
 } while (!acquired);
 try {
  super.execute(command);
 } catch (final RejectedExecutionException e) {
  semaphore.release();
  throw e;
 }
}

代码示例来源:origin: ahmetaa/zemberek-nlp

void checkConsistency() {
 Set<String> intersectionOfKeys = incorrect.getIntersectionOfKeys(correct);
 int sharedKeyCount = intersectionOfKeys.size();
 if (sharedKeyCount > 0) {
  Log.warn("Incorrect and correct sets share %d keys", sharedKeyCount);
 }
 sharedKeyCount = incorrect.getIntersectionOfKeys(ignored).size();
 if (sharedKeyCount > 0) {
  Log.warn("Incorrect and ignored sets share %d keys", sharedKeyCount);
 }
 sharedKeyCount = correct.getIntersectionOfKeys(ignored).size();
 if (sharedKeyCount > 0) {
  Log.warn("Correct and ignored sets share %d keys", sharedKeyCount);
 }
}

代码示例来源:origin: ahmetaa/zemberek-nlp

/**
 * @param indexes word indexes.
 * @return Words representations of the indexes. If an index is out of bounds, <UNK>
 * representation is used. Note that Vocabulary may contain an <UNK> word in it.
 */
public String[] toWords(int... indexes) {
 String[] words = new String[indexes.length];
 int k = 0;
 for (int index : indexes) {
  if (contains(index)) {
   words[k++] = vocabulary.get(index);
  } else {
   Log.warn("Out of bounds word index is used:" + index);
   words[k++] = unknownWord;
  }
 }
 return words;
}

代码示例来源:origin: ahmetaa/zemberek-nlp

public static PairRule fromLine(String line) {
 String[] tokens = line.trim().split("[ ]+");
 if (tokens.length == 3) {
  return new PairRule(tokens[0], tokens[1], tokens[2]);
 } else if (tokens.length == 5) {
  return new PairRule(tokens[0], tokens[1], tokens[2], tokens[3], tokens[4]);
 } else {
  Log.warn("Unexpected token count in line %s", line);
 }
 return null;
}

代码示例来源:origin: ahmetaa/zemberek-nlp

public void addDictionaryItem(DictionaryItem item) {
 lock.writeLock().lock();
 try {
  List<StemTransition> transitions = generate(item);
  for (StemTransition transition : transitions) {
   addStemTransition(transition);
  }
  if (transitions.size() > 1 || (transitions.size() == 1 && !item.root
    .equals(transitions.get(0).surface))) {
   differentStemItems.putAll(item, transitions);
  }
 } catch (Exception e) {
  Log.warn("Cannot generate stem transition for %s with reason %s", item, e.getMessage());
 } finally {
  lock.writeLock().unlock();
 }
}

代码示例来源:origin: ahmetaa/zemberek-nlp

private void handleSpecialToken(String word) throws IOException {
 if (vocabularyBuilder.indexOf(word) == -1
   && vocabularyBuilder.indexOf(word.toUpperCase()) == -1) {
  Log.warn("Special token " + word +
    " does not exist in model. It is added with default [unknown word] probability: " +
    DEFAULT_UNKNOWN_PROBABILTY);
  int index = vocabularyBuilder.add(word);
  gramOs.writeInt(index);
  probOs.writeFloat(DEFAULT_UNKNOWN_PROBABILTY);
  if (ngramCounts.size() > 1) {
   backoOffs.writeFloat(0);
  }
 }
}

代码示例来源:origin: ahmetaa/zemberek-nlp

public static String reduceHtml(String htmlToReduce) {
 String htmlBody = getHtmlBody(htmlToReduce);
 if (htmlBody == null) {
  Log.warn("Cannot get html body. ");
  return htmlToReduce;
 }
 List<String> parts = Regexps.allMatches(HTML_META_CONTENT_TAG, htmlToReduce);
 return HTML_START + "<html><head>" + Joiner.on(" ").join(parts) +
   "</head>\n" + cleanScripts(htmlBody) + "</html>";
}

代码示例来源:origin: ahmetaa/zemberek-nlp

private static void filterVocab(Path vocabFile, Path outFile) throws IOException {
 List<String> words = Files.readAllLines(vocabFile, StandardCharsets.UTF_8);
 TurkishMorphology morphology = TurkishMorphology.createWithDefaults();
 List<String> result = new ArrayList<>();
 for (String word : words) {
  WordAnalysis analysis = morphology.analyze(word);
  if (!analysis.isCorrect()) {
   Log.warn("Cannot analyze %s", word);
   continue;
  }
  result.add(word);
 }
 Files.write(outFile, result, StandardCharsets.UTF_8);
}

代码示例来源:origin: ahmetaa/zemberek-nlp

public NormalizationServiceImpl(ZemberekContext context) throws IOException {
 this.context = context;
 if (context.configuration != null && context.configuration.normalizationPathsAvailable()) {
  sentenceNormalizer = new TurkishSentenceNormalizer(
    context.morphology,
    context.configuration.normalizationDataRoot,
    context.configuration.normalizationLmPath);
 } else {
  Log.warn("Normalization paths are not available. Normalization service is down.");
 }
}

代码示例来源:origin: ahmetaa/zemberek-nlp

public void removeDictionaryItem(DictionaryItem item) {
 lock.writeLock().lock();
 try {
  List<StemTransition> transitions = generate(item);
  for (StemTransition transition : transitions) {
   stemTransitionTrie.remove(transition.surface, transition);
  }
  if (differentStemItems.containsKey(item)) {
   differentStemItems.removeAll(item);
  }
 } catch (Exception e) {
  Log.warn("Cannot remove %s ", e.getMessage());
 } finally {
  lock.writeLock().unlock();
 }
}

代码示例来源:origin: ahmetaa/zemberek-nlp

public void removeDictionaryItem(DictionaryItem item) {
 lock.writeLock().lock();
 try {
  List<StemTransition> transitions = generate(item);
  for (StemTransition transition : transitions) {
   removeStemNode(transition);
  }
  if (differentStemItems.containsKey(item)) {
   differentStemItems.removeAll(item);
  }
 } catch (Exception e) {
  Log.warn("Cannot remove %s ", item, e.getMessage());
 } finally {
  lock.writeLock().unlock();
 }
}

代码示例来源:origin: ahmetaa/zemberek-nlp

private void handleSpecialToken(String word) throws IOException {
 if (vocabularyBuilder.indexOf(word) == -1) {
  Log.warn("Special token " + word +
    " does not exist in model. It is added with default unknown probability: " +
    DEFAULT_UNKNOWN_PROBABILITY);
  int index = vocabularyBuilder.add(word);
  probabilities.put(new NgramData(index), new NgramProb(DEFAULT_UNKNOWN_PROBABILITY, 0));
 }
}

相关文章

微信公众号

最新文章

更多