/// <summary>
		/// Helper
		/// </summary>
		private LexEntryComponents SetupComponentsForEntryCreation(out int germanWsId,
			out ILexEntryFactory lexFactory, out ITsString tssGermanGloss)
		{
			germanWsId = Cache.WritingSystemFactory.GetWsFromStr("de");
			Cache.LangProject.AnalysisWritingSystems.Add(
				Cache.WritingSystemFactory.get_EngineOrNull(germanWsId) as IWritingSystem);
			lexFactory = Cache.ServiceLocator.GetInstance<ILexEntryFactory>();
			tssGermanGloss = Cache.TsStrFactory.MakeString("da", germanWsId);
			var tssVernacForm = Cache.TsStrFactory.MakeString("bunk",
				Cache.WritingSystemFactory.GetWsFromStr(Cache.LangProject.DefaultVernacularWritingSystem.Id));
			var msa = new SandboxGenericMSA
			{
				MainPOS = Cache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Where(
					pos => pos.Name.AnalysisDefaultWritingSystem.Text == "noun")
					.Cast<IPartOfSpeech>()
					.FirstOrDefault(),
				MsaType = MsaType.kStem
			};

			var lexEntryComponents = new LexEntryComponents()
			{
				GlossAlternatives = new List<ITsString>() { tssGermanGloss },
				LexemeFormAlternatives = new List<ITsString>() { tssVernacForm },
				MSA = msa,
				MorphType = Cache.LangProject.LexDbOA.MorphTypesOA.PossibilitiesOS.Where(
					mt => mt.Name.AnalysisDefaultWritingSystem.Text == "stem")
					.Cast<IMoMorphType>()
					.FirstOrDefault()
			};
			return lexEntryComponents;
		}
		private ILexEntry CreateSimpleEntry(string form, string gloss)
		{
			var lexAlt = TsStringUtils.MakeTss(form, m_wsVern);
			var glossAlt = TsStringUtils.MakeTss(gloss, m_wsAnalysis);
			var msa = new SandboxGenericMSA { MainPOS = m_noun, MsaType = MsaType.kStem };
			var leComp = new LexEntryComponents { MSA = msa, MorphType = m_stem };
			leComp.GlossAlternatives.Add(glossAlt);
			leComp.LexemeFormAlternatives.Add(lexAlt);
			var entry = m_leFact.Create(leComp);
			return entry;
		}
Ejemplo n.º 3
0
        /// <summary>
        /// Initialize a new LexEntryComponents computing MorphType and LexFormAlternatives[0] from formWithMarkers
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="formWithMarkers"></param>
        /// <returns></returns>
        public static LexEntryComponents BuildEntryComponents(LcmCache cache, ITsString formWithMarkers)
        {
            var morphComponents = BuildMorphComponents(cache, formWithMarkers, MoMorphTypeTags.kguidMorphStem);
            var entryComponents = new LexEntryComponents {
                MorphType = morphComponents.MorphType
            };

            if (morphComponents.TssForm != null)
            {
                entryComponents.LexemeFormAlternatives.Add(morphComponents.TssForm);
            }
            return(entryComponents);
        }
Ejemplo n.º 4
0
        protected ILexEntry AddLexeme(List <ICmObject> addList, string lexForm, IMoMorphType morphTypePoss,
                                      string gloss, IPartOfSpeech categoryPoss)
        {
            var msa = new SandboxGenericMSA {
                MainPOS = categoryPoss
            };
            var comp = new LexEntryComponents {
                MorphType = morphTypePoss, MSA = msa
            };

            comp.GlossAlternatives.Add(m_tssFact.MakeString(gloss, Cache.DefaultAnalWs));
            comp.LexemeFormAlternatives.Add(m_tssFact.MakeString(lexForm, Cache.DefaultVernWs));
            var entry = m_entryFact.Create(comp);

            addList.Add(entry);
            return(entry);
        }
Ejemplo n.º 5
0
        private ILexEntry CreateSimpleEntry(string form, string gloss)
        {
            var lexAlt   = TsStringUtils.MakeString(form, m_wsVern);
            var glossAlt = TsStringUtils.MakeString(gloss, m_wsAnalysis);
            var msa      = new SandboxGenericMSA {
                MainPOS = m_noun, MsaType = MsaType.kStem
            };
            var leComp = new LexEntryComponents {
                MSA = msa, MorphType = m_stem
            };

            leComp.GlossAlternatives.Add(glossAlt);
            leComp.LexemeFormAlternatives.Add(lexAlt);
            var entry = m_leFact.Create(leComp);

            return(entry);
        }
