當前位置: 首頁>>代碼示例>>Java>>正文


Java Env類代碼示例

本文整理匯總了Java中edu.stanford.nlp.ling.tokensregex.Env的典型用法代碼示例。如果您正苦於以下問題:Java Env類的具體用法?Java Env怎麽用?Java Env使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Env類屬於edu.stanford.nlp.ling.tokensregex包,在下文中一共展示了Env類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: IntelKBPTokensregexExtractor

import edu.stanford.nlp.ling.tokensregex.Env; //導入依賴的package包/類
public IntelKBPTokensregexExtractor(String tokensregexDir) {
    logger.log("Creating TokensRegexExtractor");
    // Create extractors        
    for (RelationType rel : RelationType.values()) {
        if (IntelConfig.bSeprateFormerTitle || rel != RelationType.PER_FORMER_TITLE) {
            String path = tokensregexDir + File.separator + rel.canonicalName.replaceAll("/", "SLASH") + ".rules";
            if (IOUtils.existsInClasspathOrFileSystem(path)) {
                List<String> listFiles = new ArrayList<>();
                listFiles.add(tokensregexDir + File.separator + "defs.rules");
                listFiles.add(path);
                logger.log("Rule files for relation " + rel + " is " + path);
                Env env = TokenSequencePattern.getNewEnv();
                env.bind("collapseExtractionRules", true);
                CoreMapExpressionExtractor extr = CoreMapExpressionExtractor.createExtractorFromFiles(env, listFiles).keepTemporaryTags();
                rules.put(rel, extr);
            }
        }
    }
}
 
開發者ID:intel-analytics,項目名稱:InformationExtraction,代碼行數:20,代碼來源:IntelKBPTokensregexExtractor.java

示例2: KBPTokensregexExtractor

import edu.stanford.nlp.ling.tokensregex.Env; //導入依賴的package包/類
public KBPTokensregexExtractor(String tokensregexDir) {
  logger.log("Creating TokensRegexExtractor");
  // Create extractors
  for (RelationType rel : RelationType.values()) {
    String path = tokensregexDir + File.separator + rel.canonicalName.replaceAll("/", "SLASH") + ".rules";
    if (IOUtils.existsInClasspathOrFileSystem(path)) {
      List<String> listFiles = new ArrayList<>();
      listFiles.add(tokensregexDir + File.separator + "defs.rules");
      listFiles.add(path);
      logger.log("Rule files for relation " + rel + " is " + path);
      Env env = TokenSequencePattern.getNewEnv();
      env.bind("collapseExtractionRules", true);
      CoreMapExpressionExtractor extr = CoreMapExpressionExtractor.createExtractorFromFiles(env, listFiles).keepTemporaryTags();
      rules.put(rel, extr);
    }
  }
}
 
開發者ID:intel-analytics,項目名稱:InformationExtraction,代碼行數:18,代碼來源:KBPTokensregexExtractor.java

示例3: evaluate

import edu.stanford.nlp.ling.tokensregex.Env; //導入依賴的package包/類
public Value evaluate(Env env, Object... args) {
  Expression exp = null;
  String varName = value;
  if (args != null) {
    if (args.length == 1 && args[0] instanceof CoreMap) {
      CoreMap cm = (CoreMap) args[0];
      Class annotationKey = EnvLookup.lookupAnnotationKey(env, varName);
      if (annotationKey != null) {
        return createValue(varName, cm.get(annotationKey));
      }
    }
  }
  Object obj = env.get(varName);
  if (obj != null) {
    exp = asExpression(env, obj);
  }
  Value v = exp != null? exp.evaluate(env, args): null;
  if (v == null) {
    System.err.println("Unknown variable: " + varName);
  }
  return v;
}
 
開發者ID:benblamey,項目名稱:stanford-nlp,代碼行數:23,代碼來源:Expressions.java

示例4: simplify

