Syn Bot /OSCOVA 系统实体(12)

System Entities

以下列举的都是内置的,对于中文应用,多数是没用的。

要注册你自己的实体类型识别器,使用如下代码:

Bot.Recognizers.RegisterType<Recognizer-Class>(Entity-Type);

系统预定义实体

常规

Entity NameDescriptionExamplesReturned Value
@sys.text Matches non-empty text Tell John @sys.text Returns matched part of user input I am on my way
@sys.url Matches a url www.oscova.com 
http://oscova.com
Returns a valid URL
NOTE

Overusing @sys.text may result in imprecise intent scores. It is highly recommended that wherever possible, developers must use custom, composite or other pre-built system entities.

设置

Entity NameDescriptionExamplesReturned Value
@sys.bot.{VARIABLE} Matches values of the specified Bot settings variable. Is your name @sys.bot.name Returns the value of the name variable in bot settings.
@sys.user.{VARIABLE} Matches values of the specified User settings variable of the current user My support PIN is @sys.user.pin Returns the value of the PIN variable in user settings.
NOTE

Both User and Bot Settings entity recognizer only recognize variables whose names are explicitly mentioned in Expressions.

时间和日期

Entity NameDescriptionExamplesReturned Value
@sys.date Matches a date. Configurable March 12th 
Tomorrow
Returns date in ISO-8601 format, such as 2016-12-15
@sys.date.month Names of months January, June Returns month and date string in ISO-8601
@sys.date.time Matches a date and time December 1 at 5 pm 
Tomorrow at 2 pm
Returns Date and time in ISO-8601 format, such as 2016-12-10T13:42:25
@sys.time Matches a time. 8:30 
12 pm 
in 10 minutes
Returns time in ISO-8601 format (hh:mm:ss): 14:20:00

Entity NameDescriptionExamplesReturned Value
@sys.number Matches integer and decimal numbers 10.5 
14 
seventy 
first
Returns double, such as 10.5
@sys.ordinal Matches ordinal numbers second 
1st 
12-th
Returns integer, such as 12
@sys.number.integer Matches integer numbers 10 
-10
Returns integer, such as 10
@sys.number.sequence Matches integer number sequences 10 15 20 
1 5 8 6
Returns string, such as 10 15 12
@sys.math.expression Matches simple math expressions 2+5*5 Returns string such as 2+5*5 and also an evaluated value

值和单位

Entity NameDescriptionExamplesReturned Value
@sys.unit.area Number and Area unit 36 sq m 
19 acres
Value as double and unit abbreviation as {"amount":10, "unit":"sq m"}
@sys.unit.information Number and Digital Information unit 56 kilobytes 
5 MB
Value as double and unit abbreviation as {"amount":10, "unit":"MB"}
@sys.unit.length Number and Length unit 15 kilometers 
8 miles
Value as double and unit abbreviation as {"amount":10, "unit":"km"}
@sys.unit.speed Number and Speed unit 17 miles per hour 
10 km/h
Value as double and unit abbreviation as {"amount":10, "unit":"mph"}
@sys.unit.volume Number and Volume unit 5 liters 
10 gallons
Value as double and unit abbreviation as {"amount":10, "unit":"cm3"}
@sys.unit.weight Number and Weight unit 14 kg 
10 pounds
Value as double and unit abbreviation as {"amount":10, "unit":"lb"}
@sys.currency Number and currency unit 15 US Dollars 
25 INR
Value as double and currency unit abbreviation as {"amount":24, "unit":"USD"}
@sys.temperature Number and Temperature unit 37.6°F 
15 degrees celsius
Value as double and unit abbreviation as {"amount":10, "unit":"F"}
@sys.duration Number and Time unit 12 minutes 
4 hrs
Value as double and unit abbreviation as {"amount":10, "unit":"hour"}
@sys.age Number and Age unit 12 months old 
2 years old
Value as double and unit abbreviation as {"amount":5, "unit":"year"}
@sys.percentage Number and Percentage unit 56% 
12 percent
Value as double and unit as {"amount":5, "unit":"percent"}

