extractKeywords
- addBibliography
- addBookmark
- addBreak
- addChart
- addCitation
- addComment
- addCrossReference
- addDateAndHour
- addEndnote
- addExternalFile
- addFootnote
- addFormElement
- addHeading
- addImage
- addLink
- addList
- addMathEquation
- addMergeField
- addOLE
- addOnlineVideo
- addPageNumber
- addShape
- addSimpleField
- addSource
- addStructuredDocumentTag
- addSVG
- addTab
- addTable
- addTableContents
- addTableFigures
- addText
- addTextBox
- addWordFragment
- addWordML
- embedHTML
- addBackgroundImage
- addFooter
- addFooterSection
- addHeader
- addHeaderSection
- addLineNumbering
- addMacroFromDoc
- addPageBorders
- addProperties
- addSection
- createDocx
- createDocxAndDownload
- createCharacterStyle
- createListStyle
- createParagraphStyle
- createTableStyle
- docxSettings
- embedFont
- importChartStyle
- importHeadersAndFooters
- importListStyle
- importStyles
- importStylesWordDefault
- modifyPageLayout
- parseStyles
- removeFooters
- removeHeaders
- setBackgroundColor
- setDecimalSymbol
- setDefaultFont
- setDocumentDefaultStyles
- setEncodeUTF8
- setLanguage
- setMarkAsFinal
- setRTL
- clearBlocks
- cloneBlock
- deleteBlock
- getTemplateVariables
- getTemplateVariablesType
- modifyInputFields
- modifyMergeFields
- processTemplate
- removeTemplateVariable
- removeTemplateVariableImage
- replaceBlock
- replaceListVariable
- replacePlaceholderImage
- replaceTableVariable
- replaceVariableByExternalFile
- replaceVariableByHtml
- replaceVariableByText
- replaceVariableByWordFragment
- replaceVariableByWordML
- setTemplateSymbol
- setTemplateBlockSymbol
- tickCheckboxes
extractKeywords
PREMIUM
TRIAL / ADVANCED
Extract top keywords in a DOCX document.
Description
public extractKeywords ( $source [, array $options = array()] )
Extracts top keywords in a DOCX.
Supported AI integrations:
- GPT OpenAI
- phpdocx AI
Parameters GPT OpenAI
source
DOCX document.
options
An array with the available options.
The possible keys and values are:
key | Type | Description |
---|---|---|
frequency_penalty | float | Default as 0.8. |
max_tokens | int | Default as 1000. Each OpenAI model limits max tokens. |
model | string | Default as 'text-davinci-003'. |
presence_penalty | float | Default as 0.0. |
prompt | string | Default as 'Extract keywords from this text:'. |
referenceNode | array |
Default all paragraphs. DOCXPath options for custom queries:
|
returnFullResponse | bool | If true returns the whole GPT response. Default as false. |
target | array |
Extract specific targets:
|
temperature | float | Default as 0 (set 0.5 to generate related keywords). |
top_p | float | Default as 1.0. |
url | string | Default as 'https://api.openai.com/v1/completions'. |
Parameters phpdocx AI
source
DOCX document.
options
An array with the available options.
The possible keys and values are:
key | Type | Description |
---|---|---|
maxKeywords | int | Maximum number of keywords to return. Default as unlimited. |
minLength | int | Minimum length of keywords. Default as null. |
referenceNode | array |
Default all paragraphs. DOCXPath options for custom queries:
|
regExprCleanWords | string | Regular expression to clean contents to remove extra symbols. Default as '/[^\p{L}\p{N}\s]/u'. |
stopWords | array | Words to be ignored. Default as empty. https://github.com/stopwords-iso to get stop word lists for many languages. |
target | array |
Extract specific targets:
|
Return values
string or array with the keywords
Exceptions
Not valid DOCX source.
Error connecting to GPT.
GPT error.
Code samples
Release notes
- phpdocx 14.0:
- new method.