Exemple #1
0
        private static void ImportNLU(string rootPath)
        {
            NLUDataImporter importer = new NLUDataImporter(rootPath);

            writer.CreateNLUCollections(importer.ParseIntentRules(), importer.ParseEntityData(), importer.ParseEntityAttributeData());
            Console.WriteLine("Imported NLU materials to MongoDB!");
        }
Exemple #2
0
        public (List <NLUIntentRule>, List <EntityData>, List <EntityAttributeData>) LoadNLU(string dsName)
        {
            if (string.IsNullOrWhiteSpace(dsName))
            {
                log.Here().Warning("The datastore: " + dsName + " doesn't exist.");
                return(null, null, null);
            }

            string nluPath = this.rootPath + Path.DirectorySeparatorChar + dsName + Path.DirectorySeparatorChar + "NLU" + Path.DirectorySeparatorChar;

            if (string.IsNullOrWhiteSpace(nluPath) || !Directory.Exists(nluPath))
            {
                log.Here().Warning("The path of NLUFilePath: " + nluPath + " doesn't exist.");
                return(null, null, null);
            }

            log.Here().Information("NLUFilePath: " + nluPath);

            NLUDataImporter importer = new NLUDataImporter(nluPath);

            List <NLUIntentRule>       iList  = importer.ParseIntentRules();
            List <EntityData>          eList  = importer.ParseEntityData();
            List <EntityAttributeData> eaList = importer.ParseEntityAttributeData();

            return(iList, eList, eaList);
        }
Exemple #3
0
        private void ImportNLU(string nluPath, string dbName)
        {
            NLUDataImporter importer = new NLUDataImporter(nluPath);

            writer.CreateNLUCollections(dbName, importer.ParseIntentRules(), importer.ParseEntityData(), importer.ParseEntityAttributeData(), false);
            Console.WriteLine("Imported NLU materials to MongoDB!");
        }
Exemple #4
0
        private NLUDataAccessor(IConfiguration config)
        {
            log = Log.Logger.ForContext <NLUDataAccessor>();

            string persistanceType = config.GetSection("PersistanceType").Value;

            if (persistanceType == "File")
            {
                FilePathConfig filePaths = config.GetSection("FileDataPath").Get <FilePathConfig>();
                string         nluPath   = filePaths.NLUFilePath;

                log.Here().Information("NLUFilePath: " + nluPath);

                NLUDataImporter importer = new NLUDataImporter(nluPath);

                this.iList  = importer.ParseIntentRules();
                this.eList  = importer.ParseEntityData();
                this.eaList = importer.ParseEntityAttributeData();
            }
            else if (persistanceType == "MongoDB")
            {
                BsonDocument allFilter = new BsonDocument();

                string connectionString = config.GetConnectionString("MongoDbConnection");
                string dbName           = config.GetConnectionString("DatabaseName");

                Console.WriteLine("Database Name: " + dbName);

                MongoClient client = new MongoClient(connectionString);

                IMongoDatabase db = client.GetDatabase(dbName);

                log.Here().Information("connectionString: " + connectionString + ", databaseName: " + dbName);

                IMongoCollection <NLUIntentRule> iCollection = db.GetCollection <NLUIntentRule>("IntentRules");
                this.iList = iCollection.Find(allFilter).ToList();

                IMongoCollection <EntityData> eCollection = db.GetCollection <EntityData>("Entities");
                this.eList = eCollection.Find(allFilter).ToList();

                IMongoCollection <EntityAttributeData> eaCollection = db.GetCollection <EntityAttributeData>("EntityAttributes");
                this.eaList = eaCollection.Find(allFilter).ToList();

                log.Here().Information("NLU Data has been parsed from MongoDB.");
            }
        }