EntityRecognizer class
用來剖析 & 解析從 LUIS 收到的日期時間等常見實體的公用程式類別。
方法
| expand |
將一組選項轉換成展開的陣列。 |
| find |
尋找集合內特定實體類型的所有專案。 |
| find |
根據選擇清單,尋找使用者語句的所有可能相符專案。 |
| find |
根據選擇清單,尋找用戶語句的最佳比對。 |
| find |
搜尋集合內特定實體類型的第一次發生。 |
| parse |
從使用者語句剖析布爾值。 |
| parse |
從使用者文字語句或一組實體剖析數位。 |
| parse |
從使用者文字語句或一組實體剖析日期。 |
| recognize |
辨識用戶語句的時間。 語句會使用 chrono 連結庫 |
| resolve |
從一組 datetime 實體計算 Date。 |
方法詳細資料
expandChoices(string | Object | string[])
將一組選項轉換成展開的陣列。
static function expandChoices(choices: string | Object | string[])
參數
- choices
-
string | Object | string[]
- 選項:{string} - 管道 ('|') 分隔的值清單。
- 選項:{Object} - 用來產生選項清單的物件。 物件域名將用來建置選擇清單。
- 選項:{string[]} - 字串陣列。 這隻會回顯為輸出。
傳回
string[]
findAllEntities(IEntity[], string)
尋找集合內特定實體類型的所有專案。
static function findAllEntities(entities: IEntity[], type: string)
參數
- entities
-
IEntity[]
要搜尋的實體集。
- type
-
string
要尋找的實體類型。
傳回
IEntity[]
findAllMatches(string | Object | string[], string, number)
根據選擇清單,尋找使用者語句的所有可能相符專案。
static function findAllMatches(choices: string | Object | string[], utterance: string, threshold?: number)
參數
- choices
-
string | Object | string[]
- 選項:{string} - 管道 ('|') 分隔的值清單,以與用戶語句進行比較。
- 選項:{Object} - 用來產生選項清單的物件。 物件域名將用來建置選擇清單。
- 選項:{string[]} - 要與用戶語句比較的字串陣列。
- utterance
-
string
要剖析的文字語句。
- threshold
-
number
(選擇性) 要考慮相符專案所需的最低分數。 預設值為 0.6。
傳回
findBestMatch(string | Object | string[], string, number)
根據選擇清單,尋找用戶語句的最佳比對。
static function findBestMatch(choices: string | Object | string[], utterance: string, threshold?: number)
參數
- choices
-
string | Object | string[]
- 選項:{string} - 管道 ('|') 分隔的值清單,以與用戶語句進行比較。
- 選項:{Object} - 用來產生選項清單的物件。 物件域名將用來建置選擇清單。
- 選項:{string[]} - 要與用戶語句比較的字串陣列。
- utterance
-
string
要剖析的文字語句。
- threshold
-
number
(選擇性) 要考慮相符專案所需的最低分數。 預設值為 0.6。
傳回
findEntity(IEntity[], string)
搜尋集合內特定實體類型的第一次發生。
static function findEntity(entities: IEntity[], type: string)
參數
- entities
-
IEntity[]
要搜尋的實體集。
- type
-
string
要尋找的實體類型。
傳回
parseBoolean(string)
從使用者語句剖析布爾值。
static function parseBoolean(value: string)
參數
- value
-
string
要剖析的文字語句。
傳回
boolean
有效的布林值,否則 未定義。
parseNumber(string | IEntity[])
從使用者文字語句或一組實體剖析數位。
static function parseNumber(value: string | IEntity[])
參數
- value
-
string | IEntity[]
- 值:{string} - 要剖析的文字語句。
- 值:{IEntity[]} - 要解析的實體集。
傳回
number
有效的數字,否則 Number.NaN。
parseTime(string | IEntity[])
從使用者文字語句或一組實體剖析日期。
static function parseTime(value: string | IEntity[])
參數
- value
-
string | IEntity[]
-
值:{string} - 要剖析的文字語句。 語句會使用 chrono 連結庫
剖析。 - 值:{IEntity[]} - 要解析的實體集。
傳回
Date
如果使用者輪輻時間,則為有效的 Date 對象,否則 null。
recognizeTime(string, Date)
辨識用戶語句的時間。 語句會使用 chrono 連結庫
static function recognizeTime(utterance: string, refDate?: Date)
參數
- utterance
-
string
要剖析的文字語句。
- refDate
-
Date
(選擇性) 用來計算最終日期的參考日期。
傳回
如果成功,則包含已解析日期的實體,如果無法判斷日期,null。
resolveTime(IEntity[])
從一組 datetime 實體計算 Date。
static function resolveTime(entities: IEntity[])
參數
- entities
-
IEntity[]
要從中擷取日期的實體清單。
傳回
Date
如果無法判斷日期,則成功計算的 Date 或 null。