在 PowerShell 中使用有关非结构化文档处理模型的说明
适用于: • 非结构化文档处理
重要
Microsoft Syntex PowerShell cmdlet 和所有其他 PnP 组件都是开源工具,由提供支持的活动社区提供支持。 没有来自 Microsoft 的官方支持渠道的开放源代码工具支持的 SLA。
自定义说明模板存储在内容中心内的列表中。 由于这些说明存储为列表项,因此可以使用 PowerShell 与其交互。
列出保存的解释
此示例演示如何查看已保存在特定内容中心的所有自定义说明模板。
$contentCenterURL = "https://contoso.sharepoint.com/sites/yourContentCenter"
# Connect to content center
Connect-PnPOnline -url $contentCenterURL
# Load explanation templates list and items
$explanationTemplatesList = Get-PnPList -Identity "/Explanations"
$explanations = Get-PnPListItem -List $explanationTemplatesList -Fields "Id", "Title", "ExplanationName", "ExplanationType", "ExplanationDescription","ExplanationContent"
# Extract explanation components
$explanationValues = $explanations.fieldvalues
$explanationOutput = @()
foreach ($explanation in $explanationValues) {
$content = $explanation.ExplanationContent
$content = $content.replace('false','"false"')
$content = $content.replace('true','"true"')
$contentArray = $content | ConvertFrom-Json
$output = New-Object -TypeName PSObject
Add-Member -InputObject $output -MemberType NoteProperty -Name "Explanation Name" -Value $explanation.ExplanationName
Add-Member -InputObject $output -MemberType NoteProperty -Name "Explanation Description" -Value $explanation.ExplanationDescription
Add-Member -InputObject $output -MemberType NoteProperty -Name "Explanation Type" -Value $contentArray.kind
Add-Member -InputObject $output -MemberType NoteProperty -Name "RegEx Pattern" -Value $contentArray.pattern
Add-Member -InputObject $output -MemberType NoteProperty -Name "Phrase List" -Value $contentArray.ngrams
Add-Member -InputObject $output -MemberType NoteProperty -Name "Case Sensitive" -Value $contentArray.caseSensitive
Add-Member -InputObject $output -MemberType NoteProperty -Name "Ignore Digit Identity" -Value $contentArray.ignoreDigitIdentity
Add-Member -InputObject $output -MemberType NoteProperty -Name "Ignore Letter Identity" -Value $contentArray.ignoreLetterIdentity
$explanationOutput += $output
}
$explanationOutput
创建短语列表说明
此示例演示如何创建自定义短语列表说明模板。
$contentCenterURL = "https://contoso.sharepoint.com/sites/yourContentCenter"
$explanationName = "Phrase Explanation A"
$explanationDescription = "This is my explanation"
$phrases = "Phrase 1", "Phrase 2"
$caseSensitive = $false
$ignoreDigitIdentity= $false
$ignoreLetterIdentity = $false
# Connect to content center
Connect-PnPOnline -url $contentCenterURL
# Load explanation templates list
$explanationTemplatesList = Get-PnPList -Identity "/Explanations"
#Generate GUID for explanation
$guid = New-Guid
#Format phrase list
$phrases = $phrases -join "`",`""
#Convert booleans to lower case strings
$caseSensitive = ($caseSensitive.ToString()).ToLower()
$ignoreDigitIdentity= ($ignoreDigitIdentity.ToString()).ToLower()
$ignoreLetterIdentity = ($ignoreLetterIdentity.ToString()).ToLower()
# Build explanation content
$explanationContent = "{`"id`":`"$guid`",`"kind`":`"dictionaryFeature`",`"name`":`"$explanationName`",`"active`":true,`"nGrams`":[`"$phrases`"],`"caseSensitive`":$caseSensitive,`"ignoreDigitIdentity`":$ignoreDigitIdentity,`"ignoreLetterIdentity`":$ignoreLetterIdentity}"
# Create item in explanation list
Add-PnPListItem -List $explanationTemplatesList -Values @{"Title"= $explanationName; "ExplanationName" = $explanationName; "ExplanationDescription" = $explanationDescription; "ExplanationContent" = $explanationContent}
创建正则表达式说明
此示例演示如何创建自定义正则表达式说明模板。
$contentCenterURL = "https://contoso.sharepoint.com/sites/yourContentCenter"
$explanationName = "RegEx Explanation A"
$explanationDescription = "This is my explanation"
$pattern = "\b(https?):\/\/\S+"
# Connect to content center
Connect-PnPOnline -url $contentCenterURL
# Load explanation templates list
$explanationTemplatesList = Get-PnPList -Identity "/Explanations"
#Generate GUID for explanation
$guid = New-Guid
# Build explanation content
$pattern = $pattern.Replace('\','\\')
$explanationContent = "{`"id`":`"$guid`",`"kind`":`"regexFeature`",`"name`":`"$explanationName`",`"active`":true,`"pattern`":`"$pattern`"}"
# Create item in explanation list
Add-PnPListItem -List $explanationTemplatesList -Values @{"Title"= $explanationName; "ExplanationName" = $explanationName; "ExplanationDescription" = $explanationDescription; "ExplanationContent" = $explanationContent}
基于术语集创建短语列表说明
此示例演示如何通过从术语集中获取值来创建自定义短语列表说明模板。 这包括首选术语名称和任何同义词。
$contentCenterURL = "https://contoso.sharepoint.com/sites/yourContentCenter"
$termSetName = "Terms"
$termGroupName = "GroupA"
$explanationName = "MMS Explanation A"
$explanationDescription = "This is my explanation"
$caseSensitive = $false
$ignoreDigitIdentity= $false
$ignoreLetterIdentity = $false
# Connect to content center
Connect-PnPOnline -url $contentCenterURL
# Load explanation templates list
$explanationTemplatesList = Get-PnPList -Identity "/Explanations"
#Generate GUID for explanation
$guid = New-Guid
#Get term set, including preferred labels and synonyms
$terms = Get-PnPTerm -TermGroup $termGroupName -TermSet $termSetName -Includes Labels
$phrases = $terms.labels.value
#Format phrase list
$phrases = $phrases -join "`",`""
#Convert booleans to lower case strings
$caseSensitive = ($caseSensitive.ToString()).ToLower()
$ignoreDigitIdentity= ($ignoreDigitIdentity.ToString()).ToLower()
$ignoreLetterIdentity = ($ignoreLetterIdentity.ToString()).ToLower()
# Build explanation content
$explanationContent = "{`"id`":`"$guid`",`"kind`":`"dictionaryFeature`",`"name`":`"$explanationName`",`"active`":true,`"nGrams`":[`"$phrases`"],`"caseSensitive`":$caseSensitive,`"ignoreDigitIdentity`":$ignoreDigitIdentity,`"ignoreLetterIdentity`":$ignoreLetterIdentity}"
# Create item in explanation list
Add-PnPListItem -List $explanationTemplatesList -Values @{"Title"= $explanationName; "ExplanationName" = $explanationName; "ExplanationDescription" = $explanationDescription; "ExplanationContent" = $explanationContent}