本文整理匯總了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);
}
}
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
}
示例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 ]");
}
示例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);
}
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);