import edu.stanford.nlp.ling.tokensregex.Env; //導入依賴的package包/類
public Expression simplify(Env env)
{
  boolean paramsAllHasValue = true;
  List<Expression> simplifiedParams = new ArrayList<Expression>(params.size());
  for (Expression param:params) {
    Expression simplified = param.simplify(env);
    simplifiedParams.add(simplified);
    if (!(simplified.hasValue())) {
      paramsAllHasValue = false;
    }
  }
  Expression res = new FunctionCallExpression(function, simplifiedParams);
  if (paramsAllHasValue) {
    return res.evaluate(env);
  } else {
    return res;
  }
}
 
開發者ID:benblamey,項目名稱:stanford-nlp,代碼行數:19,代碼來源:Expressions.java

示例5: initEnv

import edu.stanford.nlp.ling.tokensregex.Env; //導入依賴的package包/類
public static void initEnv(Env env)
{
  // Custom binding for numeric values expressions
  env.bind("numtype", CoreAnnotations.NumericTypeAnnotation.class);
  env.bind("numvalue", CoreAnnotations.NumericValueAnnotation.class);
  env.bind("numcomptype", CoreAnnotations.NumericCompositeTypeAnnotation.class);
  env.bind("numcompvalue", CoreAnnotations.NumericCompositeValueAnnotation.class);
  env.bind("$NUMCOMPTERM", " [ { numcomptype::EXISTS } & !{ numcomptype:NUMBER_RANGE } ] ");
  env.bind("$NUMTERM", " [ { numtype::EXISTS } & !{ numtype:NUMBER_RANGE } ] ");
  env.bind("$NUMRANGE", " [ { numtype:NUMBER_RANGE } ] ");
  // TODO: Improve code to only recognize integers
  env.bind("$INTTERM", " [ { numtype::EXISTS } & !{ numtype:NUMBER_RANGE } & !{ word:/.*\\.\\d+.*/} ] ");
  env.bind("$POSINTTERM", " [ { numvalue>0 } & !{ word:/.*\\.\\d+.*/} ] ");
  env.bind("$ORDTERM", " [ { numtype:ORDINAL } ] ");
  env.bind("$BEFORE_WS", " [ { before:/\\s*/ } | !{ before::EXISTS} ]");
  env.bind("$AFTER_WS", " [ { after:/\\s*/ } | !{ after::EXISTS} ]");
  env.bind("$BEFORE_AFTER_WS", " [ $BEFORE_WS & $AFTER_WS ]");
}
 
開發者ID:benblamey,項目名稱:stanford-nlp,代碼行數:19,代碼來源:NumberNormalizer.java

示例6: bind

import edu.stanford.nlp.ling.tokensregex.Env; //導入依賴的package包/類
public void bind(Env env) {
  if (holidays != null) {
    for (String s:holidays.keySet()) {
      JollyHoliday jh = holidays.get(s);
      env.bind(varPrefix + s, jh);
    }
  }
}
 
開發者ID:benblamey,項目名稱:stanford-nlp,代碼行數:9,代碼來源:JollyDayHolidays.java

示例7: extractAnnotation

import edu.stanford.nlp.ling.tokensregex.Env; //導入依賴的package包/類
public boolean extractAnnotation(Env env, CoreMap sourceAnnotation)
{
  boolean okay = super.extractAnnotation(env, sourceAnnotation);
          //super.extractAnnotation(sourceAnnotation, CoreAnnotations.NumerizedTokensAnnotation.class,
          //CoreMapAttributeAggregator.DEFAULT_NUMERIC_TOKENS_AGGREGATORS,
          //TimeExpression.Annotation.class, TimeExpression.ChildrenAnnotation.class);
  if (okay) {
    return addMod();
  } else {
    return false;
  }
}
 
開發者ID:benblamey,項目名稱:stanford-nlp,代碼行數:13,代碼來源:TimeExpression.java

示例8: asObject

