本文整理汇总了Java中edu.cornell.cs.nlp.spf.mr.lambda.FlexibleTypeComparator类的典型用法代码示例。如果您正苦于以下问题:Java FlexibleTypeComparator类的具体用法?Java FlexibleTypeComparator怎么用?Java FlexibleTypeComparator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FlexibleTypeComparator类属于edu.cornell.cs.nlp.spf.mr.lambda包,在下文中一共展示了FlexibleTypeComparator类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import edu.cornell.cs.nlp.spf.mr.lambda.FlexibleTypeComparator; //导入依赖的package包/类
public static void main(String[] args) {
// //////////////////////////////////////////
// Init logging
// //////////////////////////////////////////
Logger.DEFAULT_LOG = new Log(System.err);
Logger.setSkipPrefix(true);
LogLevel.setLogLevel(LogLevel.INFO);
// //////////////////////////////////////////
// Init lambda calculus system.
// //////////////////////////////////////////
try {
// Init the logical expression type system
LogicLanguageServices
.setInstance(new LogicLanguageServices.Builder(
new TypeRepository(new File(args[1])),
new FlexibleTypeComparator()).build());
} catch (final IOException e) {
throw new RuntimeException(e);
}
// //////////////////////////////////////////
// Print output file.
// //////////////////////////////////////////
// Read input data.
final SingleSentenceCollection data = SingleSentenceCollection.read(new File(
args[0]));
for (final SingleSentence sentence : data) {
System.out.println(sentence.getSample());
System.out.println(ListUtils.join(
GetConstantsMultiSet.of(sentence.getLabel()), " "));
System.out.println();
}
}
示例2: NlpPipeline
import edu.cornell.cs.nlp.spf.mr.lambda.FlexibleTypeComparator; //导入依赖的package包/类
public NlpPipeline(Map<String, String> options) throws Exception {
super(options);
System.err.println(options);
this.options = options;
if (options.containsKey(DEPLAMBDA) && options.get(DEPLAMBDA).equals("true")) {
System.err.println("Loading DepLambda Model.. ");
try {
MutableTypeRepository types =
new MutableTypeRepository(options.get(DEPLAMBDA_DEFINED_TYPES_FILE));
System.err.println(String.format("%s=%s", DEPLAMBDA_DEFINED_TYPES_FILE,
options.get(DEPLAMBDA_DEFINED_TYPES_FILE)));
LogicLanguageServices.setInstance(new LogicLanguageServices.Builder(
types, new FlexibleTypeComparator()).closeOntology(false)
.setNumeralTypeName("i").build());
TransformationRuleGroups treeTransformationRules;
treeTransformationRules =
new TransformationRuleGroups(
options.get(DEPLAMBDA_TREE_TRANSFORMATIONS_FILE));
System.err.println(String.format("%s=%s",
DEPLAMBDA_TREE_TRANSFORMATIONS_FILE,
options.get(DEPLAMBDA_TREE_TRANSFORMATIONS_FILE)));
TransformationRuleGroups relationPrioritiesRules =
new TransformationRuleGroups(
options.get(DEPLAMBDA_RELATION_PRORITIES_FILE));
System.err.println(String.format("%s=%s",
DEPLAMBDA_RELATION_PRORITIES_FILE,
options.get(DEPLAMBDA_RELATION_PRORITIES_FILE)));
TransformationRuleGroups lambdaAssignmentRules =
new TransformationRuleGroups(
options.get(DEPLAMBDA_LAMBDA_ASSIGNMENT_RULES_FILE));
System.err.println(String.format("%s=%s",
DEPLAMBDA_LAMBDA_ASSIGNMENT_RULES_FILE,
options.get(DEPLAMBDA_LAMBDA_ASSIGNMENT_RULES_FILE)));
Boolean lexicalizePredicates =
Boolean.parseBoolean(options.getOrDefault(
DEPLAMBDA_LEXICALIZE_PREDICATES, "true"));
Logger logger = null;
if (options.containsKey(DEPLAMBDA_DEBUG_TO_FILE)
&& !options.get(DEPLAMBDA_DEBUG_TO_FILE).trim().equals("")) {
logger = Logger.getLogger(getClass());
PatternLayout layout = new PatternLayout("%r [%t] %-5p: %m%n");
logger.setLevel(Level.DEBUG);
logger.setAdditivity(false);
Appender fileAppender =
new FileAppender(layout, options.get(DEPLAMBDA_DEBUG_TO_FILE));
logger.addAppender(fileAppender);
}
treeTransformer =
new TreeTransformerMain(treeTransformationRules,
relationPrioritiesRules, lambdaAssignmentRules, logger,
lexicalizePredicates);
System.err.println("Loaded DepLambda Model.. ");
} catch (IOException e) {
e.printStackTrace();
}
}
}
示例3: main
import edu.cornell.cs.nlp.spf.mr.lambda.FlexibleTypeComparator; //导入依赖的package包/类
public static void main(String[] args) {
if (args.length == 0 || args.length % 2 != 0) {
System.err
.println("Specify pipeline arguments, e.g., annotator, languageCode, preprocess.capitalize. See the NlpPipelineTest file.");
System.exit(0);
}
Map<String, String> options = new HashMap<>();
for (int i = 0; i < args.length; i += 2) {
options.put(args[i], args[i + 1]);
}
Printer printer = new LogicalExpressionSimpleIndenter.Printer(" ");
String defined_types = NlpPipeline.DEPLAMBDA_DEFINED_TYPES_FILE;
try {
TypeRepository types =
new MutableTypeRepository(options.get(defined_types));
System.err.println(String.format("%s=%s", defined_types,
options.get(defined_types)));
LogicLanguageServices.setInstance(new LogicLanguageServices.Builder(
types, new FlexibleTypeComparator())
.closeOntology(false)
.setNumeralTypeName("i")
// .setPrinter(new LogicalExpressionVjIndenter.Printer(" "))
.build());
} catch (IOException z) {
z.printStackTrace();
}
String input = read(System.in);
JsonParser jsonParser = new JsonParser();
JsonObject jsonSentence =
jsonParser
.parse(input)
.getAsJsonObject();
Sentence sentence = new Sentence(jsonSentence);
System.out.println("----\nSentence: " + cleanString(""+jsonSentence.get("sentence")));
System.out.println("\nDepTree:\n" + TreePrinter.toIndentedString(sentence.getRootNode()));
JsonPrimitive c = (JsonPrimitive) jsonSentence.get(SentenceKeys.DEPLAMBDA_EXPRESSION);
String depLambda = cleanString(c.toString());
JsonElement logic = jsonSentence.get(SentenceKeys.DEPENDENCY_LAMBDA);
System.out.println("\nDepLambda Expr:\n " + printer.toString(SimpleLogicalExpressionReader.read(depLambda)));
System.out.println("\nDepLambda simplified: ");
printJsonArray((JsonArray) logic);
}
示例4: run
import edu.cornell.cs.nlp.spf.mr.lambda.FlexibleTypeComparator; //导入依赖的package包/类
@Override
public void run(OptionSet options) {
try {
int nthreadsVal = options.valueOf(nthreads);
String inputFileVal = options.valueOf(inputFile);
InputStream inputStream = SentenceUtils.getInputStream(inputFileVal);
MutableTypeRepository types =
new MutableTypeRepository(options.valueOf(definedTypesFile));
LogicLanguageServices.setInstance(new LogicLanguageServices.Builder(
types, new FlexibleTypeComparator()).closeOntology(false)
.setNumeralTypeName("i").build());
TransformationRuleGroups treeTransformationRules =
new TransformationRuleGroups(options.valueOf(treeTransformationsFile));
TransformationRuleGroups relationPrioritiesRules =
new TransformationRuleGroups(options.valueOf(relationPrioritiesFile));
TransformationRuleGroups lambdaAssignmentRules =
new TransformationRuleGroups(
options.valueOf(lambdaAssignmentRulesFile));
Logger logger = null;
if (!options.valueOf(debugToFile).equals("")) {
logger = Logger.getLogger(getClass());
PatternLayout layout = new PatternLayout("%r [%t] %-5p: %m%n");
logger.setLevel(Level.DEBUG);
logger.setAdditivity(false);
Appender fileAppender =
new FileAppender(layout, options.valueOf(debugToFile));
logger.addAppender(fileAppender);
}
TreeTransformerMain treeTransformer =
new TreeTransformerMain(treeTransformationRules,
relationPrioritiesRules, lambdaAssignmentRules, logger,
options.valueOf(lexicalizePredicates));
if (options.valueOf(inputTypeIsForest)) {
ForestTransformerMain forestTransoformer =
new ForestTransformerMain(treeTransformer);
forestTransoformer.processStream(inputStream, System.out, nthreadsVal,
true);
} else {
treeTransformer.processStream(inputStream, System.out, nthreadsVal,
true);
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}