コード例 #1
0
        // Token: 0x06001132 RID: 4402 RVA: 0x000642D8 File Offset: 0x000624D8
        private ADEntry LoadADEntry(XmlReader entryReader, NameNormalizer nameNormalizer, GrammarGenerationLog generationLog)
        {
            base.Logger.TraceDebug(this, "Entering GrammarGenerator.LoadADEntry", new object[0]);
            ADEntry       result        = null;
            string        text          = entryReader.GetAttribute(GrammarRecipientHelper.LookupProperties[2].Name);
            string        attribute     = entryReader.GetAttribute(GrammarRecipientHelper.LookupProperties[0].Name);
            string        attribute2    = entryReader.GetAttribute(GrammarRecipientHelper.LookupProperties[1].Name);
            Guid          guid          = new Guid(entryReader.GetAttribute(GrammarRecipientHelper.LookupProperties[3].Name));
            RecipientType recipientType = (RecipientType)Enum.Parse(typeof(RecipientType), entryReader.GetAttribute(GrammarRecipientHelper.LookupProperties[4].Name));
            string        attribute3    = entryReader.GetAttribute(GrammarRecipientHelper.LookupProperties[6].Name);
            string        attribute4    = entryReader.GetAttribute(GrammarRecipientHelper.LookupProperties[9].Name);

            base.Logger.TraceDebug(this, "GrammarGenerator.LoadADEntry - displayName='{0}', phoneticDisplayName='{1}', smtpAddress='{2}', objectGuid='{3}', recipientType='{4}', dialPlanGuid='{5}', AddressListMembership='{6}'", new object[]
            {
                attribute,
                attribute2,
                text,
                guid,
                recipientType,
                attribute3,
                attribute4
            });
            if (RecipientType.DynamicDistributionGroup != recipientType)
            {
                List <string> list = new List <string>(2);
                if (!string.IsNullOrEmpty(attribute))
                {
                    list.Add(attribute);
                }
                if (!string.IsNullOrEmpty(attribute2))
                {
                    list.Add(attribute2);
                }
                list = NormalizationHelper.GetNormalizedNames(list, nameNormalizer, recipientType, generationLog);
                if (list != null)
                {
                    base.Logger.TraceDebug(this, "GrammarGenerator.LoadADEntry - Valid names found for entry", new object[0]);
                    text = GrammarRecipientHelper.GetNormalizedEmailAddress(text);
                    Guid        dialPlanGuid = string.IsNullOrEmpty(attribute3) ? Guid.Empty : new Guid(attribute3);
                    List <Guid> list2        = new List <Guid>();
                    if (!string.IsNullOrEmpty(attribute4))
                    {
                        char[] separator = new char[]
                        {
                            ','
                        };
                        string[] array = attribute4.Split(separator);
                        foreach (string g in array)
                        {
                            list2.Add(new Guid(g));
                        }
                    }
                    result = new ADEntry(list, text, guid, recipientType, dialPlanGuid, list2);
                }
            }
            return(result);
        }
コード例 #2
0
 // Token: 0x06001139 RID: 4409 RVA: 0x00064A4C File Offset: 0x00062C4C
 private void UploadResults(List <string> grammarFilePaths, NameNormalizer nameNormalizer, CultureInfo culture)
 {
     this.grammars.Add(culture.Name, grammarFilePaths);
     nameNormalizer.UpdateDiskCache();
     this.normalizationCaches.Add(culture.Name, nameNormalizer.NormalizationCache);
     if (!this.DoBulkUpload)
     {
         base.Logger.TraceDebug(this, "GrammarGenerator.UploadResults, upload results for culture='{0}'", new object[]
         {
             culture
         });
         this.UploadResults(culture);
     }
 }
