Main Content

docfun

应用函数在documents

描述

例子

新DOCUMENTS= docfun(功能,,,,文件calls the function specified by the function handle功能并通过文件作为单词的字符串向量。

  • 如果功能完全接受一个输入参数,然后newDocuments(i)是输出func(字符串(文档(i)))

  • 如果功能接受两个输入参数,然后newDocuments(i)是输出功能(string(documents(i)),details), 在哪里细节包含相应的令牌详细信息输出tokendetails

  • 如果功能更改文档中的单词数,然后docfun从该文档中删除令牌详细信息。

docfundoes not perform the calls to function功能按照特定顺序。

例子

新DOCUMENTS= docfun(功能,,,,文档1,,,,。。。,,,,文件n)calls the function specified by the function handle功能并通过Documents1,…,Documentsn作为单词的字符串向量,n是功能的输入数量功能。话的话newDocuments(i)是输出func(string(documents1(i)),...,字符串(documentsn(i)))

每一个Documents1,…,Documentsn必须是相同的大小。

例子

全部收缩

申请撤销to each word in a document array.

documents = tokenizedDocument([...“简短句子的例子”“第二句话”)))
文件= 2x1 tokenizedDocument: 6 tokens: an example of a short sentence 4 tokens: a second short sentence
func = @reverse;newDocuments = docfun(func,文档)
newDocuments = 2x1 tokenizeddocument:6代币:na elpmaxe fo a trohs ecnetnes 4代币:a dnoces trohs ecnetnes

使用字符串函数将一个文档数组中的单词与另一个文档数组的单词结合在一起来标记单词plus

创建第一个tokenizedDocument大批。擦除标点符号并将文本转换为小写。

str = [...“一个简短句子的例子。”“第二句话。”];str =删除(str);str =下(str);documents1 = tokenizedDocument(str)
documents1 = 2x1 tokenizeddocument:6代币:简短句子4令牌的示例:第二个简短句子

创建第二个tokenizedDocument大批。The documents have the same number of words as the corresponding documents in文档1。话的话文档2是相应单词的POS标签。

文档2= tokenizedDocument([...“ _det _noun _prep _det _adj _noun”“ _det _adj _adj _noun”)))
文档2= 2x1 tokenizedDocument: 6 tokens: _det _noun _prep _det _adj _noun 4 tokens: _det _adj _adj _noun
功能= @plus; newDocuments = docfun(func,documents1,documents2)
newDocuments = 2x1 tokenizedDocument:6代币:an_det example_noun of_prep a_det short_adj stont_noun 4 tokens:a_det second_adj short_adj stont_noun

The output is not the same as callingplus直接在文档上。

plus(documents1,documents2)
ans = 2x1 tokenizedDocument:12令牌:一个简短句子的示例_det _noun _prep _det _det _adj _noun 8 tokens:第二个简短句子_det _adj _adj _noun

输入参数

全部收缩

功能句柄that acceptsn字符串数组作为输入并输出字符串数组。功能必须接受string(documents1(i)),...,string(documentsn(i))作为输入。

功能处理以适用于文档中的单词。该函数必须具有以下语法之一:

  • newwords = func(单词), 在哪里is a string array of the words of a single document.

  • newwords = func(单词,详细信息), 在哪里是单个文档单词的字符串数组,以及细节是对应的令牌详细信息表tokendetails

  • newwords = func(words1,...,wordsn), 在哪里单词1,...,wordsn是单词的字符串数组。

例子:@撤销

数据类型:function_handle

输入文档,指定为tokenizedDocument大批。

输出参数

全部收缩

输出文档,返回tokenizedDocument大批。

版本历史记录

在R2017b中引入