public IntentionBuilderFactory(CommandAggregatesRepo commandAggregatesRepo, MapperRepo mapperRepo, LexRepo gameLexesRepo)
        {
            _commandAggregatesRepo = commandAggregatesRepo;
            _mapperRepo            = mapperRepo;
            _gameLexesRepo         = gameLexesRepo;

            _intentionPoints = new Dictionary <BaseIntentions, int>();

            foreach (BaseIntentions enumValue in Enum.GetValues(typeof(BaseIntentions)))
            {
                _intentionPoints.Add(enumValue, 0);
            }
        }
示例#2
0
 public CheckAllWordsIsInGameLex(LexRepo lexRepo)
     : base("Property {PropertyName} contains a word not known to the game!")
 {
     _lexRepo = lexRepo;
 }
示例#3
0
 public LookIntention(CommandAggregatesRepo commandAggregatesRepo, MapperRepo mapperRepo, LexRepo gameLexesRepo)
 {
     _commandAggregatesRepo = commandAggregatesRepo;
     _mapperRepo            = mapperRepo;
     _gameLexesRepo         = gameLexesRepo;
 }
示例#4
0
        public void Initiate()
        {
            _coreNlpProcessor = _runtime.Container.Resolve <CoreNlpProcessor>();

            var jsonContentProvider = _runtime.Container.Resolve <IContentProvider>();

            _coreNlpProcessor.JarRootDir = @"C:\stanford-corenlp-full-2017-06-09\models";

            _pipeline = _coreNlpProcessor.LoadNlp(jsonContentProvider);

            _lexicalizedParser = _coreNlpProcessor.LoadLexicalizedParser(@"C:\stanford-corenlp-full-2017-06-09\models\edu\stanford\nlp\models\lexparser\englishPCFG.ser.gz");

            var currentAssemblyName = GetType().GetTypeInfo().Assembly.GetName().Name;

            var movementLex   = _runtime.Container.Resolve <MovementLex>();
            var adverbLex     = _runtime.Container.Resolve <AdverbLex>();
            var adjectivesLex = _runtime.Container.Resolve <AdjectivesLex>();
            var inventoryLex  = _runtime.Container.Resolve <InventoryLex>();
            var poiLex        = _runtime.Container.Resolve <PoiLex>();
            var miscObjectLex = _runtime.Container.Resolve <MiscObjectLex>();
            var takeLex       = _runtime.Container.Resolve <TakeLex>();
            var directionsLex = _runtime.Container.Resolve <DirectionsLex>();
            var locationsLex  = _runtime.Container.Resolve <LocationsLex>();
            var lookLex       = _runtime.Container.Resolve <LookLex>();
            var adverbModLex  = _runtime.Container.Resolve <AdverbModLex>();

            jsonContentProvider.Populate <MovementLex>(movementLex, currentAssemblyName);
            jsonContentProvider.Populate <AdverbLex>(adverbLex, currentAssemblyName);
            jsonContentProvider.Populate <AdjectivesLex>(adjectivesLex, currentAssemblyName);
            jsonContentProvider.Populate <InventoryLex>(inventoryLex, currentAssemblyName);
            jsonContentProvider.Populate <PoiLex>(poiLex, currentAssemblyName);
            jsonContentProvider.Populate <MiscObjectLex>(miscObjectLex, currentAssemblyName);
            jsonContentProvider.Populate <TakeLex>(takeLex, currentAssemblyName);
            jsonContentProvider.Populate <DirectionsLex>(directionsLex, currentAssemblyName);
            jsonContentProvider.Populate <LocationsLex>(locationsLex, currentAssemblyName);
            jsonContentProvider.Populate <LookLex>(lookLex, currentAssemblyName);
            jsonContentProvider.Populate <AdverbModLex>(adverbModLex, currentAssemblyName);


            _lexRepo = _runtime.Container.Resolve <LexRepo>(new NamedParameter("nestedRepos", new List <INestedRepo <dynamic> >
            {
                (INestedRepo <InventoryLex.Action>) new LexActionRepo <InventoryLex.Action>(inventoryLex, "Actions"),
                (INestedRepo <MovementLex.Action>) new LexActionRepo <MovementLex.Action>(movementLex, "Actions"),
                (INestedRepo <AdverbLex.Action>) new LexActionRepo <AdverbLex.Action>(adverbLex, "Actions"),
                (INestedRepo <AdjectivesLex.Action>) new LexActionRepo <AdjectivesLex.Action>(adjectivesLex, "Actions"),
                (INestedRepo <PoiLex.Action>) new LexActionRepo <PoiLex.Action>(poiLex, "Actions"),
                (INestedRepo <MiscObjectLex.Action>) new LexActionRepo <MiscObjectLex.Action>(miscObjectLex, "Actions"),
                (INestedRepo <TakeLex.Action>) new LexActionRepo <TakeLex.Action>(takeLex, "Actions"),
                (INestedRepo <DirectionsLex.Action>) new LexActionRepo <DirectionsLex.Action>(directionsLex, "Actions"),
                (INestedRepo <LocationsLex.Action>) new LexActionRepo <LocationsLex.Action>(locationsLex, "Actions"),
                (INestedRepo <LookLex.Action>) new LexActionRepo <LookLex.Action>(lookLex, "Actions"),
                (INestedRepo <AdverbModLex.Action>) new LexActionRepo <AdverbModLex.Action>(adverbModLex, "Actions"),
            }));

            _lexToIntentMapping = _runtime.Container.Resolve <LexToIntentionMapper>();

            _lexToIntentMapping.AddToMap(typeof(MovementLex), BaseIntentions.Move);
            _lexToIntentMapping.AddToMap(typeof(AdverbLex), BaseIntentions.Adverb);
            _lexToIntentMapping.AddToMap(typeof(AdverbModLex), BaseIntentions.AdverbMod);
            _lexToIntentMapping.AddToMap(typeof(AdjectivesLex), BaseIntentions.Adjective);
            _lexToIntentMapping.AddToMap(typeof(InventoryLex), BaseIntentions.Inventory);
            _lexToIntentMapping.AddToMap(typeof(PoiLex), BaseIntentions.ObjectOfInterest);
            _lexToIntentMapping.AddToMap(typeof(MiscObjectLex), BaseIntentions.MiscObject);
            _lexToIntentMapping.AddToMap(typeof(TakeLex), BaseIntentions.Take);
            _lexToIntentMapping.AddToMap(typeof(DirectionsLex), BaseIntentions.Direction);
            _lexToIntentMapping.AddToMap(typeof(LocationsLex), BaseIntentions.Location);
            _lexToIntentMapping.AddToMap(typeof(LookLex), BaseIntentions.Look);

            _nerToIntentMapping = _runtime.Container.Resolve <NerStringToIntentionMapper>();

            _nerToIntentMapping.AddToMap("PERSON", BaseIntentions.NerPerson);
            _nerToIntentMapping.AddToMap("LOCATION", BaseIntentions.NerLocation);
            _nerToIntentMapping.AddToMap("ORGANIZATION", BaseIntentions.NerOrganization);
            _nerToIntentMapping.AddToMap("MISC", BaseIntentions.NerMisc);
            _nerToIntentMapping.AddToMap("MONEY", BaseIntentions.NerMoney);
            _nerToIntentMapping.AddToMap("NUMBER", BaseIntentions.NerNumber);
            _nerToIntentMapping.AddToMap("ORDINAL", BaseIntentions.NerOrdinal);
            _nerToIntentMapping.AddToMap("PERCENT", BaseIntentions.NerPercent);
            _nerToIntentMapping.AddToMap("O", BaseIntentions.NerUnknown);

            _posToIntentMapping = _runtime.Container.Resolve <PosStringToIntentionMapper>();

            _posToIntentMapping.AddToMap("NN", BaseIntentions.UnknownNoun);
            _posToIntentMapping.AddToMap("NNS", BaseIntentions.UnknownNounPlural);
            _posToIntentMapping.AddToMap("VB", BaseIntentions.UnknownVerb);
            _posToIntentMapping.AddToMap("JJ", BaseIntentions.UnknownAdjective);
            _posToIntentMapping.AddToMap("RB", BaseIntentions.UnknownAdverb);

            _intentToIntentBuilderMapping = _runtime.Container.Resolve <IntentToIntentBuilderMapper>();

            _intentToIntentBuilderMapping.AddToMap(BaseIntentions.Move, typeof(MovementIntention));
            _intentToIntentBuilderMapping.AddToMap(BaseIntentions.Look, typeof(LookIntention));

            _mapperRepo = _runtime.Container.Resolve <MapperRepo>();

            _mapperRepo.Set(_intentToIntentBuilderMapping, _lexToIntentMapping, _nerToIntentMapping, _posToIntentMapping);
        }