コード例 #3
0
        // Token: 0x06001159 RID: 4441 RVA: 0x00065A68 File Offset: 0x00063C68
        public static List <string> GetNormalizedNames(List <string> inputNames, NameNormalizer nameNormalizer, RecipientType recipientType, GrammarGenerationLog generationLog)
        {
            UMTracer.DebugTrace("NormalizationHelper.GetNormalizedNames", new object[0]);
            List <string> list = new List <string>();
            int           i    = 0;

            while (i < inputNames.Count)
            {
                string text = inputNames[i];
                UMTracer.DebugTrace("NormalizationHelper.GetNormalizedName inputName='{0}', recipientType={1}", new object[]
                {
                    text,
                    recipientType
                });
                string input = GrammarRecipientHelper.CharacterMapReplaceString(text);
                Dictionary <string, bool> dictionary = GrammarRecipientHelper.ApplyExclusionList(input, recipientType);
                if (dictionary.Count != 0)
                {
                    using (Dictionary <string, bool> .KeyCollection.Enumerator enumerator = dictionary.Keys.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            string text2 = enumerator.Current;
                            if (!string.IsNullOrEmpty(text2) && NormalizationHelper.IsGrammarEntryFormatValid(text2))
                            {
                                bool   flag  = false;
                                string text3 = SpeechUtils.SrgsEncode(text2);
                                if (dictionary[text2])
                                {
                                    if (nameNormalizer.IsNameAcceptable(text3))
                                    {
                                        flag = true;
                                    }
                                    else
                                    {
                                        generationLog.WriteLine(Strings.NormalizationFailedError(text));
                                    }
                                }
                                else
                                {
                                    flag = true;
                                }
                                if (flag && !string.IsNullOrEmpty(text3))
                                {
                                    UMTracer.DebugTrace("Adding name '{0}'", new object[]
                                    {
                                        text3
                                    });
                                    list.Add(text3);
                                }
                            }
                        }
                        goto IL_12D;
                    }
                    goto IL_11C;
                }
                goto IL_11C;
IL_12D:
                i++;
                continue;
IL_11C:
                generationLog.WriteLine(Strings.EntryExcludedFromGrammar(text));
                goto IL_12D;
            }
            if (list.Count != 0)
            {
                return(list);
            }
            return(null);
        }