单位名称

Entity NameDescriptionExamplesReturned Value
@sys.unit.area.name Units of area Square Meters 
Hectares
Returns string, such as sq km
@sys.unit.information.name Units of Digital Information Kilobytes 
GB
Returns string such as MB
@sys.currency.name Currencies. Configurable US dollar 
INR
Returns string, such as USD
@sys.unit.length.name Units of length Meter 
Kilometers
Returns string, such as km
@sys.unit.speed.name Units of speed Miles per hour 
Kilometer per hour
Returns string, such as mph
@sys.unit.temperature.name Units of temperature degree celsius 
Kelvin
Returns string, such as K
@sys.unit.volume.name Units of volume Milliliter 
Gallon
Returns string, such as ml
@sys.unit.weight.name Units of weight Kilogram 
Pounds
Returns string, such as kg

地理位置

Entity NameDescriptionExamplesReturned Value
@sys.geo.country Names of countries United States 
Australia
Returns short country name string as per ISO 3166-1, such as United States of America
@sys.geo.state.us US States Arizona 
Minnesota
Returns short state name string as per ISO-3166-2, such as Ohio
@sys.geo.state.ind Indian states and union territories Goa 
New Delhi
Returns string, such as Goa
@sys.geo.ip Matches IP Addresses 192.168.2.1 Returns string, such as 192.168.2.1
@sys.geo.postal.us 5 digit US postal codes 11368 
90005
Returns string, such as 90005 Note: Does not validate the code
@sys.geo.postal.uk Alphanumeric UK Postal codes W1A 1HQ 
M60 1NW
Returns string, such as M60 1NW Note: Does not validate the code.
@sys.geo.postal.ind 6 digit Indian Postal codes 560037 
691001
Returns string, such as 560037 Note: Does not validate the code.

语言

Entity NameDescriptionExamplesReturned Value
@sys.language Names of Languages English 
Hindi
Returns string, such as English

联系人信息

Entity NameDescriptionExamplesReturned Value
@sys.email Email address example@example.com Returns string, such as example@example.com Note: Overrides @sys.url value example.com
@sys.phone.us Matches US phone numbers +1 (123) 456-7890 
(123) 456-7890
Returns string, such as (123) 456-7890
@sys.phone.ind Matches Indian phone numbers (+91) 8987654321 
011-20000198
Returns string, such as 8987654321

颜色

Entity NameDescriptionExamplesReturned Value
@sys.color Names of colors Red 
Dark Gray
Returns string, such as Dark Gray

音乐

Entity NameDescriptionExamplesReturned Value
@sys.music.genre Names of popular music genres Jazz 
Blues
Returns string, such as Jazz

Polar Question

Because users can respond in any manner to polar questions some user responses may lead to some false-positives. Hence, developers are encouraged to build custom recognizers for positive and negative sentences. However, by using the following entity types the developer is solely responsible for any action executed by the Bot.

Entity NameDescriptionExamplesReturned Value
@sys.positive A positive response Yes 
Okay
Returns string, such as yes
@sys.negative A negative response No 
Nope
Returns string, such as no

手动设置

Currency

As the word dollar may be used to refer to United States Dollar in US and Australian Dollar in Australia. The developer must manually extend the @sys.currency.name entries by adding synonyms for currency codes based on the location of the user the bot is interacting with.

Bot.Recognizers[EntityTypes.CurrencyName].Entries.AddSynonyms("USD", new [] {"dollar", "us dollar","dollars"})

OrderStyle

@sys.date recognizer has an OrderStyle property that enables regional date time parsing. The default value of MonthDayYear can be changed based on the location where the bot is deployed to accept different date formats like mm/dd/yy, mm/dd/yyyy, mm-dd-yy

You may change the order style prior to training the bot as shown below.

var bot = new OscovaBot();
var dateRecogizer = (Bot.Recognizers["sys.date"] as DateRecognizer);
dateRecogizer.OrderStyle = OrderStyle.DayMonthYear;
原文地址:https://www.cnblogs.com/mrtiny/p/9082698.html