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

命令行接口Command Line Interface

知识探索服务 (KES) 命令行接口能够从结构化数据生成索引和语法文件,并将其部署为 Web 服务。The Knowledge Exploration Service (KES) command line interface provides the ability to build index and grammar files from structured data and deploy them as web services. 它用的是常规语法:kes.exe <command> <required_args> [<optional_args>]It uses the general syntax: kes.exe <command> <required_args> [<optional_args>]. 可运行没有参数的 kes.exe 以显示命令列表,或运行 kes.exe <command> 显示可用于指定命令的参数列表。You can run kes.exe without arguments to display a list of commands, or kes.exe <command> to display a list of arguments available for the specified command. 下面是可用命令列表:Below is a list of available commands:

  • build_indexbuild_index
  • build_grammarbuild_grammar
  • host_servicehost_service
  • deploy_servicedeploy_service
  • describe_indexdescribe_index
  • describe_grammardescribe_grammar

build_index 命令build_index Command

build_index 命令可从架构定义文件和要编制索引对象的数据文件生成二进制索引文件 。The build_index command builds a binary index file from a schema definition file and a data file of objects to be indexed. 可以使用生成的索引文件评估结构化的查询表达式,或者与已编译的语法文件结合使用生成自然语言查询的解释。The resulting index file can be used to evaluate structured query expressions, or to generate interpretations of natural language queries in conjunction with a compiled grammar file.

kes.exe build_index <schemaFile> <dataFile> <indexFile> [options]

参数Parameter 描述Description
<schemaFile> 输入架构路径Input schema path
<dataFile> 输入数据路径Input data path
<indexFile> 输出索引路径Output index path
--description <description> 说明字符串Description string
--remote <vmSize> 远程生成 VM 的大小Size of VM for remote build

可通过 Azure blob 的本地文件路径或 URL 路径指定这些文件。These files may be specified by local file paths or URL paths to Azure blobs. 架构文件介绍要编制索引的对象的结构以及要支持的操作(请参阅架构格式)。The schema file describes the structure of the objects being indexed as well as the operations to be supported (see Schema Format). 数据文件将枚举要编制索引的对象和属性值(请参阅数据格式)。The data file enumerates the objects and attribute values to be indexed (see Data Format). 当生成成功时,输出索引文件将包含支持所需操作的输入数据的压缩表示形式。When the build succeeds, the output index file contains a compressed representation of the input data that supports the desired operations.

可使用 describe_index 命令选择指定说明字符串,用来随后标识二进制索引 。A description string may be optionally specified to subsequently identify a binary index using the describe_index command.

默认情况下,在本地计算机上生成索引。By default, the index is built on the local machine. 在 Azure 环境外部,本地生成被限制为最多包含 10,000 个对象的数据文件。Outside of the Azure environment, local builds are limited to data files containing up to 10,000 objects. 指定 --remote 标记时,将在临时创建的具有指定大小的 VM 上生成索引。When the --remote flag is specified, the index will be built on a temporarily created Azure VM of the specified size. 这样便可使用具有更多内存的 Azure VM 有效生成大型索引。This allows large indices to be built efficiently using Azure VMs with more memory. 若要避免减缓生成过程的分页,建议将 3 倍 RAM 大小的 VM 作为输入数据文件大小。To avoid paging which slows down the build process, we recommend using a VM with 3 times the amount of RAM as the input data file size. 有关可用的 VM 大小列表,请参阅虚拟机大小For a list of available VM sizes, see Sizes for virtual machines.

提示

为了更快生成,可通过降低概率来预先分类数据文件中的对象。For faster builds, presort the objects in the data file by decreasing probability.

build_grammar 命令build_grammar Command

build_grammar 命令可将指定的 XML 格式的语法编译为二进制语法文件 。The build_grammar command compiles a grammar specified in XML to a binary grammar file. 可将生成的语法文件与索引文件结合使用,以生成自然语言查询的解释。The resulting grammar file can be used in conjunction with an index file to generate interpretations of natural language queries.

kes.exe build_grammar <xmlFile> <grammarFile>

参数Parameter 描述Description
<xmlFile> 输入 XML 语法规范路径Input XML grammar specification path
<grammarFile> 输出已编译语法路径Output compiled grammar path

