Exemplo n.º 1
0
        private Guid AddEntry(string lexemeForm,
                              string meaningWritingSystemId,
                              string meaning,
                              bool includeExample)
        {
            LexEntry entry = _lexEntryRepository.CreateItem();

            entry.LexicalForm.SetAlternative("th", lexemeForm);

            LexSense sense = new LexSense();

            entry.Senses.Add(sense);
#if GlossMeaning
            sense.Gloss[
                WeSayWordsProject.Project.DefaultViewTemplate.GetField("SenseGloss").WritingSystemIds[0]] =
                meaning;
#else
            sense.Definition.SetAlternative(meaningWritingSystemId, meaning);
#endif
            if (includeExample)
            {
                LexExampleSentence ex = new LexExampleSentence();
                sense.ExampleSentences.Add(ex);
                ex.Sentence.SetAlternative("th", "hello");
            }
            _lexEntryRepository.SaveItem(entry);
            return(entry.Guid);
        }
Exemplo n.º 2
0
        private void CreateLexentryWithOnlyCitationForm(string citationForm, string writingSystemId)
        {
            LexEntry entry = _lexEntryRepository.CreateItem();

            entry.CitationForm[writingSystemId] = citationForm;
            _lexEntryRepository.SaveItem(entry);
        }
Exemplo n.º 3
0
        public void Entries_PrecededByLetterDivs()
        {
            // Note: When the Palaso WritingSystemDefinition changed to use ICU for DefaultOrdering this test broke.
            // The windows SystemCollator using CultureInvariant sorts hyphens with the text, rather than default unicode
            // order.
            // To make this test pass we provide a custom ICU sort rule to do the same.
            _project.WritingSystems.Get("qaa-x-qaa").SortUsingCustomICU("&[last primary ignorable] <<< '-' <<< ' '");
            var entries = new List <LexEntry>();

            entries.Add(_entry);

            var pineapple = _repo.CreateItem();

            entries.Add(pineapple);
            pineapple.LexicalForm.SetAlternative("qaa-x-qaa", "-pineapple");            //should skip hyphen

            var pear = _repo.CreateItem();

            entries.Add(pear);
            pear.LexicalForm.SetAlternative("qaa-x-qaa", "pear");

            var contents = GetXhtmlContents(entries);

            //should only be two sections, not three
            AssertHasAtLeastOneMatch(contents, "html/body[count(div[@class='letHead'])=2]");

            AssertHasAtLeastOneMatch(contents, "html/body/div[@class='letHead']/div[@class='letter' and text()='A a']");
            AssertHasAtLeastOneMatch(contents, "html/body/div[@class='letHead']/div[@class='letData']");

            AssertHasAtLeastOneMatch(contents, "html/body/div[@class='letHead']/div[@class='letter' and text()='P p']");
        }
		public void Setup()
		{
			_tempFolder = new TemporaryFolder();
			_filePath = _tempFolder.GetTemporaryFile();
			_lexEntryRepository = new LexEntryRepository(_filePath);

			_target = _lexEntryRepository.CreateItem();
			_source = _lexEntryRepository.CreateItem();

			Field relationField = new Field("synonyms",
											"LexEntry",
											new string[] {"vernacular"},
											Field.MultiplicityType.ZeroOr1,
											"RelationToOneEntry");
			_missingRelationFieldFilter = new MissingFieldQuery(relationField);
		}