import edu.stanford.nlp.ling.tokensregex.Env; //導入依賴的package包/類
public static <C> C asObject(Env env, Object v) {
  if (v instanceof Expression) {
    return (C) ((Expression) v).evaluate(env).get();
  } else {
    return (C) v;
  }
}
 
開發者ID:benblamey,項目名稱:stanford-nlp,代碼行數:8,代碼來源:Expressions.java

示例9: asExpression

import edu.stanford.nlp.ling.tokensregex.Env; //導入依賴的package包/類
public static Expression asExpression(Env env, Object v) {
  if (v instanceof Expression) {
    return (Expression) v;
  } else {
    return createValue(null, v);
  }
}
 
開發者ID:benblamey,項目名稱:stanford-nlp,代碼行數:8,代碼來源:Expressions.java

示例10: asValue

import edu.stanford.nlp.ling.tokensregex.Env; //導入依賴的package包/類
public static Value asValue(Env env, Object v) {
  if (v instanceof Value) {
    return (Value) v;
  } else {
    return createValue(null, v);
  }
}
 
開發者ID:benblamey,項目名稱:stanford-nlp,代碼行數:8,代碼來源:Expressions.java

示例11: simplifyNoTypeConversion

import edu.stanford.nlp.ling.tokensregex.Env; //導入依賴的package包/類
public CompositeValue simplifyNoTypeConversion(Env env, Object... args) {
  Map<String, Expression> m = value;
  Map<String, Expression> res = Generics.newHashMap (m.size());
  for (String s:m.keySet()) {
    res.put(s, m.get(s).simplify(env));
  }
  return new CompositeValue(res, true);
}
 
開發者ID:benblamey,項目名稱:stanford-nlp,代碼行數:9,代碼來源:Expressions.java

示例12: evaluateNoTypeConversion

import edu.stanford.nlp.ling.tokensregex.Env; //導入依賴的package包/類
private CompositeValue evaluateNoTypeConversion(Env env, Object... args) {
  Map<String, Expression> m = value;
  Map<String, Expression> res = Generics.newHashMap (m.size());
  for (String s:m.keySet()) {
    res.put(s, m.get(s).evaluate(env, args));
  }
  return new CompositeValue(res, true);
}
 
開發者ID:benblamey,項目名稱:stanford-nlp,代碼行數:9,代碼來源:Expressions.java

示例13: doEvaluation

import edu.stanford.nlp.ling.tokensregex.Env; //導入依賴的package包/類
public Value doEvaluation(Env env, Object... args) {
  Value v = attemptTypeConversion(this, env, args);
  if (v != null) return v;
  Map<String, Expression> m = value;
  Map<String, Expression> res = Generics.newHashMap (m.size());
  for (String s:m.keySet()) {
    res.put(s, m.get(s).evaluate(env, args));
  }
  disableCaching = !checkValue();
  return new CompositeValue(res, true);
}
 
開發者ID:benblamey,項目名稱:stanford-nlp,代碼行數:12,代碼來源:Expressions.java

示例14: getNewEnv

import edu.stanford.nlp.ling.tokensregex.Env; //導入依賴的package包/類
public static Env getNewEnv()
{
  Env env = TokenSequencePattern.getNewEnv();

  // Do case insensitive matching
  env.setDefaultStringPatternFlags(Pattern.CASE_INSENSITIVE);

  initEnv(env);
  return env;
}
 
開發者ID:benblamey,項目名稱:stanford-nlp,代碼行數:11,代碼來源:NumberNormalizer.java

示例15: simplify

import edu.stanford.nlp.ling.tokensregex.Env; //導入依賴的package包/類
/**
 * Simplifies the expression using the specified environment
 * @param env Environment to simply with respect to
 * @return Simplified expressions
 */
public Expression simplify(Env env);
 
開發者ID:benblamey,項目名稱:stanford-nlp,代碼行數:7,代碼來源:Expression.java


注:本文中的edu.stanford.nlp.ling.tokensregex.Env類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。