Exemple #1
0
        public void ParseScenarioSettings(NLUDataFrame nluDF, List <ScenarioSetting> kgSettings, List <Vertex> rootVertexes)
        {
            Dictionary <string, ScenarioSetting> scenarioCache = new Dictionary <string, ScenarioSetting>();

            if (kgSettings != null && kgSettings.Count > 0)
            {
                foreach (ScenarioSetting setting in kgSettings)
                {
                    scenarioCache.Add(setting.scenarioName, setting);
                }
            }

            foreach (Vertex vertex in rootVertexes)
            {
                if (vertex.nodeType == "ROOT" && vertex.scenarios != null)
                {
                    foreach (string scenarioName in vertex.scenarios)
                    {
                        if (scenarioCache.ContainsKey(scenarioName))
                        {
                            scenarioCache[scenarioName].root = vertex;
                        }
                        else
                        {
                            ScenarioSetting defaultSetting = new ScenarioSetting(scenarioName, vertex);
                            scenarioCache.Add(scenarioName, defaultSetting);
                        }
                    }
                }
            }

            nluDF.SetSceanrioCache(scenarioCache);
        }
Exemple #2
0
        public NLUProcessor(string datastoreName)
        {
            DataStoreFrame dsFrame = DataStoreManager.GetInstance().GetDataStore(datastoreName);

            if (dsFrame != null)
            {
                this.nluDF = DataStoreManager.GetInstance().GetDataStore(datastoreName).GetNLU();
            }
        }
Exemple #3
0
        public NLUDataFrame Parse(List <NLUIntentRule> iList, List <EntityData> eList, List <EntityAttributeData> eaList)
        {
            NLUDataFrame nluDF = new NLUDataFrame();

            if (iList == null || iList.Count == 0)
            {
                //throw new Exception("No Intent is defined.");
                log.Warning("No Intent is defined.");
            }
            else
            {
                foreach (NLUIntentRule intentRule in iList)
                {
                    nluDF.AddIntentRule(intentRule);
                }
            }

            if (eList == null || eList.Count == 0)
            {
                //throw new Exception("No Entity is defined.");
                log.Warning("No Entity is defined.");
            }
            else
            {
                foreach (EntityData entity in eList)
                {
                    NLUEntity nluEntity = nluDF.AddEntity(entity.intentName, entity.entityValue, entity.entityType);
                    nluDF.AddSimilarWord(entity.intentName, entity.similarWord, nluEntity);
                }
            }

            if (eaList == null || eaList.Count == 0)
            {
                Log.Information("There is not any entity attribute defined.");
            }
            else
            {
                foreach (EntityAttributeData ea in eaList)
                {
                    nluDF.AddAttribute(ea.intentName, new NLUEntity(ea.entityValue, ea.entityType), new AttributePair(ea.attributeName, ea.attributeValue));
                }
            }

            return(nluDF);
        }
Exemple #4
0
        public DataStoreFrame LoadDataStore(string dsName)
        {
            List <Vertex>             vList  = null;
            List <Edge>               eList  = null;
            List <VisulizationConfig> vcList = null;

            List <NLUIntentRule>       iList  = null;
            List <EntityData>          enList = null;
            List <EntityAttributeData> eaList = null;

            (vList, eList, vcList, iList, enList, eaList) = this.dataAccessor.Load(dsName);

            if (vcList == null || vList == null || eList == null)
            {
                log.Here().Warning("No KG Data loaded from persistence");
                return(null);
            }

            DataPersistanceKGParser kgParser      = new DataPersistanceKGParser();
            KnowledgeGraphDataFrame kgDF          = kgParser.ParseKG(vList, eList);
            KGConfigFrame           kgConfigFrame = kgParser.ParseKGConfig(vcList);

            log.Information("Knowledge Graph is parsed.");
            Console.WriteLine("Knowledge Graph is parsed.");

            NLUDataFrame nluDF = null;

            if (iList == null || enList == null)
            {
                log.Here().Warning("No NLU Data loaded from persistence");
            }
            else
            {
                DataPersistanceNLUParser nluParser = new DataPersistanceNLUParser();
                nluDF = nluParser.Parse(iList, enList, eaList);

                log.Information("NLU materials is parsed.");
                Console.WriteLine("NLU materials is parsed.");
            }

            DataStoreFrame dsFrame = new DataStoreFrame(dsName, kgDF, kgConfigFrame, nluDF);

            return(dsFrame);
        }