Ejemplo n.º 6
0
        protected ILexEntry AddVariantLexeme(List <ICmObject> addList, IVariantComponentLexeme origLe,
                                             string lexForm, IMoMorphType morphTypePoss, string gloss, IPartOfSpeech categoryPoss,
                                             ILexEntryType varType)
        {
            Assert.IsNotNull(varType, "Need a variant entry type!");
            var msa = new SandboxGenericMSA {
                MainPOS = categoryPoss
            };
            var comp = new LexEntryComponents {
                MorphType = morphTypePoss, MSA = msa
            };

            comp.GlossAlternatives.Add(m_tssFact.MakeString(gloss, Cache.DefaultAnalWs));
            comp.LexemeFormAlternatives.Add(m_tssFact.MakeString(lexForm, Cache.DefaultVernWs));
            var entry = m_entryFact.Create(comp);

            entry.MakeVariantOf(origLe, varType);
            addList.Add(entry);
            return(entry);
        }
        /// <summary>
        /// Helper
        /// </summary>
        private LexEntryComponents SetupComponentsForEntryCreation(out int germanWsId,
                                                                   out ILexEntryFactory lexFactory, out ITsString tssGermanGloss)
        {
            germanWsId = Cache.WritingSystemFactory.GetWsFromStr("de");
            Cache.LangProject.AnalysisWritingSystems.Add(
                Cache.WritingSystemFactory.get_EngineOrNull(germanWsId) as IWritingSystem);
            lexFactory     = Cache.ServiceLocator.GetInstance <ILexEntryFactory>();
            tssGermanGloss = Cache.TsStrFactory.MakeString("da", germanWsId);
            var tssVernacForm = Cache.TsStrFactory.MakeString("bunk",
                                                              Cache.WritingSystemFactory.GetWsFromStr(Cache.LangProject.DefaultVernacularWritingSystem.Id));
            var msa = new SandboxGenericMSA
            {
                MainPOS = Cache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Where(
                    pos => pos.Name.AnalysisDefaultWritingSystem.Text == "noun")
                          .Cast <IPartOfSpeech>()
                          .FirstOrDefault(),
                MsaType = MsaType.kStem
            };

            var lexEntryComponents = new LexEntryComponents()
            {
                GlossAlternatives = new List <ITsString>()
                {
                    tssGermanGloss
                },
                LexemeFormAlternatives = new List <ITsString>()
                {
                    tssVernacForm
                },
                MSA       = msa,
                MorphType = Cache.LangProject.LexDbOA.MorphTypesOA.PossibilitiesOS.Where(
                    mt => mt.Name.AnalysisDefaultWritingSystem.Text == "stem")
                            .Cast <IMoMorphType>()
                            .FirstOrDefault()
            };

            return(lexEntryComponents);
        }
Ejemplo n.º 8
0
		/// <summary>
		///
		/// </summary>
		/// <param name="entryComponents"></param>
		/// <returns></returns>
		public ILexEntry Create(LexEntryComponents entryComponents)
		{
			if (entryComponents.MorphType == null)
				throw new ArgumentException("Expected entryComponents to already have MorphType");
			var tssGloss =
				entryComponents.GlossAlternatives.DefaultIfEmpty(TsStringUtils.MakeTss("", m_cache.DefaultAnalWs)).
					FirstOrDefault();
			ILexEntry newEntry = Create(entryComponents.MorphType,
				entryComponents.LexemeFormAlternatives[0],
				tssGloss,
				entryComponents.MSA);

			foreach (ITsString tss in entryComponents.LexemeFormAlternatives)
				newEntry.SetLexemeFormAlt(TsStringUtils.GetWsAtOffset(tss, 0), tss);

			foreach (ITsString tss in entryComponents.GlossAlternatives)
				newEntry.SensesOS[0].Gloss.set_String(TsStringUtils.GetWsAtOffset(tss, 0), tss);

			var featsys = m_cache.LanguageProject.MsFeatureSystemOA;
			foreach (XmlNode xn in entryComponents.GlossFeatures)
			{
				featsys.AddFeatureFromXml(xn);
				foreach (var msa in newEntry.MorphoSyntaxAnalysesOC)
				{
					var infl = msa as IMoInflAffMsa;
					if (infl != null)
					{
						if (infl.InflFeatsOA == null)
							infl.InflFeatsOA = m_cache.ServiceLocator.GetInstance<IFsFeatStrucFactory>().Create();

						infl.InflFeatsOA.AddFeatureFromXml(xn, featsys);
						// if there is a POS, add features to topmost pos' inflectable features
						var pos = infl.PartOfSpeechRA;
						if (pos != null)
						{
							var topPos = pos.HighestPartOfSpeech;
							topPos.AddInflectableFeatsFromXml(xn);
						}
					}
				}
			}
			return newEntry;
		}
Ejemplo n.º 9
0
		private LexEntryComponents BuildEntryComponentsDTO()
		{
			var entryComponents = new LexEntryComponents();
			entryComponents.MorphType = m_morphType;
			CollectValuesFromMultiStringControl(msLexicalForm, entryComponents.LexemeFormAlternatives, BestTssForm);
			CollectValuesFromMultiStringControl(msGloss, entryComponents.GlossAlternatives,
				TsStringUtils.MakeTss(Gloss, m_cache.DefaultAnalWs));
			entryComponents.MSA = m_msaGroupBox.SandboxMSA;
			if (m_MGAGlossListBoxItems != null)
			{
				foreach (GlossListBoxItem xn in m_MGAGlossListBoxItems)
					entryComponents.GlossFeatures.Add(xn.XmlNode);
			}
			return entryComponents;
		}