Esempio n. 1
0
        /// <summary>
        /// Template method which is invoked from <see cref="ElementParserBase.Parse"/> when
        /// a match is encountered.
        /// </summary>
        /// <param name="authoringEngine"></param>
        /// <param name="parentElement"></param>
        /// <param name="match"></param>
        protected override void ProcessMatch(IAuthoringEngine authoringEngine, DomElement parentElement, Match match)
        {
            Acronym acronym = new Acronym(parentElement, match.Groups["Text"].Value,
                                          match.Groups["Acronym"].Value);

            parentElement.AppendChild(acronym);
        }
Esempio n. 2
0
        private void showDetails()
        {
            Acronym acronymSelected = lbxAcronym.SelectedItem as Acronym;

            if (acronymSelected != null)
            {
                Meaning selectedMeaning = acronymSelected.Meanings.First(x => x.Caption == lvwMeaning.SelectedItems[0].Text);
                if (rdoCategories.Checked)
                {
                    lblDetailsCaption.Text = "Categories:";
                    lbxDetails.DataSource  = selectedMeaning.Categories.OrderBy(x => x.Caption).Select(x => x.Caption).ToList();
                }
                else if (rdoResources.Checked)
                {
                    lblDetailsCaption.Text = "Sources:";
                    lbxDetails.DataSource  = selectedMeaning.Resources.SelectMany(x => x.Executions.Select(y => y.Description)).Distinct().OrderBy(x => x).ToList();
                }
                else if (rdoMatches.Checked)
                {
                    lblDetailsCaption.Text = "Matchers:";
                    lbxDetails.DataSource  = selectedMeaning.Configurations.Select(x => x.Description).OrderBy(x => x).ToList();
                }
                else if (rdoValidations.Checked)
                {
                    lblDetailsCaption.Text = "Validators:";
                    lbxDetails.DataSource  = selectedMeaning.Validations.Select(x => x.Arrangement.Description).OrderBy(x => x).ToList();
                }
            }
        }
Esempio n. 3
0
        protected override List <Meaning> ValidateMeanings(Acronym acronym)
        {
            string acronymCaption = _setAcronymToLowerCase
                                        ? acronym.Caption.ToLowerInvariant()
                                        : acronym.Caption;

            acronymCaption = HttpUtility.UrlEncode(StringTreatment.RemoveDiacritics(acronymCaption)
                                                   .Replace(".", string.Empty)
                                                   .Replace("/", string.Empty));

            List <string> meanings = getMeanings(acronymCaption);

            if (meanings != null && meanings.Count == 0 && acronymCaption.Contains("-"))
            {
                meanings = getMeanings(acronymCaption.Replace("-", string.Empty));
            }

            List <Meaning> validatedMeanings = null;

            if (meanings != null)
            {
                validatedMeanings = acronym.Meanings.Where(x => meanings.Any(y => y.IndexOf(x.Caption.ToUpperInvariant()) >= 0 ||
                                                                             x.Caption.ToUpperInvariant().IndexOf(y) >= 0)).ToList();
            }

            return(validatedMeanings);
        }
Esempio n. 4
0
    public static void Main(String[] args)
    {
        string output = Acronym.Abbreviate("Something - I made up from thin air");

        Console.WriteLine(output);
        Console.ReadKey();
    }
Esempio n. 5
0
        private void lbxAcronym_SelectedValueChanged(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                lvwMeaning.Items.Clear();
                if (lbxAcronym.SelectedItem != null)
                {
                    Acronym acronymSelected = lbxAcronym.SelectedItem as Acronym;
                    lvwMeaning.Items.AddRange(acronymSelected.Meanings
                                              .OrderBy(x => x.Caption)
                                              .Select(x => new ListViewItem(x.Caption,
                                                                            x.Validations.Any(y => y.Validated) ? 1 : 0))
                                              .ToArray());
                }
                if (lvwMeaning.Items.Count > 0)
                {
                    lvwMeaning.Items[0].Selected = true;
                }
                else
                {
                    lvwMeaning_SelectedIndexChanged(sender, e);
                }
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Fills in LHD details and click create.
 /// </summary>
 public void FillInLHDDetailsAndClickCreate()
 {
     lName = "RegTestLHD" + PageHelper.RandomNumber(4);
     Name.SendKeys(lName);
     Acronym.SendKeys("RGT" + PageHelper.RandomNumber(4));
     PeriodicCoreFunding.SendKeys("20000");
     SaveLHDButton.Click();
     BackToListButton.Click();
 }
Esempio n. 7
0
        public override bool Equals(object obj)
        {
            var compareTo = obj as Gender;

            if (compareTo is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, compareTo))
            {
                return(true);
            }

            return(Acronym.Equals(compareTo.Acronym) && InFull.Equals(compareTo.InFull));
        }
