/// <summary>Generate the training features from the CoNLL input file.</summary>
        /// <returns>Dataset of feature vectors</returns>
        /// <exception cref="System.Exception"/>
        private static GeneralDataset <string, string> GenerateFeatureVectors(Properties props)
        {
            GeneralDataset <string, string> dataset = new Dataset <string, string>();
            Dictionaries  dict     = new Dictionaries(props);
            DocumentMaker docMaker = new DocumentMaker(props, dict);
            Document      document;

            while ((document = docMaker.NextDoc()) != null)
            {
                SetTokenIndices(document);
                IDictionary <int, CorefCluster> entities = document.goldCorefClusters;
                // Generate features for coreferent mentions with class label 1
                foreach (CorefCluster entity in entities.Values)
                {
                    foreach (Mention mention in entity.GetCorefMentions())
                    {
                        // Ignore verbal mentions
                        if (mention.headWord.Tag().StartsWith("V"))
                        {
                            continue;
                        }
                        IndexedWord head = mention.enhancedDependency.GetNodeByIndexSafe(mention.headWord.Index());
                        if (head == null)
                        {
                            continue;
                        }
                        List <string> feats = mention.GetSingletonFeatures(dict);
                        dataset.Add(new BasicDatum <string, string>(feats, "1"));
                    }
                }
                // Generate features for singletons with class label 0
                List <CoreLabel> gold_heads = new List <CoreLabel>();
                foreach (Mention gold_men in document.goldMentionsByID.Values)
                {
                    gold_heads.Add(gold_men.headWord);
                }
                foreach (Mention predicted_men in document.predictedMentionsByID.Values)
                {
                    SemanticGraph dep  = predicted_men.enhancedDependency;
                    IndexedWord   head = dep.GetNodeByIndexSafe(predicted_men.headWord.Index());
                    if (head == null || !dep.VertexSet().Contains(head))
                    {
                        continue;
                    }
                    // Ignore verbal mentions
                    if (predicted_men.headWord.Tag().StartsWith("V"))
                    {
                        continue;
                    }
                    // If the mention is in the gold set, it is not a singleton and thus ignore
                    if (gold_heads.Contains(predicted_men.headWord))
                    {
                        continue;
                    }
                    dataset.Add(new BasicDatum <string, string>(predicted_men.GetSingletonFeatures(dict), "0"));
                }
            }
            dataset.SummaryStatistics();
            return(dataset);
        }
Exemple #2
0
        public void Remove_UnknownName()
        {
            Dataset dataset = new Dataset();

            dataset.Add(fooExtension);
            dataset.Add(barExtension);

            Assert.IsNull(dataset.Remove("Unknown Plug-In"));
        }
Exemple #3
0
        public void IDataset_Indexer()
        {
            Dataset dataset = new Dataset();

            dataset.Add(fooExtension);
            dataset.Add(barExtension);

            Landis.PlugIns.IDataset coreDataset = dataset;
            AssertAreEqual(fooExtension.CoreInfo, coreDataset[fooExtension.Name]);
            AssertAreEqual(barExtension.CoreInfo, coreDataset[barExtension.Name]);
        }
Exemple #4
0
        public void AddNameTwice()
        {
            Dataset dataset = new Dataset();

            Assert.AreEqual(0, dataset.Count);

            dataset.Add(fooExtension);
            Assert.AreEqual(1, dataset.Count);
            Assert.AreEqual(fooExtension, dataset[0]);
            Assert.AreEqual(fooExtension, dataset[fooExtension.Name]);

            dataset.Add(fooExtension);
        }
        private async Task ExecuteLoadDataCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Dataset.Clear();
                var dataset = await DataStore.GetAllAsync_Score(true);

                //Order the scores by descending order
                dataset = dataset
                          .OrderByDescending(a => a.ScoreTotal)
                          .ToList();
                foreach (var data in dataset)
                {
                    Dataset.Add(data);
                }
            }

            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            finally
            {
                IsBusy = false;
            }
        }
        public async Task <bool> AddAsync(Character data)
        {
            Dataset.Add(data);
            var myReturn = await DataStore.AddAsync_Character(data);

            return(myReturn);
        }
Exemple #7
0
        async Task ExecuteLoadDataCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Dataset.Clear();
                var dataset = await DataStore.GetAllAsync_Creature(true);

                foreach (var data in dataset)
                {
                    if (data.Type == 0)// just Characters
                    {
                        Dataset.Add(data);
                    }
                }
            }

            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            finally
            {
                IsBusy = false;
            }
        }
        public async Task <bool> AddAsync(Score data)
        {
            Dataset.Add(data);
            var myReturn = await DataStore.AddAsync_Score(data);

            return(myReturn);
        }
        public async Task <bool> AddAsync(Item data)
        {
            Dataset.Add(data);
            var myReturn = await DataStore.AddAsync_Item(data);

            return(myReturn);
        }
