您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

Web API 接口Web API Interface

可以通过一组 Web API 托管和访问知识探索服务生成的模型文件。The model files built by the Knowledge Exploration Service can be hosted and accessed via a set of web APIs. 可以使用 host_service 命令在本地计算机上托管 API,也可以使用 deploy_service 命令将 API 部署到 Azure 云服务。The APIs may be hosted on the local machine using the host_service command, or may be deployed to an Azure cloud service using the deploy_service command. 这两种技术都公开以下 API 终结点:Both techniques expose the following API endpoints:

  • interpret - 解释自然语言查询字符串。interpret – Interprets a natural language query string. 返回批注版解释,以实现可预测用户输入内容的丰富搜索框自动完成体验。Returns annotated interpretations to enable rich search-box auto-completion experiences that anticipate what the user is typing.
  • evaluate - 计算并返回结构化查询表达式的输出。evaluate – Evaluates and returns the output of a structured query expression.
  • calchistogram - 计算结构化查询表达式返回的对象的属性值直方图。calchistogram – Calculates a histogram of attribute values for objects returned by a structured query expression.

综合使用这些 API 方法,可以创建丰富的语义搜索体验。Used together, these API methods allow the creation of a rich semantic search experience. 在自然语言查询字符串给定的情况下,interpret 方法根据基础语法和索引数据,提供包含结构化查询表达式的批注版输入查询。Given a natural language query string, the interpret method provides annotated versions of the input query with structured query expressions, based on the underlying grammar and index data. evaluate 方法计算结构化查询表达式,并返回匹配索引对象以供显示。The evaluate method evaluates the structured query expression and returns the matching index objects for display. calchistogram 方法计算属性值分布,以启用筛选和优化。The calchistogram method computes the attribute value distributions to enable filtering and refinement.

示例Example

在学术出版物领域中,如果用户键入字符串“latent s”,interpret 方法可以提供一组排名解释,同时提示用户可能正在搜索关键字“latent semantic analysis”(潜在语义分析)、标题“latent structure analysis”(潜在结构分析)或以“latent s”开头的其他表达式。In an academic publications domain, if a user types the string "latent s", the interpret method can provide a set of ranked interpretations, suggesting that the user might be searching for the keyword "latent semantic analysis", the title "latent structure analysis", or other expressions starting with "latent s". 此信息可用于快速引导用户获得所需搜索结果。This information can be used to quickly guide the user to the desired search results.

对于此域,evaluate 方法可用于从学术索引中检索一组匹配出版物,calchistogram 方法可用于计算匹配出版物的属性值分布,这可用于进一步筛选和优化搜索结果。For this domain, the evaluate method can be used to retrieve a set of matching publications from the academic index, and the calchistogram method can be used to calculate the distribution of attribute values for the matching publications, which can be used to further filter and refine the search results.

请注意,REST API 调用包含未经 URL 编码的字符(如空格)是为了提高示例的可读性。Note that to improve the readability of the examples, the REST API calls contain characters (such as spaces) that have not been URL-encoded. 你的代码需要应用适当的 URL 编码。Your code will need to apply the appropriate URL-encodings.