Пример #1
0
        static void Main(string[] args)
        {
            var dictionary = new Dictionary.Dictionary <int, string>();

            dictionary.Notify += DisplayMessage;

            dictionary.Add(55, "asdasdad");
            System.Console.WriteLine("\n");
            System.Console.WriteLine(dictionary[55]);
            dictionary.Remove(55);

            var list = dictionary.Keys;

            System.Console.WriteLine(list.Contains(55));

            System.Console.WriteLine();
            System.Console.WriteLine();

            dictionary.Add(1, "111");
            dictionary.Add(2, "222");
            dictionary.Add(3, "333");
            KeyValuePair <int, string>[] array =
            {
                new KeyValuePair <int, string>(5, "555"),
                new KeyValuePair <int, string>(6, "555"),
                new KeyValuePair <int, string>(7, "555"),
            };

            dictionary.CopyTo(array, 1);

            foreach (var item in array)
            {
                System.Console.WriteLine(item);
            }
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TokenizerFactory"/> class.
 /// </summary>
 /// <param name="languageCode">The language code.</param>
 /// <param name="abbreviationDictionary">The abbreviation dictionary.</param>
 /// <param name="useAlphaNumericOptimization">if true alpha numerics are skipped.</param>
 /// <param name="alphaNumericPattern">The alpha numeric pattern.</param>
 public TokenizerFactory(string languageCode, Dictionary.Dictionary abbreviationDictionary, bool useAlphaNumericOptimization, string alphaNumericPattern)
 {
     this.languageCode = languageCode;
     this.useAlphaNumericOptimization = useAlphaNumericOptimization;
     this.alphaNumericPattern         = alphaNumericPattern;
     this.abbreviationDictionary      = abbreviationDictionary;
 }
Пример #3
0
        protected AbstractParserEventStream(
            IObjectStream <Parse> samples,
            IHeadRules headRules,
            ParserEventTypeEnum type,
            Dictionary.Dictionary dictionary) : base(samples)
        {
            Rules         = headRules;
            Punctuation   = headRules.PunctuationTags;
            Dictionary    = dictionary;
            FixPossesives = false;

            Type = type;

#pragma warning disable 618
            switch (type)
            {
            case ParserEventTypeEnum.Chunk:
                chunkerContextGenerator = new ChunkContextGenerator();
                break;

            case ParserEventTypeEnum.Tag:
                posContextGenerator = new DefaultPOSContextGenerator(null);
                break;
            }
#pragma warning restore 618
        }
Пример #4
0
 public ParserEventStream(IObjectStream <Parse> d, AbstractHeadRules rules, ParserEventTypeEnum type,
                          Dictionary.Dictionary dict)
     : base(d, rules, type, dict)
 {
     buildContextGenerator  = new BuildContextGenerator();
     attachContextGenerator = new AttachContextGenerator(Punctuation);
     checkContextGenerator  = new CheckContextGenerator(Punctuation);
 }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TokenizerFactory"/> class.
        /// </summary>
        /// <param name="languageCode">The language code.</param>
        /// <param name="abbreviationDictionary">The abbreviation dictionary.</param>
        /// <param name="useAlphaNumericOptimization">if true alpha numerics are skipped.</param>
        public TokenizerFactory(string languageCode, Dictionary.Dictionary abbreviationDictionary,
            bool useAlphaNumericOptimization) {
            this.languageCode = languageCode;
            this.useAlphaNumericOptimization = useAlphaNumericOptimization;
            this.abbreviationDictionary = abbreviationDictionary;

            alphaNumericPattern = Factory.GetAlphanumeric(languageCode);
        }
Пример #6
0
 public Model(Dictionary.Dictionary GameDictionary, Language.Language Language)
 {
     this.GameLanguage = Language;
     TilesSet = new TilesSet(Language);
     this.Players = new List<Player.Player>();
     this.GameBoard = new Board.Board();
     this.GameDictionary = GameDictionary;
     this.PassCounter = 0;
 }
 public CreateOrUpdateDictionaryWordForm(Dictionary.Dictionary dict)
 {
     state = State.Normal;
     this.selectedWord = "";
     this.selectedDascription = "";
     InitializeComponent();
     this.Text = "Введите новое понятие";
     dictionary = dict;
 }
Пример #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DictionaryNameFinder"/> with the provided dictionary and a type.
        /// </summary>
        /// <param name="dictionary">The dictionary.</param>
        /// <param name="type">The type of the result spans.</param>
        /// <exception cref="System.ArgumentNullException">type</exception>
        public DictionaryNameFinder(Dictionary.Dictionary dictionary, string type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            Dictionary = dictionary;
            Type       = type;
        }
Пример #9
0
        /// <summary>
        /// Validates the parsed artifacts.
        /// </summary>
        /// <exception cref="InvalidFormatException">Invalid artifact map.</exception>
        public override void ValidateArtifactMap()
        {
            // Ensure that the tag dictionary is compatible with the model

            var tagDicEntry = ArtifactProvider.GetArtifact <ITagDictionary>(TagDictionaryEntryName);

            if (tagDicEntry != null && !ArtifactProvider.IsLoadedFromSerialized)
            {
                ValidatePOSDictionary((POSDictionary)tagDicEntry, Model);
            }

            dictionary = ArtifactProvider.GetArtifact <Dictionary.Dictionary>(NgramDictionaryEntryName);
        }
        public CreateOrUpdateDictionaryWordForm(string selectedWord, string selectedDascription, Dictionary.Dictionary dict)
        {
            state = State.Normal;

            this.selectedWord = selectedWord.ToLower();
            this.selectedDascription = selectedDascription;

            InitializeComponent();
            this.Text = "Отредактируйте текущее понятие";

            wordTextBox.Text = this.selectedWord;
            descriptionTextBox.Text = this.selectedDascription;
            dictionary = dict;
        }
Пример #11
0
        /// <summary>
        /// Create an event stream based on the specified data stream of the specified type using the specified head rules.
        /// </summary>
        /// <param name="samples">A 1-parse-per-line Penn Treebank Style parse.</param>
        /// <param name="rules">The head rules.</param>
        /// <param name="eType">The type of events desired (tag, chunk, build, or check).</param>
        /// <param name="dictionary">A tri-gram dictionary to reduce feature generation.</param>
        public ParserEventStream(IObjectStream <Parse> samples, AbstractHeadRules rules, ParserEventTypeEnum eType,
                                 Dictionary.Dictionary dictionary)
            : base(samples, rules, eType, dictionary)
        {
            switch (eType)
            {
            case ParserEventTypeEnum.Build:
                bcg = new BuildContextGenerator(dictionary);
                break;

            case ParserEventTypeEnum.Check:
                kcg = new CheckContextGenerator();
                break;
            }
        }
Пример #12
0
        public void CountSymbols()
        {
            Dictionary.Dictionary <char, int> charactersByCount = new Dictionary.Dictionary <char, int>();
            string text = this.InputText();

            foreach (var character in text)
            {
                if (!charactersByCount.ContainsKey(character))
                {
                    charactersByCount.Add(character, 0);
                }

                charactersByCount[character]++;
            }

            var sortedCharactersByCount = charactersByCount.OrderBy(x => x.Key);

            this.PrintSymbolsCount(sortedCharactersByCount);
        }
Пример #13
0
        static void Main()
        {
            var phonebook = new Dictionary.Dictionary<string, string>();
            string line = Console.ReadLine();
            string name = string.Empty;
            string number = string.Empty;
            List<string> names = new List<string>();

            while (line != "search")
            {
                string[] parts = line.Split('-');

                name = parts[0];
                number = parts[1];
                phonebook.Add(name, number);
                line = Console.ReadLine();
            }

            line = Console.ReadLine();

            while (!String.IsNullOrEmpty(line))
            {
                names.Add(line);
                line = Console.ReadLine();
            }

            foreach (var personName in names)
            {
                if (phonebook.ContainsKey(personName))
                {
                    Console.WriteLine("{0} -> {1}", personName, phonebook[personName]);
                }
                else
                {
                    Console.WriteLine("Contact {0} does not exist.", personName);
                }
            }
        }
        public CrosswordGenerationParametersForm(Type type, global::Crossword.Crossword crossword)
        {
            InitializeComponent();

            DialogResult = DialogResult.Cancel;

            _crossword = crossword;
            _type = type;
            if (type != Type.GenerateWithDictionary)
            {
                dictionaryFilePathTextBox.Visible = false;
                openDictionaryFileButton.Visible = false;
                label1.Visible = false;

                int margin = 80;

                generateButton.Location = new Point(generateButton.Location.X, generateButton.Location.Y - margin);
                heightNumericUpDown.Location = new Point(heightNumericUpDown.Location.X, heightNumericUpDown.Location.Y - margin);
                widthNumericUpDown.Location = new Point(widthNumericUpDown.Location.X, widthNumericUpDown.Location.Y - margin);
                label2.Location = new Point(label2.Location.X, label2.Location.Y - margin);
                heightLabel.Location = new Point(heightLabel.Location.X, heightLabel.Location.Y - margin);
                widthLabel.Location = new Point(widthLabel.Location.X, widthLabel.Location.Y - margin);
                this.Height -= margin;
            }
            if (type == Type.Params)
            {
                generateButton.Text = "Сохранить";
                this.Text = "Параметры";
            }

            if (crossword != null)
            {
                heightNumericUpDown.Value = crossword.Height;
                widthNumericUpDown.Value = crossword.Width;
            }

            _dictionary = new Dictionary.Dictionary();
        }
Пример #15
0
        /// <summary>
        /// Serializes this dictionary to the specified output stream.
        /// </summary>
        /// <param name="outputStream">The output stream.</param>
        public void Serialize(Stream outputStream)
        {
            if (outputStream == null)
            {
                throw new ArgumentNullException(nameof(outputStream));
            }

            if (!outputStream.CanWrite)
            {
                throw new ArgumentException(@"The input stream was not writable.", nameof(outputStream));
            }

            var dict = new Dictionary.Dictionary();

            foreach (var op in operationTable)
            {
                dict.Add(new Entry(new[] { op.Key }, new Attributes {
                    { "operation", GetOperationString(op.Value) }
                }));
            }

            dict.Serialize(outputStream);
        }
Пример #16
0
 protected void Init(Dictionary.Dictionary ngramDic, ITagDictionary posDic) {
     dictionary = ngramDic;
     tagDictionary = posDic;
 }
Пример #17
0
        /// <summary>
        /// Validates the parsed artifacts. 
        /// </summary>
        /// <exception cref="InvalidFormatException">Invalid artifact map.</exception>
        public override void ValidateArtifactMap() {
            // Ensure that the tag dictionary is compatible with the model

            var tagDicEntry = ArtifactProvider.GetArtifact<ITagDictionary>(TagDictionaryEntryName);

            if (tagDicEntry != null && !ArtifactProvider.IsLoadedFromSerialized) {
                ValidatePOSDictionary((POSDictionary) tagDicEntry, Model);
            }

            dictionary = ArtifactProvider.GetArtifact<Dictionary.Dictionary>(NgramDictionaryEntryName);
        }
Пример #18
0
        private void новыйToolStripMenuItem_Click(object sender, EventArgs e)
        {
            emptyState.Visible = false;
            SaveDialog();

            dictionary = new Dictionary.Dictionary();
            dictionary.DictionaryWords = new DictionaryWord[0];
            ShowDirectionButtons(false, true);
            ShowSortTypeButtons(false, true);
            ShowMask(true);
            UpdateButtonsState();
            UpdateUi();
        }
Пример #19
0
        private void LoadDictionary(Action action)
        {
            // TODO Save Existed

            SaveDialog();

            ShowProgress();
            Dictionary.Dictionary dictionary = new Dictionary.Dictionary();

            dictionary.Load((res) =>
            {
                this.dictionary = dictionary;
                try
                {
                    UpdateUi();
                    if (action != null)
                    {
                        action.Invoke();
                    }
                }
                catch (Exception e)
                {
                    ShowDirectionButtons(false, false);
                    ShowSortTypeButtons(false, false);
                    ShowMask(false);
                    UpdateButtonsState();
                    emptyState.Visible = true;
                }
            });
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DictionaryFeatureGenerator"/> with the given dictionary.
 /// </summary>
 /// <param name="dict">The dictionary.</param>
 public DictionaryFeatureGenerator(Dictionary.Dictionary dict) : this("", dict)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DictionaryFeatureGenerator"/> with the given prefix and dictionary.
 /// </summary>
 /// <param name="prefix">The prefix/name used to distinguish the generated features.</param>
 /// <param name="dict">The dictionary.</param>
 public DictionaryFeatureGenerator(string prefix, Dictionary.Dictionary dict)
 {
     SetDictionary(prefix, dict);
 }
 /// <summary>
 /// Sets the dictionary.
 /// </summary>
 /// <param name="dict">The dictionary.</param>
 public void SetDictionary(Dictionary.Dictionary dict)
 {
     SetDictionary(string.Empty, dict);
 }
 /// <summary>
 /// Sets the dictionary.
 /// </summary>
 /// <param name="name">The name used to distinguish the generated features.</param>
 /// <param name="dict">The dictionary.</param>
 public void SetDictionary(string name, Dictionary.Dictionary dict)
 {
     isg = new InSpanGenerator(name, new DictionaryNameFinder(dict));
 }
Пример #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DictionaryNameFinder"/> with the provided dictionary.
 /// </summary>
 /// <param name="dictionary">The dictionary.</param>
 public DictionaryNameFinder(Dictionary.Dictionary dictionary) : this(dictionary, DEFAULT_TYPE)
 {
 }
Пример #25
0
 protected void Init(Dictionary.Dictionary ngramDic, ITagDictionary posDic)
 {
     dictionary    = ngramDic;
     tagDictionary = posDic;
 }
Пример #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultPOSContextGenerator"/> without cache.
 /// </summary>
 /// <param name="dictionary">The dictionary.</param>
 public POSContextGenerator(Dictionary.Dictionary dictionary) : base(dictionary)
 {
 }
 public CrosswordGenerationParametersForm(Type type, global::Crossword.Crossword crossword,
     Dictionary.Dictionary dictionary)
     : this(type, crossword)
 {
     _dictionary = dictionary;
 }
Пример #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultPOSContextGenerator"/> with the specified cache size.
 /// </summary>
 /// <param name="cacheSize">The cache size.</param>
 /// <param name="dictionary">The dictionary.</param>
 public POSContextGenerator(int cacheSize, Dictionary.Dictionary dictionary) : base(cacheSize, dictionary)
 {
 }