Esempio n. 8
0
        public JsonResult GetAcronym()
        {
            Acronym acronym = new Acronym();

            try
            {
                acronym.UserId   = new Guid(Session["UserID"].ToString());
                acronym.AgencyId = (Session["AgencyId"] != null) ? new Guid(Session["AgencyId"].ToString()) : (Guid?)null;
                acronym          = new MatrixData().GetAcronym(acronym);
            }
            catch (Exception ex)
            {
                clsError.WriteException(ex);
            }
            return(Json(acronym, JsonRequestBehavior.AllowGet));
        }
Esempio n. 9
0
        private IEnumerator ValidateAcronym(Acronym acronym, float duration)
        {
            var answers = data.cards.SelectMany(card => card.acronyms)
                          .Where(a => a != acronym && a.key.Equals(acronym.key))
                          .Select(a => a.value)
                          .Take(3).ToList();

            answers.Add(acronym.value);
            answers = answers.OrderBy(a => UnityEngine.Random.value).ToList();

            for (var i = answers.Count; i < answersParent.childCount; i++)
            {
                Destroy(answersParent.GetChild(i).gameObject);
            }
            for (var i = answersParent.childCount; i < answers.Count; i++)
            {
                Instantiate(answerPrefab, answersParent);
            }
            yield return(null);

            var answerPanels = answersParent.GetComponentsInChildren <AnswerPanel>();

            for (var i = 0; i < answerPanels.Length; i++)
            {
                answerPanels[i].SetColor(defaultColor);
                answerPanels[i].SetAnswer(answers[i], acronym.value.Equals(answers[i]), OnAnswerClick);
            }

            _isWaiting       = true;
            _isValidAnswer   = false;
            timeSlider.value = 1;
            var time = 0f;

            while (_isWaiting && time < duration)
            {
                time            += Time.deltaTime;
                timeSlider.value = 1 - time / duration;
                yield return(null);
            }

            _isWaiting = false;
            yield return(new WaitForSeconds(.5f));

            timeSlider.value = 1;
        }
Esempio n. 10
0
        private void Button1_Click(object sender, EventArgs e)
        {
            if (validateNewAcronym())
            {
                Acronym x = new Acronym(textBox1.Text, textBox2.Text, textBox3.Text);
                foreach (IDataConnection db in GlobalConnections.connList)
                {
                    db.CreateAcronym(x);
                }
                MessageBox.Show("Acronym entered successfully!");
                this.Hide();

                UI newForm = new UI();
                newForm.ShowDialog();
                this.Close();
            }
            else
            {
                MessageBox.Show("This form has invalid information");
            }
        }
        public void Parse()
        {
            DomDocument          document            = new DomDocument();
            IInlineElementParser inlineElementParser = new AcronymParser();

            inlineElementParser.Parse(null, document,
                                      "HTML(Hypertext Markup Language), КГБ(Комитет Государственной безопасности) XML - eXtensible(yep) markup language");

            Assert.AreEqual(2, document.ChildElements.Count);

            Acronym acronym = document.ChildElements[0] as Acronym;

            Assert.IsNotNull(acronym);
            Assert.AreEqual("HTML", acronym.Title);
            Assert.AreEqual("Hypertext Markup Language", acronym.InnerText);

            acronym = document.ChildElements[1] as Acronym;

            Assert.IsNotNull(acronym);
            Assert.AreEqual("КГБ", acronym.Title);
            Assert.AreEqual("Комитет Государственной безопасности", acronym.InnerText);
        }
Esempio n. 12
0
        private void lvwMeaning_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current     = Cursors.WaitCursor;
                pnlDetails.Visible = lvwMeaning.SelectedItems.Count > 0;

                if (lvwMeaning.SelectedItems.Count > 0)
                {
                    Acronym acronymSelected = lbxAcronym.SelectedItem as Acronym;
                    Meaning selectedMeaning = acronymSelected.Meanings.First(x => x.Caption == lvwMeaning.SelectedItems[0].Text);
                    lblNoOfCategories.Text  = selectedMeaning.Categories.Count.ToString("n0");
                    lblNoOfResources.Text   = selectedMeaning.Resources.Count.ToString("n0");
                    lblNoOfMatches.Text     = selectedMeaning.Configurations.Count.ToString("n0");
                    lblNoOfValidations.Text = selectedMeaning.Validations.Count(x => x.Validated).ToString("n0");
                    showDetails();
                }
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Esempio n. 13
0
 public void Lowercase_words()
 {
     Assert.Equal("ROR", Acronym.Abbreviate("Ruby on Rails"));
 }
Esempio n. 14
0
 public void Empty_string_abbreviated_to_empty_string()
 {
     Assert.That(Acronym.Abbreviate(string.Empty), Is.EqualTo(string.Empty));
 }
Esempio n. 15
0
 public void Underscore_emphasis()
 {
     Assert.Equal("TRNT", Acronym.Abbreviate("The Road _Not_ Taken"));
 }
