SrgsRule.Scope Właściwość

Definicja

Pobiera lub ustawia, czy reguła może być aktywowana do rozpoznawania i kiedy reguła może być przywołyowana przez inne reguły.

public:
 property System::Speech::Recognition::SrgsGrammar::SrgsRuleScope Scope { System::Speech::Recognition::SrgsGrammar::SrgsRuleScope get(); void set(System::Speech::Recognition::SrgsGrammar::SrgsRuleScope value); };
public System.Speech.Recognition.SrgsGrammar.SrgsRuleScope Scope { get; set; }
member this.Scope : System.Speech.Recognition.SrgsGrammar.SrgsRuleScope with get, set
Public Property Scope As SrgsRuleScope

Wartość właściwości

Wartość ustawia zakres reguły.

Przykłady

Poniższy przykład tworzy gramatykę, która rozpoznaje frazę "Naród, który wygrał Puchar Świata" następuje nazwa kraju, który wygrał Puchar Świata. Tworzy regułę publiczną o nazwie WorldCupWinner i ustawia zakres tej reguły na Publiczny.

// Create an SrgsDocument, create a new rule and set its scope to public.
SrgsDocument document = new SrgsDocument();
SrgsRule winnerRule = new SrgsRule("WorldCupWinner");
winnerRule.Scope = SrgsRuleScope.Public;

// Add the introduction.
winnerRule.Elements.Add(new SrgsItem("A nation that has won the world cup is: "));

// Create the rule for the European nations.
SrgsOneOf oneOfEurope = new SrgsOneOf(new SrgsItem[] {new SrgsItem("England"), new SrgsItem("France"), new SrgsItem("Germany"), new SrgsItem("Italy")});
SrgsRule ruleEurope = (new SrgsRule("EuropeanNations", new SrgsElement[] {oneOfEurope}));

// Create the rule for the South American nations.
SrgsOneOf oneOfSAmerica = new SrgsOneOf(new SrgsItem[] {new SrgsItem("Argentina"), new SrgsItem("Brazil"), new SrgsItem("Uruguay")});
SrgsRule ruleSAmerica = (new SrgsRule("SouthAmericanNations", new SrgsElement[] {oneOfSAmerica}));

// Add references to winnerRule for ruleEurope and ruleSAmerica.
winnerRule.Elements.Add(new SrgsOneOf(new SrgsItem[] {(new SrgsItem (new SrgsRuleRef(ruleEurope)), new SrgsItem(new SrgsRuleRef(ruleSAmerica)})));

// Add all the rules to the document and make winnerRule
// the root rule of the document.
document.Rules.Add(new SrgsRule[] {winnerRule, ruleEurope, ruleSAmerica});
document.Root = winnerRule;

Utworzona gramatyka ma następujący formularz.

<grammar version="1.0" xml:lang="en-US" xmlns="http://www.w3.org/2001/06/grammar" root="WorldCupWinner">
    <rule id="WorldCupWinner" scope="public">
        <item> A nation that has won the world cup is </item>
        <one-of>
            <item>
                <ruleref uri="#EuropeanNations" />
            </item>
            <item>
                <ruleref uri="#SouthAmericanNations" />
            </item>
        </one-of>
    </rule>
    <rule id="EuropeanNations">
        <one-of>
            <item> England< /item>
            <item> France </item>
            <item> Germany </item>
            <item> Italy </item>
        </one-of>
    </rule>
    <rule id="SouthAmericanNations">
        <one-of>
            <item> Argentina </item>
            <item> Brazil </item>
            <item> Uruguay </item>
        </one-of>
    </rule>
</grammar>

Uwagi

Wartość domyślna zakresu to Private. Regułę prywatną można aktywować do rozpoznawania tylko przez odwołanie reguły z reguły głównej w jej gramatyce lub z innej reguły, do którego odwołuje się reguła główna. Reguły prywatnej nie można odwoływać się do zewnętrznej gramatyki, chyba że reguła prywatna jest zadeklarowana jako główna reguła jej zawierającej gramatykę.

Jeśli jego zakres jest ustawiony na Publicwartość , SrgsRule obiekt można aktywować do rozpoznawania przez odwołanie z SrgsRuleRef obiektu w zawierającej gramatykę lub z reguły w zewnętrznej gramatyki.

Dotyczy

Zobacz też