当前位置: 首页>>代码示例>>Java>>正文


Java WAQuery类代码示例

本文整理汇总了Java中com.wolfram.alpha.WAQuery的典型用法代码示例。如果您正苦于以下问题:Java WAQuery类的具体用法?Java WAQuery怎么用?Java WAQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WAQuery类属于com.wolfram.alpha包,在下文中一共展示了WAQuery类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getQueryResult

import com.wolfram.alpha.WAQuery; //导入依赖的package包/类
public WAQueryResult getQueryResult(String query) {
	String url;
	try {
		url = "http://www.wolframalpha.com/input/?i=" + URLEncoder.encode(query, "UTF-8");
	} catch (UnsupportedEncodingException e1) {
	}
	// openUrl(url);
	// The WAEngine is a factory for creating WAQuery objects,
	// and it also used to perform those queries. You can set properties of
	// the WAEngine (such as the desired API output format types) that will
	// be inherited by all WAQuery objects created from it. Most
	// applications
	// will only need to crete one WAEngine object, which is used throughout
	// the life of the application.
	WAEngine engine = new WAEngine();

	// These properties will be set in all the WAQuery objects created from
	// this WAEngine.
	engine.setAppID(AppID);
	engine.addFormat("plaintext");
	engine.addFormat("image");

	// Create the query.
	WAQuery waquery = engine.createQuery();

	// Set properties of the query.
	waquery.setInput(query);

	try {
		// For educational purposes, print out the URL we are about to send:
		// System.out.println("Query URL:");
		// System.out.println(engine.toURL(waquery));
		// System.out.println("");

		// This sends the URL to the Wolfram|Alpha server, gets the XML
		// result
		// and parses it into an object hierarchy held by the WAQueryResult
		// object.
		return engine.performQuery(waquery);
	} catch (Exception e) {
	}
	return null;
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:44,代码来源:WolframAlpha.java

示例2: copy

import com.wolfram.alpha.WAQuery; //导入依赖的package包/类
public WAQuery copy() {
    return new WAQueryImpl(this);
}
 
开发者ID:shobhitchittora,项目名称:OCR-Equation-Solver,代码行数:4,代码来源:WAQueryImpl.java

示例3: getQuery

import com.wolfram.alpha.WAQuery; //导入依赖的package包/类
public WAQuery getQuery() {
    return query;
}
 
开发者ID:shobhitchittora,项目名称:OCR-Equation-Solver,代码行数:4,代码来源:WAQueryResultImpl.java

示例4: getQueryResult

import com.wolfram.alpha.WAQuery; //导入依赖的package包/类
public WAQueryResult getQueryResult(String query) {
  // String url;
  // try {
  // url = "http://www.wolframalpha.com/input/?i=" + URLEncoder.encode(query,
  // "UTF-8");
  // } catch (UnsupportedEncodingException e1) {
  // }
  // openUrl(url);
  // The WAEngine is a factory for creating WAQuery objects,
  // and it also used to perform those queries. You can set properties of
  // the WAEngine (such as the desired API output format types) that will
  // be inherited by all WAQuery objects created from it. Most
  // applications
  // will only need to crete one WAEngine object, which is used throughout
  // the life of the application.
  WAEngine engine = new WAEngine();

  // These properties will be set in all the WAQuery objects created from
  // this WAEngine.
  engine.setAppID(AppID);
  engine.addFormat("plaintext");
  engine.addFormat("image");

  // Create the query.
  WAQuery waquery = engine.createQuery();

  // Set properties of the query.
  waquery.setInput(query);

  try {
    // For educational purposes, print out the URL we are about to send:
    // System.out.println("Query URL:");
    // System.out.println(engine.toURL(waquery));
    // System.out.println("");

    // This sends the URL to the Wolfram|Alpha server, gets the XML
    // result
    // and parses it into an object hierarchy held by the WAQueryResult
    // object.
    return engine.performQuery(waquery);
  } catch (Exception e) {
  }
  return null;
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:45,代码来源:WolframAlpha.java


注:本文中的com.wolfram.alpha.WAQuery类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。