コード例 #4
0
        // Token: 0x06001130 RID: 4400 RVA: 0x00063F64 File Offset: 0x00062164
        private List <string> GenerateGrammar(CultureInfo c, IGrammarGeneratorInterface generatorInstance)
        {
            base.Logger.TraceDebug(this, "Entering GrammarGenerator.GenerateGrammar culture='{0}'", new object[]
            {
                c
            });
            string        runFolderPath     = base.RunData.RunFolderPath;
            string        adentriesFileName = generatorInstance.ADEntriesFileName;
            List <string> list = null;

            try
            {
                string entriesFilePath = ADCrawler.GetEntriesFilePath(runFolderPath, adentriesFileName);
                List <DirectoryGrammar> grammarList = generatorInstance.GetGrammarList();
                list = new List <string>(grammarList.Count);
                UmGlobals.ExEvent.LogEvent(UMEventLogConstants.Tuple_GrammarGenerationWritingGrammarEntriesStarted, null, new object[]
                {
                    adentriesFileName,
                    c.Name,
                    base.TenantId,
                    base.RunId
                });
                string grammarFileFolderPath = GrammarFileDistributionShare.GetGrammarFileFolderPath(base.OrgId, base.MailboxGuid, base.RunId, c);
                Directory.CreateDirectory(grammarFileFolderPath);
                string recognizerId = SpeechRecognizerInfo.GetRecognizerId(c);
                if (recognizerId != null)
                {
                    string grammarFolderPath = GrammarFileDistributionShare.GetGrammarFolderPath(base.OrgId, base.MailboxGuid);
                    INormalizationCacheFileStore cacheFileStore = NormalizationCacheMailboxFileStore.FromMailboxGuid(base.OrgId, base.MailboxGuid);
                    using (SpeechRecognitionEngine speechRecognitionEngine = new SpeechRecognitionEngine(recognizerId))
                    {
                        using (XmlReader xmlReader = XmlReader.Create(entriesFilePath))
                        {
                            using (GrammarGenerationLog grammarGenerationLog = new GrammarGenerationLog(grammarFileFolderPath, base.Logger))
                            {
                                NameNormalizer nameNormalizer = new NameNormalizer(c, speechRecognitionEngine, adentriesFileName, grammarFolderPath, base.Logger, cacheFileStore);
                                this.InitializeGrammars(grammarFileFolderPath, c, grammarList);
                                if (xmlReader.ReadToFollowing("ADEntry"))
                                {
                                    for (;;)
                                    {
                                        ADEntry adentry = this.LoadADEntry(xmlReader, nameNormalizer, grammarGenerationLog);
                                        if (adentry != null && !this.WriteADEntryToGrammars(adentry, grammarList))
                                        {
                                            break;
                                        }
                                        base.RunData.ThrowIfShuttingDown();
                                        if (!xmlReader.ReadToFollowing("ADEntry"))
                                        {
                                            goto IL_18A;
                                        }
                                    }
                                    base.Logger.TraceError(this, "GrammarGenerator.Run - Cannot accept more entries in any of the grammar files", new object[0]);
                                }
IL_18A:
                                list.AddRange(this.CompleteGrammars(grammarList));
                                this.UploadResults(list, nameNormalizer, c);
                            }
                        }
                        goto IL_204;
                    }
                }
                UmGlobals.ExEvent.LogEvent(UMEventLogConstants.Tuple_GrammarGenerationMissingCulture, null, new object[]
                {
                    base.TenantId,
                    c.Name,
                    Utils.GetLocalHostFqdn()
                });
IL_204:
                UmGlobals.ExEvent.LogEvent(UMEventLogConstants.Tuple_GrammarGenerationWritingGrammarEntriesCompleted, null, new object[]
                {
                    adentriesFileName,
                    c.Name,
                    base.TenantId,
                    base.RunId
                });
            }
            catch (Exception ex)
            {
                base.Logger.TraceError(this, "GrammarGenerator.Run - Exception='{0}'", new object[]
                {
                    ex
                });
                this.exception = ex;
                throw;
            }
            return(list);
        }
コード例 #5
0
        // Token: 0x0600114B RID: 4427 RVA: 0x00064F44 File Offset: 0x00063144
        public bool IsNameAcceptable(string encodedDisplayName)
        {
            ValidateArgument.NotNullOrEmpty(encodedDisplayName, "encodedDisplayName");
            this.logger.TraceDebug(this, "Entering NameNormalizer.IsNameAcceptable encodedDisplayName='{0}'", new object[]
            {
                encodedDisplayName
            });
            bool result = true;

            try
            {
                foreach (string text in encodedDisplayName.Split(new char[]
                {
                    ' '
                }))
                {
                    if (Utils.TrimSpaces(text) != null)
                    {
                        bool flag = true;
                        if (this.normalizationCache.TryGetValue(text, out flag))
                        {
                            this.logger.TraceDebug(this, "Found word='{0}' in cache, acceptWord='{1}'", new object[]
                            {
                                text,
                                flag
                            });
                        }
                        else
                        {
                            flag = this.IsWordAcceptable(text);
                            this.logger.TraceDebug(this, "Adding word='{0}' to normalization cache, acceptWord='{1}'", new object[]
                            {
                                text,
                                flag
                            });
                            this.normalizationCache[text] = flag;
                        }
                        if (!flag)
                        {
                            this.logger.TraceDebug(this, "Skipping name because word='{0}' didn't pass normalization check", new object[]
                            {
                                text
                            });
                            result = false;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result = false;
                this.logger.TraceError(this, "NameNormalizer.IsNameAcceptable input='{0}' exception='{1}'", new object[]
                {
                    encodedDisplayName,
                    ex
                });
                if (!NameNormalizer.IsExpectedException(ex) && !GrayException.IsGrayException(ex))
                {
                    throw;
                }
            }
            return(result);
        }