Exemplo n.º 5
0
        public void Activate_Refreshes()
        {
            MissingInfoTask task = (MissingInfoTask)_task;

            task.Activate();
            try
            {
                Assert.IsTrue(
                    ((MissingInfoControl)task.Control).EntryViewControl.RtfContentsOfPreviewForTests.Contains(_lexicalForm));

                Assert.AreEqual(1, _lexEntryRepository.CountAllItems());
            }
            finally
            {
                task.Deactivate();
            }
            _lexEntryRepository.CreateItem();              //REVIEW: So, connect the dots for me...  Why should creating an
            // item here make the list switch to that item after the Activate()? (JH)
            task.Activate();
            try
            {
                Assert.IsTrue(
                    ((MissingInfoControl)task.Control).EntryViewControl.DataSource.LexicalForm.
                    Empty);
                Assert.AreEqual(2, _lexEntryRepository.CountAllItems());
            }
            finally
            {
                task.Deactivate();
            }
        }
        public void Setup()
        {
            _tempFolder         = new TemporaryFolder();
            _filePath           = _tempFolder.GetTemporaryFile();
            _lexEntryRepository = new LexEntryRepository(_filePath);

            _target = _lexEntryRepository.CreateItem();
            _source = _lexEntryRepository.CreateItem();

            Field relationField = new Field("synonyms",
                                            "LexEntry",
                                            new string[] { "vernacular" },
                                            Field.MultiplicityType.ZeroOr1,
                                            "RelationToOneEntry");

            _missingRelationFieldFilter = new MissingFieldQuery(relationField, null, null);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Adds this word and gloss, potentially adding the current semantic domain to multiple entriew with that word and gloss.
        /// </summary>
        /// <param name="lexicalForm"></param>
        /// <param name="gloss"></param>
        /// <returns>the entries that were modified </returns>
        public IList <LexEntry> AddWord(string lexicalForm, string gloss)
        {
            VerifyTaskActivated();

            if (string.IsNullOrEmpty(lexicalForm))
            {
                throw new ArgumentNullException();
            }
            var modifiedEntries = new List <LexEntry>();

            if (lexicalForm != string.Empty)
            {
                ResultSet <LexEntry> recordTokens =
                    LexEntryRepository.GetEntriesWithMatchingLexicalForm(lexicalForm,
                                                                         FormWritingSystem);
                if (recordTokens.Count == 0)                //no entries with a matching form
                {
                    LexEntry entry = LexEntryRepository.CreateItem();
                    entry.LexicalForm.SetAlternative(WordWritingSystemId, lexicalForm);
                    AddCurrentSemanticDomainToEntry(entry, gloss);
                    LexEntryRepository.SaveItem(entry);
                    modifiedEntries.Add(entry);

                    _logger.WriteConciseHistoricalEvent("SD-Added '{0}' with Domain to '{1}'", entry.GetSimpleFormForLogging(), CurrentDomainName);
                }
                else                // one or more matching entries
                {
                    var entriesMatchingWord = new List <LexEntry>(from RecordToken <LexEntry> x in recordTokens select x.RealObject);
                    foreach (var entry in entriesMatchingWord)
                    {
                        if (HasMatchingSense(entry, gloss))
                        {
                            modifiedEntries.Add(entry);
                            AddCurrentSemanticDomainToEntry(entry, gloss);
                            _logger.WriteConciseHistoricalEvent("SD-Added Domain to '{0}'", entry.GetSimpleFormForLogging());
                            break;
                        }
                    }
                    if (modifiedEntries.Count == 0)                     //didn't find any matching glosses
                    {
                        //NB: what to do IS NOT CLEAR. This just adds to the first entry,
                        // but it's just rolling the dice!  What to do???
                        var first = entriesMatchingWord.First();
                        modifiedEntries.Add(first);
                        AddCurrentSemanticDomainToEntry(first, gloss);
                        _logger.WriteConciseHistoricalEvent("SD-Added Domain {0} to '{1}' REVIEW", CurrentDomainName, first.GetSimpleFormForLogging());
                    }
                }
            }
            _savedSensesDuringMoveToEditArea = null;
            UpdateCurrentWords();
            return(modifiedEntries);
        }
 public void NewEntry_ByEntry_TriggersModifiedEntryAdded()
 {
     using (var f = new TemporaryFolder("eventTests"))
     {
         using (var r = new LexEntryRepository(f.GetPathForNewTempFile(true)))
         {
             r.AfterEntryModified += OnEvent;
             LexEntry entry = r.CreateItem();
             r.SaveItem(entry);
             Assert.IsTrue(_gotEventCall);
         }
     }
 }
Exemplo n.º 9
0
        public void WordCollected_LexEntryAlreadyExists_WordAppearsInCompletedBox()
        {
            LexEntry e = _lexEntryRepository.CreateItem();

            e.LexicalForm[VernWs.Id] = "uno";
            Assert.AreEqual(1, _lexEntryRepository.CountAllItems());
            MultiText word = new MultiText();

            word[VernWs.Id] = "uno";
            Assert.AreEqual(0, e.Senses.Count);
            _lexEntryRepository.SaveItem(e);

            Task.NavigateFirstToShow();
            Task.WordCollected(word);
            Task.NavigateNext();
            Task.WordCollected(word);

            ResultSet <LexEntry> matchingLexicalForms = Task.GetRecordsWithMatchingMeaning();

            Assert.AreEqual(1, matchingLexicalForms.Count);
            Task.Deactivate();
        }
Exemplo n.º 10
0
        public void Setup()
        {
            _projectDir = new ProjectDirectorySetupForTesting("");
            _project    = _projectDir.CreateLoadedProject();
            _project.WritingSystems.Set(WritingSystemDefinition.Parse("fr"));
            _repo  = _project.GetLexEntryRepository();
            _entry = _repo.CreateItem();
            _entry.LexicalForm.SetAlternative("qaa-x-qaa", "apple");


            _project.DefaultPrintingTemplate.GetField(LexSense.WellKnownProperties.Definition).WritingSystemIds.Add("fr");
            _project.DefaultPrintingTemplate.GetField(LexExampleSentence.WellKnownProperties.Translation).WritingSystemIds.Add("fr");

            _project.DefaultPrintingTemplate.GetField(LexEntry.WellKnownProperties.CrossReference).Enabled = true;
        }
Exemplo n.º 11
0
        private LexEntry CreateEntry(string lexemeForm, string meaning)
        {
            LexEntry entry = _lexEntryRepository.CreateItem();

            entry.LexicalForm.SetAlternative(WritingSystemsIdsForTests.OtherIdForTest, lexemeForm);

            LexSense sense = new LexSense();

            entry.Senses.Add(sense);
            sense.Gloss[
                WeSayWordsProject.Project.DefaultViewTemplate.GetField(
                    LexSense.WellKnownProperties.Definition).WritingSystemIds[0]] = meaning;
            _lexEntryRepository.SaveItem(entry);
            return(entry);
        }
Exemplo n.º 12
0
        public void DeleteEntry_ByEntry_TriggersAfterEntryDeleted()
        {
            using (TemporaryFolder f = new TemporaryFolder("eventTests"))
            {
                using (LexEntryRepository r = new LexEntryRepository(f.GetPathForNewTempFile(true)))
                {
                    r.AfterEntryDeleted += OnEvent;

                    LexEntry entry = r.CreateItem();
                    r.SaveItem(entry);

                    r.DeleteItem(entry);
                    Assert.IsTrue(_gotEventCall);
                }
            }
        }
Exemplo n.º 13
0
        private void CreateTestEntry(string lexicalForm, string Definition, string exampleSentence)
        {
            var entry = _lexEntryRepository.CreateItem();

            entry.LexicalForm[_writingSystem.Id] = lexicalForm;
            var sense = new LexSense();

            entry.Senses.Add(sense);
            sense.Definition[WritingSystemsIdsForTests.AnalysisIdForTest] = Definition;
            var example = new LexExampleSentence();

            sense.ExampleSentences.Add(example);
            example.Sentence[_writingSystem.Id] = exampleSentence;
            _lexEntryRepository.SaveItem(entry);
            return;
        }
Exemplo n.º 14
0
            private LexEntry CreateEntryWithDefinitionAndWs(IEnumerable <string> populatedWritingSystems, IEnumerable <string> emptyWritingSystems)
            {
                LexEntry entry = _repository.CreateItem();

                entry.LexicalForm.SetAlternative(_vernacularWritingSystem.Id, "theForm");

                entry.Senses.Add(new LexSense());
                foreach (var id in populatedWritingSystems)
                {
                    entry.Senses[0].Definition.SetAlternative(id, "the definition for " + id);
                }
                foreach (var id in emptyWritingSystems)
                {
                    entry.Senses[0].Definition.SetAlternative(id, "");
                }

                return(entry);
            }
Exemplo n.º 15
0
        public void Setup()
        {
            _tempFolder         = new TemporaryFolder();
            _filePath           = _tempFolder.GetTemporaryFile();
            _lexEntryRepository = new LexEntryRepository(_filePath);

            WeSayProjectTestHelper.InitializeForTests();
            RtfRenderer.HeadWordWritingSystemId = _vernacularWritingSystemId;

            _missingFieldName = LexSense.WellKnownProperties.Definition;

            LexEntry entry = _lexEntryRepository.CreateItem();

            _lexicalForm = "vernacular";
            entry.LexicalForm.SetAlternative(_vernacularWritingSystemId, _lexicalForm);
            _lexEntryRepository.SaveItem(entry);
            _longLabel          = "Long label";
            _remainingCountText = "Remaining count:";
            _referenceCountText = "Reference count:";

            _fieldsToShow = "LexicalForm";
            _label        = "My label";
            _description  = "My description";

            _viewTemplate = new ViewTemplate();
            _viewTemplate.Add(new Field(LexEntry.WellKnownProperties.LexicalUnit,
                                        "LexEntry",
                                        new string[] { _vernacularWritingSystemId }));
            _viewTemplate.Add(new Field(LexSense.WellKnownProperties.Definition,
                                        "LexSense",
                                        new string[] { "en" }));
            _viewTemplate.Add(new Field(Field.FieldNames.ExampleSentence.ToString(),
                                        "LexExampleSentence",
                                        new string[] { "th" }));
            _task = CreateMissingInfoTask(_lexEntryRepository,
                                          _missingFieldName,
                                          _label,
                                          _longLabel,
                                          _description,
                                          _remainingCountText,
                                          _referenceCountText,
                                          _viewTemplate,
                                          _fieldsToShow, string.Empty);
        }
Exemplo n.º 16
0
        internal void AddNewWord(bool FocusWasOnFindTextBox)
        {
            Logger.WriteMinorEvent("NewWord_Click");

            // only create a new word when there is not an empty word already
            int emptyWordIndex = GetEmptyWordIndex();
            int selectIndex;

            if (emptyWordIndex == -1)
            {
                LexEntry entry = _lexEntryRepository.CreateItem();
                //bool NoPriorSelection = _todoRecordsListBox.SelectedIndex == -1;
                //_recordListBoxActive = true; // allow onRecordSelectionChanged
                if (FocusWasOnFindTextBox && !string.IsNullOrEmpty(SearchTextBox.Text) &&
                    IsWritingSystemUsedInLexicalForm(_listWritingSystem.Id))
                {
                    entry.LexicalForm[_listWritingSystem.Id] = SearchTextBox.Text.Trim();
                    _lexEntryRepository.SaveItem(entry);
                }
                //review: Revert (remove) below for WS-950
                // _lexEntryRepository.SaveItem(entry);
                LoadRecords();
                selectIndex = _records.FindFirstIndex(entry);
            }
            else
            {
                selectIndex = emptyWordIndex;
            }

            if (!_btnNewWord.Focused)
            {
                // if we use a hot key, it may not have received the focus
                // but we assume it has the focus when we do our selection change event
                _btnNewWord.Focus();
            }
            Debug.Assert(selectIndex != -1);
            _recordsListBox.SelectedIndex = selectIndex;

            UpdateListViewIfGecko();
            //_entryViewControl.Focus();
            _entryViewControl.SelectOnCorrectControl();

            _logger.WriteConciseHistoricalEvent("Added Word");
        }
Exemplo n.º 17
0
        private void SetupTestData()
        {
            Palaso.Reporting.ErrorReport.IsOkToInteractWithUser = false;
            _tempFolder = new TemporaryFolder();
            _filePath   = _tempFolder.GetTemporaryFile();

            _currentItem = null;
            string lexicalForm        = "test";
            string definition         = "definition";
            string exampleSentence    = "Test sentence";
            string exampleTranslation = "Translated sentence";

            _lexEntryRepository = (LexEntryRepository)
                                  WeSayWordsProject.Project.ServiceLocator.GetService(typeof(LexEntryRepository));
            _viewTemplate = (ViewTemplate)
                            WeSayWordsProject.Project.ServiceLocator.GetService(typeof(ViewTemplate));

            List <String> headwordWritingSystemIds = new List <string>(_viewTemplate.GetHeadwordWritingSystemIds());
            string        wsA = headwordWritingSystemIds[0];
            string        wsB = _viewTemplate.GetDefaultWritingSystemForField(definition).Id;

            HtmlRenderer.HeadWordWritingSystemId = _viewTemplate.HeadwordWritingSystem.Id;

            _entry = _lexEntryRepository.CreateItem();
            _entry.LexicalForm[wsA] = lexicalForm;
            LexSense sense = new LexSense();

            sense.Definition[wsB] = definition;
            LexExampleSentence example = new LexExampleSentence();

            example.Sentence[wsA]    = exampleSentence;
            example.Translation[wsB] = exampleTranslation;
            sense.ExampleSentences.Add(example);
            _entry.Senses.Add(sense);
            empty        = CreateTestEntry("", "", "");
            apple        = CreateTestEntry("apple", "red thing", "An apple a day keeps the doctor away.");
            anotherApple = CreateTestEntry("apple", "fruit", "An apple a day keeps the doctor away.");
            banana       = CreateTestEntry("banana", "yellow food", "Monkeys like to eat bananas.");
            car          = CreateTestEntry("car",
                                           "small motorized vehicle",
                                           "Watch out for cars when you cross the street.");
            bike = CreateTestEntry("bike", "vehicle with two wheels", "He rides his bike to school.");
        }
Exemplo n.º 18
0
		public void Setup()
		{
			_tempFolder = new TemporaryFolder();
			_filePath = _tempFolder.GetTemporaryFile();
			_lexEntryRepository = new LexEntryRepository(_filePath);

			Form window = new Form();
			window.Size = new Size(800, 600);

			_lexEntryRepository.CreateItem();

			Dash dash = new Dash(_lexEntryRepository, null);//, new UserSettingsForTask());
			dash.ThingsToMakeButtonsFor = GetButtonItems();
			dash.Dock = DockStyle.Fill;
			window.Controls.Add(dash);
			window.BackColor = dash.BackColor;
			dash.Activate();
			Application.Run(window);
		}
Exemplo n.º 19
0
        private LexEntry CreateTestEntry(string lexicalForm, string meaning, string exampleSentence)
        {
            LexEntry entry = _lexEntryRepository.CreateItem();

            entry.LexicalForm[GetSomeValidWsIdForField("EntryLexicalForm")] = lexicalForm;
            LexSense sense = new LexSense();

            entry.Senses.Add(sense);
#if GlossMeaning
            sense.Gloss[GetSomeValidWsIdForField("SenseGloss")] = meaning;
#else
            sense.Definition[WritingSystemsIdsForTests.AnalysisIdForTest] = meaning;
#endif
            LexExampleSentence example = new LexExampleSentence();
            sense.ExampleSentences.Add(example);
            example.Sentence[GetSomeValidWsIdForField("ExampleSentence")] = exampleSentence;
            _lexEntryRepository.SaveItem(entry);
            return(entry);
        }
Exemplo n.º 20
0
        public void GetAllEntriesSortedByHeadWord_CreateItemAfterFirstCall_EntryIsReturnedAndSortedInResultSet()
        {
            LexEntry entryBeforeFirstQuery = CreateEntryWithLexicalFormBeforeFirstQuery("de", "word 1");

            _repository.GetAllEntriesSortedByHeadword(WritingSystemDefinition.Parse("de"));

            LexEntry entryAfterFirstQuery = _repository.CreateItem();

            ResultSet <LexEntry> results = _repository.GetAllEntriesSortedByHeadword(WritingSystemDefinition.Parse("de"));

            Assert.AreEqual(2, results.Count);
            Assert.AreEqual(null, results[0]["Form"]);
            Assert.AreEqual("word 1", results[1]["Form"]);
        }
Exemplo n.º 21
0
        public void Setup()
        {
            _tempFolder         = new TemporaryFolder();
            _filePath           = _tempFolder.GetTemporaryFile();
            _lexEntryRepository = new LexEntryRepository(_filePath);

            Form window = new Form();

            window.Size = new Size(800, 600);

            _lexEntryRepository.CreateItem();

            Dash dash = new Dash(_lexEntryRepository, null);            //, new UserSettingsForTask());

            dash.ThingsToMakeButtonsFor = GetButtonItems();
            dash.Dock = DockStyle.Fill;
            window.Controls.Add(dash);
            window.BackColor = dash.BackColor;
            dash.Activate();
            Application.Run(window);
        }
Exemplo n.º 22
0
        private LexEntry CreateTestEntry(string lexicalForm, string meaning, string exampleSentence)
        {
            List <String> headwordWritingSystemIds = new List <string>(_viewTemplate.GetHeadwordWritingSystemIds());
            string        wsA   = headwordWritingSystemIds[0];
            string        wsB   = _viewTemplate.GetDefaultWritingSystemForField("definition").Id;
            LexEntry      entry = _lexEntryRepository.CreateItem();

            entry.LexicalForm[wsA] = lexicalForm;
            LexSense sense = new LexSense();

#if GlossMeaning
            sense.Gloss[GetSomeValidWsIdForField("SenseGloss")] = meaning;
#else
            sense.Definition[wsB] = meaning;
#endif
            LexExampleSentence example = new LexExampleSentence();
            example.Sentence[wsA] = exampleSentence;
            sense.ExampleSentences.Add(example);
            entry.Senses.Add(sense);
            _lexEntryRepository.SaveItem(entry);
            return(entry);
        }
Exemplo n.º 23
0
        private LexEntry CreateNewLexEntry(CreateNewArgs e)
        {
            LexEntry newGuy = _lexEntryRepository.CreateItem();
            // If we're creating from a previously deleted word, omit the guid part of the stored label.
            // See https://jira.sil.org/browse/WS-96 for a picture of what could happen otherwise.
            // Also restore the guid in case this form was referred to more than once.
            string word = e.LabelOfNewItem;
            Match  m    = Regex.Match(e.LabelOfNewItem, "_[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}");

            if (m.Success)
            {
                word        = e.LabelOfNewItem.Substring(0, m.Index);
                newGuy.Guid = new Guid(m.Value.Substring(1));
            }
            newGuy.LexicalForm.SetAlternative(_field.WritingSystemIds[0], word);
            //hack: if something is a baseform itself, it isn't likely to have its own baseform
            //This satisfies Rene's request of WS-419
            if (_field.FieldName == "BaseForm")
            {
                newGuy.SetFlag(LexEntry.WellKnownProperties.FlagSkipBaseform);
            }
            return(newGuy);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Try to add the sense to a matching entry. If none found, make a new entry with the sense
        /// </summary>
        private void AddSenseToLexicon(MultiTextBase lexemeForm, LexSense sense)
        {
            //remove from the gloss and def any forms we don't want in our project for those fields
            foreach (var form in sense.Gloss.Forms)
            {
                //why are we checking definition writing system here? Well, the whole gloss/def thing continues to be murky. When gathering, we're just
                //trying to populate both.  And if you have your 1st def be, say, french, and don't have that in your glosses, well
                // in the WordList task, you won't see the words you gathered, because that's based on glosses!
                if (!_glossWritingSystemIds.Contains(form.WritingSystemId) && !_definitionWritingSystemIds.Contains(form.WritingSystemId))
                {
                    sense.Gloss.SetAlternative(form.WritingSystemId, null);
                }
            }
            foreach (var form in sense.Definition.Forms)
            {
                if (!_definitionWritingSystemIds.Contains(form.WritingSystemId) && !_glossWritingSystemIds.Contains(form.WritingSystemId))
                {
                    sense.Definition.SetAlternative(form.WritingSystemId, null);
                }
            }

            //I don't recall why we did this, but what it is doing is populating def from gloss and vice-versa, where there are blanks

            /* var definition = sense.Definition;
             * if(definition.Empty)
             * {
             *      foreach (var form in sense.Gloss.Forms)
             *      {
             *              //this check makes sure we don't introduce a form form a lang we allow for gloss, but not def
             *              if (_definitionWritingSystemIds.Contains(form.WritingSystemId))
             *                      definition.SetAlternative(form.WritingSystemId, form.Form);
             *      }
             * }
             *
             * var gloss = sense.Gloss;
             * if (gloss.Empty)
             * {
             *      foreach (var form in sense.Definition.Forms)
             *      {
             *              //this check makes sure we don't introduce a form form a lang we allow for def, but not gloss
             *              if (_glossWritingSystemIds.Contains(form.WritingSystemId))
             *                      gloss.SetAlternative(form.WritingSystemId, form.Form);
             *      }
             * } */

            //review: the desired semantics of this find are unclear, if we have more than one ws
            ResultSet <LexEntry> entriesWithSameForm =
                LexEntryRepository.GetEntriesWithMatchingLexicalForm(
                    lexemeForm[_lexicalUnitWritingSystem.Id], _lexicalUnitWritingSystem);
            var          meaningField = _glossMeaningField ? sense.Gloss : sense.Definition;
            LanguageForm firstMeaning = new LanguageForm("en", "-none-", null);

            if (meaningField.Forms.Length > 0)
            {
                firstMeaning = meaningField.Forms[0];
            }

            if (entriesWithSameForm.Count == 0)
            {
                LexEntry entry = LexEntryRepository.CreateItem();
                entry.LexicalForm.MergeIn(lexemeForm);
                entry.Senses.Add(sense.Clone());
                LexEntryRepository.SaveItem(entry);
                Logger.WriteEvent("WordList-Adding new word '{0}'and giving the sense '{1}'", entry.GetSimpleFormForLogging(), firstMeaning);
            }
            else
            {
                LexEntry entry = entriesWithSameForm[0].RealObject;

                foreach (LexSense s in entry.Senses)
                {
                    if (meaningField.Forms.Length > 0)
                    {
                        LanguageForm meaningWeAreAdding         = firstMeaning;
                        string       meaningInThisWritingSystem = _glossMeaningField ?
                                                                  s.Gloss.GetExactAlternative(meaningWeAreAdding.WritingSystemId) :
                                                                  s.Definition.GetExactAlternative(meaningWeAreAdding.WritingSystemId);
                        if (meaningInThisWritingSystem == meaningWeAreAdding.Form)
                        {
                            Logger.WriteEvent("WordList '{0}' already exists in '{1}'", firstMeaning, entry.GetSimpleFormForLogging());
                            return;                             //don't add it again
                        }
                    }
                }
                if (sense.Gloss.Forms.Length == 0 && sense.Definition.Forms.Length == 0 && sense.ExampleSentences.Count == 0)
                {
                    return;                    //nothing worth adding (may happen in unit test)
                }
                entry.Senses.Add(sense);

                //REVIEW: June 2011, Hatton added this, because of WS-34024: if a new *meaning* was added to an existing entry,
                //and then the user quit, this change was unsaved.
                LexEntryRepository.SaveItem(entry);
                Logger.WriteEvent("WordList-Added '{0}' to preexisting '{1}'", firstMeaning, entry.GetSimpleFormForLogging());
            }
        }