net.sf.okapi.common.Event.isTextUnit()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(143)

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

Event.isTextUnit介绍

[英]Convenience method to tell if this Event carries a ITextUnit
[中]判断此事件是否携带ITextUnit的便捷方法

代码示例

代码示例来源:origin: net.sf.okapi/okapi-core

/**
 * Convenience method returns the {@link IResource} as a {@link ITextUnit}.
 * The caller should confirm the {@link Event} type using isTextUnit before
 * calling this method.
 * 
 * @return the {@link ITextUnit}
 * 
 * @throws OkapiUnexpectedResourceTypeException
 *             if the {@link IResource} is not a {@link ITextUnit}
 */
public ITextUnit getTextUnit () {
  if ( isTextUnit() ) {
    return (ITextUnit)resource;
  }
  throw new OkapiUnexpectedResourceTypeException("Event resource is not a text unit.");
}

代码示例来源:origin: net.sf.okapi.lib/okapi-lib-merge

/**
 * Get events in the original document until the next text unit. Any event
 * before is passed to the writer.
 * 
 * @return the event of the next text unit, or null if no next text unit is
 *         found.
 */
protected Event processUntilTextUnit() {
  Event event = null;
  while (skeletonFilter.hasNext()) {
    event = skeletonFilter.next();
    // No more events
    if (event == null) {
      return event;
    }
    // Process that event
    if (event.isTextUnit()) {
      return event;
    }
    // write out the non-TextUnit event
    writer.handleEvent(event);
  }
  return event;
}

代码示例来源:origin: net.sf.okapi/okapi-core

sb.append('\n').append(leader).append(e.getEventType().name());
if (e.isTextUnit()) {
  ITextUnit tu = e.getTextUnit();
  sb.append(" { id:").append(nqs(tu.getId())).append(",\n\t");

代码示例来源:origin: net.sf.okapi.steps/okapi-step-rainbowkit

private boolean hasPreTranslation (String poPath) {
  IFilter filter = new POFilter();
  try {
    filter.open(new RawDocument(new File(poPath).toURI(), "UTF-8",
      manifest.getSourceLocale(), manifest.getTargetLocale()));
    while ( filter.hasNext() ) {
      Event event = filter.next();
      if ( event.isTextUnit() ) {
        ITextUnit tu = event.getTextUnit();
        if ( tu.hasTarget(manifest.getTargetLocale()) ) return true;
      }
    }
  }
  catch ( Throwable e ) {
    logger.error("Error while looking for pre-translation.\n"+e.getLocalizedMessage());
  }
  finally {
    if ( filter != null ) {
      filter.close();
    }
  }
  return false;
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-msbatchtranslation

if (( computedCategory == null ) && event.isTextUnit() ) {
  ITextUnit tu = event.getTextUnit();

代码示例来源:origin: net.sf.okapi.lib/okapi-lib-merge

private void flushFilterEvents() {
  try {
    // Finish the skeleton events
    Event event = null;
    while (skeletonFilter.hasNext()) {
      event = skeletonFilter.next();
      if (event.isTextUnit()) {
        throw new OkapiMergeException(String.format(
            "No corresponding text unit for id='%s' in the skeleton file.", event.getTextUnit().getId()));
      }
      writer.handleEvent(event);
    } 
  } finally {
    writer.close();
  }
}

代码示例来源:origin: net.sf.okapi.filters/okapi-filter-multiparsers

if ( e.isTextUnit() ) {
  tu = e.getTextUnit();
  if ( tu.isTranslatable() ) {

代码示例来源:origin: net.sf.okapi/okapi-core

private void convertRefs (Event event) {
  if ( event.isMultiEvent() ) {
    MultiEvent me = event.getMultiEvent();
    for (Event e : me) {
      convertRefs(e);
    }
  }
  else {
    if ( event.isTextUnit() ) {
      ITextUnit tu = event.getTextUnit();
      convertTextContainer(tu.getSource());
      for (LocaleId locId : tu.getTargetLocales()) {
        convertTextContainer(tu.getTarget(locId));
      }                
    }
    
    ISkeleton skel = event.getResource().getSkeleton();
    subFilter.convertRefsInSkeleton(skel);            
  }
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-msbatchtranslation

if ( event.isTextUnit() ) {
    ITextUnit tu = event.getTextUnit();
for ( Event event : events ) {
  if ( !event.isTextUnit() ) continue;

代码示例来源:origin: net.sf.okapi.filters/okapi-filter-yaml

if (event.isTextUnit()) {
  event.getTextUnit().setProperty(scalarType);
  event.getTextUnit().setProperty(flow);

相关文章