Esempio n. 16
0
 public void Apostrophes()
 {
     Assert.Equal("HC", Acronym.Abbreviate("Halley's Comet"));
 }
Esempio n. 17
0
 public void Camelcase()
 {
     Assert.Equal("HTML", Acronym.Abbreviate("HyperText Markup Language"));
 }
Esempio n. 18
0
 public void Consecutive_delimiters()
 {
     Assert.Equal("SIMUFTA", Acronym.Abbreviate("Something - I made up from thin air"));
 }
Esempio n. 19
0
 public void Punctuation_without_whitespace()
 {
     Assert.Equal("CMOS", Acronym.Abbreviate("Complementary metal-oxide semiconductor"));
 }
Esempio n. 20
0
 public override int GetHashCode()
 {
     return((GetType().GetHashCode() * 1643) + Acronym.GetHashCode() + InFull.GetHashCode());
 }
Esempio n. 21
0
 protected internal abstract List <Meaning> ValidateMeanings(Acronym acronym);
Esempio n. 22
0
        internal static Meaning GetMeaning(string match, string definition, List <ResourceCategory> categories)
        {
            Acronym acronym = DataContext.Instance.AcronymSet.FirstOrDefault(a => a.Caption == match);

            bool pendingChanges = false;

            if (acronym == null)
            {
                acronym = DataContext.Instance.AcronymSet.Add(new Acronym {
                    Caption = match
                });
                if (AcronymCreated != null)
                {
                    AcronymCreated(acronym.Caption);
                }
                pendingChanges = true;
            }

            Meaning meaning = acronym.Meanings.FirstOrDefault(m => m.Caption.ToUpper() == definition.ToUpper());

            if (meaning == null)
            {
                meaning = acronym.Meanings.FirstOrDefault(m => definition.ToUpper().Contains(m.Caption.ToUpper()));
            }

            if (meaning == null)
            {
                meaning = acronym.Meanings.FirstOrDefault(m => m.Caption.ToUpper().Contains(definition.ToUpper()));
                if (meaning != null)
                {
                    meaning.Caption = definition;
                    pendingChanges  = true;
                }
            }

            if (meaning == null)
            {
                meaning = DataContext.Instance.MeaningSet.Add(new Meaning {
                    Caption = definition, Acronym = acronym
                });
                if (MeaningCreated != null)
                {
                    MeaningCreated(acronym.Caption, meaning.Caption);
                }
                pendingChanges = true;
            }

            foreach (ResourceCategory resourceCategory in categories)
            {
                resourceCategory.Category = DataContext.Instance.CategorySet
                                            .FirstOrDefault(c => c.Caption.ToUpper() == resourceCategory.Name.ToUpper());
                if (resourceCategory.Category == null)
                {
                    resourceCategory.Category = DataContext.Instance.CategorySet.Add(new Category {
                        Caption = resourceCategory.Name
                    });
                    pendingChanges = true;
                }

                if (!meaning.Categories.Contains(resourceCategory.Category))
                {
                    meaning.Categories.Add(resourceCategory.Category);
                    pendingChanges = true;
                }
            }

            if (pendingChanges)
            {
                DataContext.Instance.SaveChanges();
            }

            return(meaning);
        }
Esempio n. 23
0
 public void NonAcronymAllCapsWord()
 {
     Assert.Equal("GIMP", Acronym.Abbreviate("GNU Image Manipulation Program"));
 }
Esempio n. 24
0
 public void Punctuation()
 {
     Assert.Equal("FIFO", Acronym.Abbreviate("First In, First Out"));
 }
Esempio n. 25
0
 public void All_caps_word()
 {
     Assert.Equal("GIMP", Acronym.Abbreviate("GNU Image Manipulation Program"));
 }
Esempio n. 26
0
 public void All_caps_words()
 {
     Assert.Equal("PHP", Acronym.Abbreviate("PHP: Hypertext Preprocessor"));
 }
Esempio n. 27
0
 public void Very_long_abbreviation()
 {
     Assert.Equal("ROTFLSHTMDCOALM", Acronym.Abbreviate("Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me"));
 }
Esempio n. 28
0
 public void Hyphenated()
 {
     Assert.Equal("CMOS", Acronym.Abbreviate("Complementary metal-oxide semiconductor"));
 }
Esempio n. 29
0
 public void Basic()
 {
     Assert.Equal("PNG", Acronym.Abbreviate("Portable Network Graphics"));
 }
Esempio n. 30
0
 /// <summary>
 /// Visits the <paramref name="acronym"/> element.
 /// </summary>
 /// <param name="acronym"></param>
 public virtual void Visit(Acronym acronym)
 {
     htmlBuilder.AppendFormat("<acronym title=\"{0}\">{1}</acronym>",
                              acronym.InnerText, acronym.Title);
 }