Exemple #10
0
        /// <summary>
        /// Command to load the data
        /// </summary>
        /// <returns></returns>
        // [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>")]
        private async Task ExecuteLoadDataCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Dataset.Clear();
                var dataset = await DataStore.IndexAsync();

                dataset = SortDataSet(dataset);

                foreach (var data in dataset)
                {
                    Dataset.Add(data);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #11
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Dataset.Clear();
                var items = await DataStore.GetAllAsync_Item(true);

                foreach (var item in items)
                {
                    Dataset.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
                SetNeedsRefresh(false);
            }
        }
        /// <summary>
        /// API to add the Data
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task <bool> Add(ItemModel data)
        {
            Dataset.Add(data);
            var result = await DataStore.CreateAsync(data);

            return(true);
        }
        public void LoadData()
        {
            Dataset.Clear();
            if (CharactersViewModel.Instance.Dataset.Count == 0)
            {
                CharactersViewModel.Instance.LoadDataCommand.Execute(null);
            }
            else if (CharactersViewModel.Instance.NeedsRefresh())
            {
                CharactersViewModel.Instance.LoadDataCommand.Execute(null);
            }
            var dataset   = CharactersViewModel.Instance.GetAllCreatures();
            int teamCount = 0;

            foreach (var data in dataset)
            {
                if ((data.Type == 0) && (teamCount < 6))//&& data.OnTeam)//the creature is a character, the team is not full, and it is on the current team
                {
                    teamCount++;
                    Creature newOne = new Creature();
                    newOne.Update(data);
                    newOne.Id = Guid.NewGuid().ToString();
                    Dataset.Add(newOne);
                }
            }
        }
        // Command that Loads the Data
        private async Task ExecuteLoadDataCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Dataset.Clear();
                var dataset = await DataStore.IndexAsync(true);

                // Example of how to sort the database output using a linq query.
                // Sort the list
                dataset = dataset
                          .OrderBy(a => a.Name)
                          .ThenBy(a => a.Description)
                          .ToList();

                foreach (var data in dataset)
                {
                    Dataset.Add(data);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #15
0
        public async Task <bool> AddAsync(Monster data)
        {
            Dataset.Add(data);
            var ret = await DataStore.AddAsync_Monster(data);

            return(ret);
        }
Exemple #16
0
        // Command to load data into collection
        private async Task ExecuteLoadDataCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Dataset.Clear();
                var dataset = await DataStore.GetAllAsync_Score(true);

                // Load the data structure
                foreach (var data in dataset)
                {
                    Dataset.Add(data);
                }
                SetNeedsRefresh(false);
            }

            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            finally
            {
                IsBusy = false;
            }
        }
Exemple #17
0
        // Call to database operation for add
        public async Task <bool> AddAsync(Score data)
        {
            Dataset.Add(data);
            await DataStore.AddAsync_Score(data);

            return(true);
        }
Exemple #18
0
        private async Task ExecuteLoadDataCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Dataset.Clear();
                var dataset = await DataStore.GetAllAsync_Item(true);

                foreach (var data in dataset)
                {
                    Dataset.Add(data);
                }
            }

            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            finally
            {
                IsBusy = false;
            }
        }