可通过 Azure blob 的本地文件路径或 URL 路径指定这些文件。These files may be specified by local file paths or URL paths to Azure blobs. 语法规范描述加权自然语言表达式及其语义解释集(请参阅语法格式)。The grammar specification describes the set of weighted natural language expressions and their semantic interpretations (see Grammar Format). 如果生成成功,输出语法文件将包含语法规范的二进制表示形式,以支持快速解码。When the build succeeds, the output grammar file contains a binary representation of the grammar specification to enable fast decoding.

host_service 命令host_service Command

host_service 命令在本地计算机上承载 KES 服务实例 。The host_service command hosts an instance of the KES service on the local machine.

kes.exe host_service <grammarFile> <indexFile> [options]

参数Parameter 描述Description
<grammarFile> 输入二进制语法路径Input binary grammar path
<indexFile> 输入二进制索引路径Input binary index path
--port <port> 本地端口号。Local port number. 默认值:8000Default: 8000

可通过 Azure blob 的本地文件路径或 URL 路径指定这些文件。These files may be specified by local file paths or URL paths to Azure blobs. Web 服务将承载于 http://localhost:&lt ;port> /。A web service will be hosted at http://localhost:<port>/. 请参阅 Web API,了解受支持操作的列表。See Web APIs for a list of supported operations.

在 Azure 环境外,本地托管服务被限制为大小最大 1 MB 的索引文件、每秒 10 个请求和 1000 个总调用数。Outside of the Azure environment, locally hosted services are limited to index files up to 1 MB in size, 10 requests per second, and 1000 total calls. 若要消除这些限制,请在 Azure VM 中运行 host_service,或者使用 deploy_service 将其部署到 Azure 云服务 。To overcome these limitations, run host_service inside an Azure VM, or deploy to an Azure cloud service using deploy_service.

deploy_service 命令deploy_service Command

deploy_service 命令可将 KES 服务实例部署到 Azure 云服务 。The deploy_service command deploys an instance of the KES service to an Azure cloud service.

kes.exe deploy_service <grammarFile> <indexFile> <serviceName> <vmSize>[options]

参数Parameter 描述Description
<grammarFile> 输入二进制语法路径Input binary grammar path
<indexFile> 输入二进制索引路径Input binary index path
<serviceName> 目标云服务的名称Name of target cloud service
<vmSize> 云服务 VM 大小Size of cloud service VM
--slot <slot> 云服务槽位:“过渡”(默认)、“生产”Cloud service slot: "staging" (default), "production"

可通过 Azure blob 的本地文件路径或 URL 路径指定这些文件。These files may be specified by local file paths or URL paths to Azure blobs. 服务名称可指定预配置的 Azure 云服务(请参阅如何创建和部署云服务)。Service name specifies a preconfigured Azure cloud service (see How to Create and Deploy a Cloud Service). 该命令将使用指定大小的 VM 将 KES 服务自动部署到指定的 Azure 云服务。The command will automatically deploy the KES service to the specified Azure cloud service, using VMs of the specified size. 若要避免导致性能显著下降的分页操作,建议使用比输入文件大小多 1 GB RAM 的 VM。To avoid paging which significantly decreases performance, we recommend using a VM with 1 GB more RAM than the input index file size. 有关可用的 VM 大小列表,请参阅云服务大小For a list of available VM sizes, see Sizes for Cloud Services.

默认情况下,服务将部署到过渡环境中,可选择通过 --slot 参数重写。By default, the service is deployed to the staging environment, optionally overridden via the --slot parameter. 请参阅 Web API,了解受支持操作的列表。See Web APIs for a list of supported operations.

describe_index 命令describe_index command

describe_index 命令可输出有关索引文件的信息(包括架构和说明) 。The describe_index command outputs information about an index file, including the schema and description.

kes.exe describe_index <indexFile>

参数Parameter 描述Description
<indexFile> 输入索引路径Input index path

可通过 Azure blob 的本地文件路径或 URL 路径指定此文件。This file may be specified by a local file path or a URL path to an Azure blob. 可以使用 build_index 命令的 --description 参数指定输出描述字符串 。The output description string can be specified using the --description parameter of the build_index command.

describe_grammar 命令describe_grammar command

describe_grammar 命令输出用来生成二进制语法的原始语法规范 。The describe_grammar command outputs the original grammar specification used to build the binary grammar.

kes.exe describe_grammar <grammarFile>

参数Parameter 描述Description
<grammarFile> 输入语法路径Input grammar path

可通过 Azure blob 的本地文件路径或 URL 路径指定此文件。This file may be specified by a local file path or a URL path to an Azure blob.