Exemple #19
0
        private async Task ExecuteLoadDataCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Dataset.Clear();
                var dataset = await DataStore.IndexAsync();

                // Example of how to sort the database output using a linq query.
                // Sort the list
                dataset = SortDataset(dataset);

                foreach (var data in dataset)
                {
                    // Make a Copy of the Item Model to add to the List
                    Dataset.Add(data);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #20
0
        /// <summary>
        /// Method to call before performing the actual saving.
        /// </summary>
        protected override void OnSave()
        {
            if (RootDirectoryRecord == null)
            {
                throw new InvalidOperationException("No DICOM files added, cannot save DICOM directory");
            }

            _directoryRecordSequence.Items.Clear();
            var calculator = new DicomWriteLengthCalculator(FileMetaInfo.TransferSyntax, DicomWriteOptions.Default);

            // ensure write length calculator does not include end of sequence item
            //Dataset.Remove(DicomTag.DirectoryRecordSequence);

            //_fileOffset = 128 + calculator.Calculate(FileMetaInfo) + calculator.Calculate(Dataset);

            //Add the offset for the Directory Record sequence tag itself
            //_fileOffset += 4;//sequence element tag
            if (FileMetaInfo.TransferSyntax.IsExplicitVR)
            {
                _fileOffset  = 128 + calculator.Calculate(FileMetaInfo) + calculator.Calculate(Dataset);
                _fileOffset += 2; // vr
                _fileOffset += 2; // padding
                _fileOffset += 4; // length
            }
            else
            {
                _fileOffset = 128 + 4 + calculator.Calculate(FileMetaInfo) + calculator.Calculate(Dataset);

                _fileOffset += 4; //sequence element tag
                _fileOffset += 4; //length
            }

            AddDirectoryRecordsToSequenceItem(RootDirectoryRecord);

            if (RootDirectoryRecord != null)
            {
                CalculateOffsets(calculator);

                SetOffsets(RootDirectoryRecord);

                Dataset.Add <uint>(
                    DicomTag.OffsetOfTheFirstDirectoryRecordOfTheRootDirectoryEntity,
                    RootDirectoryRecord.Offset);

                var lastRoot = RootDirectoryRecord;

                while (lastRoot.NextDirectoryRecord != null)
                {
                    lastRoot = lastRoot.NextDirectoryRecord;
                }

                Dataset.Add <uint>(DicomTag.OffsetOfTheLastDirectoryRecordOfTheRootDirectoryEntity, lastRoot.Offset);
            }
            else
            {
                Dataset.Add <uint>(DicomTag.OffsetOfTheFirstDirectoryRecordOfTheRootDirectoryEntity, 0);
                Dataset.Add <uint>(DicomTag.OffsetOfTheLastDirectoryRecordOfTheRootDirectoryEntity, 0);
            }
        }
Exemple #21
0
        public void Remove()
        {
            Dataset dataset = new Dataset();

            dataset.Add(fooExtension);
            dataset.Add(barExtension);

            ExtensionInfo removedExtension = dataset.Remove(fooExtension.Name);

            AssertAreEqual(fooExtension, removedExtension);
            Assert.AreEqual(1, dataset.Count);
            AssertAreEqual(barExtension, dataset[0]);

            removedExtension = dataset.Remove(barExtension.Name);
            AssertAreEqual(barExtension, removedExtension);
            Assert.AreEqual(0, dataset.Count);
        }
Exemple #22
0
 public virtual void AddValue(WinLossKind winLossKind, bool?scoreless)
 {
     Dataset.Add(new SetElement
     {
         Value     = winLossKind,
         Scoreless = scoreless
     });
 }
Exemple #23
0
 // Add characters playing the game from the list of players in battle.
 public void InitializeCharacterCollection(List <Character> characters)
 {
     Dataset.Clear();
     foreach (var charNew in characters)
     {
         Dataset.Add(charNew);
     }
 }
        /// <summary>
        /// API to add the Data
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task <bool> CreateAsync(ItemModel data)
        {
            Dataset.Add(data);
            var result = await DataStore.CreateAsync(data);

            SetNeedsRefresh(true);

            return(result);
        }
Exemple #25
0
        public void setMonsters()
        {
            Dataset.Clear();
            //LoadDataCommand = new Command(async () => await ExecuteLoadDataCommand());
            if (MonstersViewModel.Instance.Dataset.Count == 0)
            {
                MonstersViewModel.Instance.LoadDataCommand.Execute(null);
            }
            else if (MonstersViewModel.Instance.NeedsRefresh())
            {
                MonstersViewModel.Instance.LoadDataCommand.Execute(null);
            }
            var    dataset     = MonstersViewModel.Instance.GetAllCreatures();
            var    tempDataset = new List <Creature>();
            int    dateSeed    = DateTime.Now.Millisecond;
            Random rand        = new Random(dateSeed);

            foreach (var data in dataset)
            {
                if (data.Type == 1)// just Monsters
                {
                    Creature newOne = new Creature();
                    newOne.Update(data);

                    tempDataset.Add(newOne);
                }
            }
            for (int i = 0; i < 6; i++)
            {
                int index = rand.Next(tempDataset.Count);
                if (GameGlobals.DisableRandomNumbers)
                {
                    index = 0;
                }
                Creature monster = new Creature();
                monster.Update(tempDataset[index]);         //get a random monster type
                monster.Id      = "monster" + i.ToString(); //Guid.NewGuid().ToString();
                monster.Alive   = true;
                monster.Level   = round;
                monster.XP      = lp[round].XP;
                monster.Attack  = lp[round].Attack;
                monster.Defense = lp[round].Defense;
                monster.Speed   = lp[round].Speed;
                int healthRand = rand.Next(11);
                if (GameGlobals.DisableRandomNumbers)
                {
                    healthRand = 1;
                }
                monster.MaxHealth   = healthRand * round;
                monster.CurrHealth  = monster.MaxHealth;
                monster.RHandItemID = "bow";//              ***temp for demo***
                monster.BodyItemID  = "helmet";
                monster.FeetItemID  = "boots";
                Dataset.Add(monster);
            }
        }
Exemple #26
0
        public void SaveAs()
        {
            Dataset dataset = new Dataset();

            dataset.Add(fooExtension);
            dataset.Add(barExtension);

            eventDataset = null;
            string path = Data.MakeOutputPath("SaveAs_Test.xml");

            dataset.SaveAs(path);
            Assert.AreEqual(path, dataset.Path);
            Assert.AreSame(dataset, eventDataset);

            Dataset loadedDataset = new Dataset(path);

            Assert.IsNotNull(loadedDataset);
            AssertAreEqual(dataset, loadedDataset);
        }
Exemple #27
0
 /// <summary>
 /// This method is for the game engine to call to add an item to the item list
 /// It is not async, so it can be called from the game engine on it's thread
 /// It sets the needs refresh flag
 /// Items added to the list this way, are not saved to the DB, they are temporary during the game.
 /// Refactor for the future would be to create a separate item list for the game to add to, and work with.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public bool Create_Sync(T data)
 {
     if (data == null)
     {
         return(false);
     }
     Dataset.Add(data);
     SetNeedsRefresh(true);
     return(true);
 }
Exemple #28
0
        public void clean()
        {
            List <Item> clean = Dataset.ToList();

            Dataset.Clear();
            foreach (var data in clean.Where(x => x != null))
            {
                Dataset.Add(data);
            }
        }
Exemple #29
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Executes the command.
        /// </summary>
        public void Execute()
        {
#if ENABLE_OLD_CODE
            //  TODO: This code is from the old AddCommand, so it needs to be
            //  updated eventually.

            Dataset dataset = Dataset.LoadOrCreate(Dataset.DefaultPath);
            EditableExtensionInfo.Dataset = dataset;
            ExtensionParser parser    = new ExtensionParser();
            ExtensionInfo   extension = Data.Load <ExtensionInfo>(extensionInfoPath, parser);

            List <string> missingLibs = new List <string>();
            foreach (string library in extension.ReferencedAssemblies)
            {
                if (!dataset.ReferencedByEntries(library))
                {
                    missingLibs.Add(library);
                }
            }

            List <string> libsToBeInstalled = new List <string>();
            foreach (string libPath in extension.LibraryPaths)
            {
                libsToBeInstalled.Add(Path.GetFileNameWithoutExtension(libPath));
            }

            foreach (string libToBeInstalled in libsToBeInstalled)
            {
                missingLibs.Remove(libToBeInstalled);
            }
            if (missingLibs.Count > 0)
            {
                MultiLineText message = new MultiLineText();
                message.Add("Error: The extension requires the following libraries which are not");
                message.Add("       currently installed and are not listed in the extension info file:");
                foreach (string lib in missingLibs)
                {
                    message.Add("         " + lib);
                }
                throw new MultiLineException(message);
            }

            Console.WriteLine("Installation directory: {0}", installDir);
            Console.WriteLine("Copying files to installation directory ...");
            CopyFileToInstallDir(extension.AssemblyPath);
            foreach (string libPath in extension.LibraryPaths)
            {
                CopyFileToInstallDir(libPath);
            }

            dataset.Add(extension);
            dataset.Save();
            Console.WriteLine("Extension {0} installed", extension.Name);
#endif
        }
        private async Task ExecuteLoadDataCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Dataset.Clear();
                DatasetParty.Clear();
                var dataset = await DataStore.GetAllAsync_Character(true);

                dataset = dataset
                          .OrderBy(a => a.Level)
                          .ThenBy(a => a.Name)
                          .ThenBy(a => a.Speed)
                          .ThenByDescending(a => a.MaximumHealth)
                          .ToList();

                // var datasett = await DataStore.GetPartyAsync_Character(true);
                foreach (var data in dataset)
                {
                    Dataset.Add(data);
                }
                Dataset = new ObservableCollection <Character>(Dataset.OrderBy(a => a.Level)
                                                               .ThenBy(a => a.Name)
                                                               .ThenBy(a => a.Speed)
                                                               .ThenByDescending(a => a.MaximumHealth)
                                                               .ToList());
                foreach (var data in dataset)
                {
                    if (PartyList.Contains(data.Id))
                    {
                        DatasetParty.Add(data);
                    }
                    //DatasetParty = new ObservableCollection<Character>(DatasetParty.OrderBy(a => a.Level)
                    //.ThenBy(a => a.Name)
                    //.ThenBy(a => a.Speed)
                    //.ThenByDescending(a => a.MaximumHealth)
                    //.ToList());
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }