Exemple #1
0
    AudioClip GetClipByStem(Stem stem, out int index)
    {
        switch (stem)
        {
        case Stem.A:
            index = Random.Range(0, clipsA.Length);
            return(clipsA[index]);

        case Stem.B:
            index = Random.Range(0, clipsB.Length);
            return(clipsB[index]);

        case Stem.C:
            index = Random.Range(0, clipsC.Length);
            return(clipsC[index]);

        case Stem.D:
            index = Random.Range(0, clipsD.Length);
            return(clipsD[index]);

        case Stem.E:
            index = Random.Range(0, clipsE.Length);
            return(clipsE[index]);

        case Stem.F:
            index = Random.Range(0, clipsF.Length);
            return(clipsF[index]);

        default:
            index = -1;
            return(null);
        }
    }
Exemple #2
0
        public async Task <ActionResult <Stem> > PostStem(Stem stem)
        {
            _context.Stemmen.Add(stem);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetStem", new { id = stem.StemId }, stem));
        }
Exemple #3
0
    void QueueFromB(out Stem newStem, out AudioClip newClip)
    {
        int   index;
        float rand = Random.value;

        if (rand < .25f)
        {
            newStem = Stem.A;
            newClip = GetClipByStem(newStem, out index);
        }
        else if (rand < .75f)
        {
            newStem = Stem.B;
            newClip = GetClipByStem(newStem, out index);
            if (newClip == lastClip)
            {
                index   = (index + 1) % clipsB.Length;
                newClip = clipsB[index];
            }
        }
        else
        {
            newStem = Stem.C;
            newClip = GetClipByStem(newStem, out index);
        }
    }
Exemple #4
0
 internal AdjectiveForm(Stem stem, Gender gender, Case @case, Number number, string suffix)
     : base(stem, suffix)
 {
     Gender = gender;
     Case = @case;
     Number = number;
 }
Exemple #5
0
        public async Task <ActionResult <Stem> > PostStem(Stem stem)
        {
            _context.Stemmen.Add(stem);
            await _context.SaveChangesAsync();

            return(Ok());
        }
Exemple #6
0
        public async Task <IActionResult> PutStem(long id, Stem stem)
        {
            if (id != stem.StemId)
            {
                return(BadRequest());
            }

            _context.Entry(stem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #7
0
        public void UpdateRecord(IBaseWindow baseWin, GDMRecord record)
        {
            if (baseWin == null)
            {
                throw new ArgumentNullException("baseWin");
            }

            if (record == null || !IsIndexedRecord(record))
            {
                return;
            }

            try
            {
                lock (fLock)
                {
                    using (WritableDatabase database = new WritableDatabase(GetXDBFolder(), Xapian.Xapian.DB_CREATE_OR_OPEN))
                        using (TermGenerator indexer = new TermGenerator())
                            using (Stem stemmer = new Stem("russian"))
                            {
                                indexer.SetStemmer(stemmer);

                                ReindexRecord(baseWin, database, indexer, record);
                                SetDBLastChange(baseWin, database);
                            }
                }
            }
            catch (Exception ex)
            {
                Logger.LogWrite("SearchManager.UpdateRecord(): " + ex.Message);
            }
        }
        public async Task <IActionResult> PutStem([FromRoute] int id, [FromBody] Stem stem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != stem.StemID)
            {
                return(BadRequest());
            }

            _context.Entry(stem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #9
0
    void QueueFromF(out Stem newStem, out AudioClip newClip)
    {
        int index;

        newStem = Stem.A;
        newClip = GetClipByStem(newStem, out index);
    }
Exemple #10
0
    // Creates a new stem segment with this stem as its parent
    public Stem AddStemSegment(int age, float pitch, float yaw, float roll)
    {
        Stem stemClone = Instantiate <Stem>(stemPrefab, transform.position, transform.rotation);

        stemClone.Init(this.transform, transform.GetChild(0).localScale.y * 2, stemPrefab, age, pitch, yaw, roll);
        return(stemClone);
    }
        public IHttpActionResult stemAntwoord(ANDROIDstem aStem)
        {
            Antwoord antwoord = antwoordManager.readAllAntwoorden().Find(o => o.ID == aStem.antwoordid);

            foreach (var stem in antwoord.stemmen)
            {
                if (stem.gebruikersNaam == aStem.gebruikersNaam)
                {
                    return(Ok("nok"));
                }
                else
                {
                    break;
                }
            }

            Stem stemAntwoord = new Stem()
            {
                antwoord       = antwoordManager.readAntwoord(aStem.antwoordid),
                gebruikersNaam = aStem.gebruikersNaam
            };

            stemManager.stemOpAntwoord(stemAntwoord);
            return(Ok("ok"));
        }
        public IFieldReader <TItem> Get(Stem <TItem> stem)
        {
            var substemCreator = new SubstemEngineSubContextCreator <TItem, TNav, TSubstem>(stem);
            StemsEngineSubContext <TNav> subContext = substemCreator.GetEngineContext();

            return(new SubCollectionFieldReader <TItem, TCollection, TNav>(_navigationExpression, subContext));
        }
Exemple #13
0
    // Use this for initialization
    void Start()
    {
        List <Variable> vars = new List <Variable>();

        vars.Add(new Variable('S', branchTime));
        vars.Add(new Variable('X', branchTime));
        vars.Add(new Variable('F', maxStemAge));

        RuleSet rules   = new RuleSet();
        Symbol  maxSSym = new Symbol('S', branchTime);
        Symbol  maxXSym = new Symbol('X', branchTime);

        rules.AddRule(maxSSym, 0.3f, new SymbolString("[@[@/@/@+@FAXA]@\\@+@FAXA]@\\@-@FAXA"));
        rules.AddRule(maxSSym, 0.3f, new SymbolString("[@\\@+@FAXA]@\\@-@FAXA"));
        rules.AddRule(maxSSym, 0.2f, new SymbolString("FAXA"));

        rules.AddRule(maxXSym, 0.16f, new SymbolString("[@[@\\@\\@+@FAXA]@/@+@FAXA]@/@-@FAXA"));
        rules.AddRule(maxXSym, 0.16f, new SymbolString("[@[@/@/@+@FAXA]@\\@+@FAXA]@\\@-@FAXA"));
        rules.AddRule(maxXSym, 0.32f, new SymbolString("[@\\@+@FAXA]@\\@-@FAXA"));
        rules.AddRule(maxXSym, 0.32f, new SymbolString("[@/@+@FAXA]@/@-@FAXA"));
        rules.AddRule(maxXSym, 0.03f, new SymbolString("\\@-@FAXA"));
        rules.AddRule(maxXSym, 0.03f, new SymbolString("/@-@FAXA"));

        this.lSystem = new LSystem(vars, new Symbol('S', 10), rules, yaw, pitch, roll, numIterations);
        if (root == null)
        {
            root     = Instantiate <Stem>(stemPrefab, transform.position, transform.rotation);
            root.age = 1;
        }
    }
Exemple #14
0
        /// <summary>
        /// Gets the stem identifier.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="category">The category.</param>
        /// <param name="sense">The sense.</param>
        /// <returns>System.Nullable&lt;System.Guid&gt;.</returns>
        private Guid?GetStemId(string text, string category, string sense = "")
        {
            Guid?    id   = null;
            Stem     stem = null;
            Category cat  = string.IsNullOrWhiteSpace(category) ? Category.None : category.ParseTag();

            if (string.IsNullOrWhiteSpace(sense))
            {
                stem = _referenceStems.FirstOrDefault(s => s.Form == text & s.Category == cat);
            }
            else
            {
                stem = _referenceStems.FirstOrDefault(s => s.Form == text & s.Category == cat & s.Sense == sense);
            }

            if (!(stem is null))
            {
                id = stem.Id;
            }

            if (id is null)
            {
                DebugHelper.Warning($"Could not find matching stem ('{text}', '{category}', '{sense}'). ID still null; OK.");
            }

            return(id);
        }
        /// <summary>
        ///     Search for the longest among the following suffixes, and perform the action indicated.
        ///     eed   eedly+
        ///     replace by ee if in R1
        ///     ed   edly+   ing   ingly+
        ///     delete if the preceding word part contains a vowel, and then
        ///     if the word ends at, bl or iz add e (so luxuriat -> luxuriate), or
        ///     if the word ends with a double remove the last letter (so hopp -> hop), or
        ///     if the word is short, add e (so hop -> hope)
        /// </summary>
        internal void StripSuffixStep1b()
        {
            // eed   eedly+ - replace by ee if in R1
            if (Stem.EndsWith("eed") ||
                Stem.EndsWith("eedly"))
            {
                if (EndsWithAndInR1("eed") ||
                    EndsWithAndInR1("eedly"))
                {
                    if (_r1.Contains(Stem.Length))
                    {
                        Stem = Stem.Substring(0, Stem.LastIndexOf("eed")) + "ee";
                    }
                }
                return;
            }

            // ed   edly+   ing   ingly+ - delete if the preceding word part contains a vowel, and then
            if ((Stem.EndsWith("ed") && Stem.IndexOfAny(Vowels, 0, Stem.Length - 2) != -1) ||
                (Stem.EndsWith("edly") && Stem.IndexOfAny(Vowels, 0, Stem.Length - 4) != -1) ||
                (Stem.EndsWith("ing") && Stem.IndexOfAny(Vowels, 0, Stem.Length - 3) != -1) ||
                (Stem.EndsWith("ingly") && Stem.IndexOfAny(Vowels, 0, Stem.Length - 5) != -1))
            {
                StripEnding(new string[4] {
                    "ed", "edly", "ing", "ingly"
                });
                // if the word ends at, bl or iz add e (so luxuriat -> luxuriate), or
                if (Stem.EndsWith("at") ||
                    Stem.EndsWith("bl") ||
                    Stem.EndsWith("iz"))
                {
                    Stem += "e";
                    return;
                }
                // if the word ends with a double remove the last letter (so hopp -> hop), or
                string end2chars;
                if (Stem.Length >= 2)
                {
                    end2chars = Stem.Substring(Stem.Length - 2, 2);
                }
                else
                {
                    return;
                }

                var doubleEndings = new List <string>(DoubleChars);
                if (doubleEndings.Contains(end2chars))
                {
                    Stem = Stem.Remove(Stem.Length - 1);
                    return;
                }
                // if the word is short, add e (so hop -> hope)
                if (IsShortWord())
                {
                    Stem += "e";
                    return;
                }
            }
        }
Exemple #16
0
        internal void GenerateStem()
        {
            if (IsException1())
            {
                return;
            }
            //If the word has two letters or less, leave it as it is.
            if (Stem.Length < 3)
            {
                return;
            }

            //Remove initial ', if present. +
            StandardiseApostrophesAndStripLeading();

            //Set initial y, or y after a vowel, to Y
            MarkYs();

            //establish the regions R1 and R2. (See note on vowel marking.)
            if (Stem.StartsWith("gener") ||
                Stem.StartsWith("arsen"))
            {
                _r1 = CalculateR(Stem, 2);
            }
            else if (Stem.StartsWith("commun"))
            {
                _r1 = CalculateR(Stem, 3);
            }
            else
            {
                _r1 = CalculateR(Stem, 0);
            }
            _r2 = CalculateR(Stem, _r1.Start);

            //Step0
            StripTrailingApostrophe();
            //Step1a
            StripSuffixStep1a();

            if (IsException2())
            {
                return;
            }

            //Step1b
            StripSuffixStep1b();
            //Step 1c: *
            ReplaceSuffixStep1c();
            //Step2
            ReplaceEndingStep2();
            //Step3
            ReplaceEndingStep3();
            //Step4
            StripSuffixStep4();
            //Step5
            StripSuffixStep5();
            //Finally, turn any remaining Y letters in the word back into lower case.
            Finally();
        }
Exemple #17
0
    void Awake()
    {
        stem             = GetComponent <Stem>();
        growthController = GetComponentInChildren <GrowthController>();
        objectAimer2D    = GetComponentInChildren <ObjectAimer2D>();

        lastHeadPosition = transform.position;
    }
        public async Task <ActionResult <Stem> > PostStem(Stem stem)
        {
            _context.Stemmen.Add(stem);
            await _context.SaveChangesAsync();

            return(RedirectToAction("GetStemmenByAntwoord", "StemController", new { id = stem.AntwoordID }));
            //return CreatedAtAction("GetStem", new { id = stem.StemID }, stem);
        }
Exemple #19
0
        public List <SearchEntry> Search(IBaseWindow baseWin, string searchText)
        {
            if (baseWin == null)
            {
                throw new ArgumentNullException("baseWin");
            }

            const uint flags = (uint)(QueryParser.feature_flag.FLAG_PARTIAL | QueryParser.feature_flag.FLAG_WILDCARD |
                                      QueryParser.feature_flag.FLAG_PHRASE | QueryParser.feature_flag.FLAG_BOOLEAN |
                                      QueryParser.feature_flag.FLAG_LOVEHATE);

            List <SearchEntry> res = new List <SearchEntry>();

            try {
                lock (fLock) {
                    using (Database database = new Database(GetXDBFolder()))
                        using (Enquire enquire = new Enquire(database))
                            using (Stem stemmer = new Stem("russian"))
                                using (QueryParser qp = new QueryParser()) {
                                    qp.SetStemmer(stemmer);
                                    qp.SetDatabase(database);
                                    qp.SetDefaultOp(Query.op.OP_AND);
                                    qp.SetStemmingStrategy(QueryParser.stem_strategy.STEM_SOME);

                                    string qs = searchText + " ged:" + GetSign(baseWin);
                                    qp.AddBooleanPrefix("ged", "GDB");

                                    using (Query query = qp.ParseQuery(qs, flags)) {
                                        enquire.SetQuery(query);

                                        using (MSet matches = enquire.GetMSet(0, 100)) {
                                            MSetIterator m = matches.Begin();
                                            while (m != matches.End())
                                            {
                                                try {
                                                    using (Document mDoc = m.GetDocument()) {
                                                        SearchEntry entry = new SearchEntry();
                                                        entry.XRef    = mDoc.GetData();
                                                        entry.Rank    = m.GetRank() + 1;
                                                        entry.Percent = m.GetPercent();
                                                        res.Add(entry);
                                                    }
                                                } catch (Exception ex) {
                                                    Logger.WriteError("SearchManager.Search()", ex);
                                                }

                                                m = m.Next();
                                            }
                                        }
                                    }
                                }
                }
            } catch (Exception ex) {
                Logger.WriteError("SearchManager.Search()", ex);
            }

            return(res);
        }
        public SubstemEngineSubContextCreator(Stem <TItem> stem)
        {
            _stem = stem;

            var autoActivator = new AutoActivator(_stem.Services.DependencyResolver);

            _substem = autoActivator.CreateInstance <TSubstem>();
            _substem.SetParent(_stem);
        }
        public async Task <ActionResult <Stem> > PostStem(Stem stem)
        {
            stem.Gebruiker = _context.Gebruikers.Find(stem.Gebruiker.GebruikerID);
            stem.Item      = _context.Items.Find(stem.Item.ItemID);
            _context.Stemmen.Add(stem);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetStem", new { id = stem.StemID }, stem));
        }
Exemple #22
0
 private bool IsValidLIEnding()
 {
     if (Stem.Length > 2)
     {
         string preLi = Stem.Substring(Stem.Length - 3, 1);
         return(ValidLIEnding.Contains(preLi));
     }
     return(false);
 }
Exemple #23
0
 // Initializes the Stem segment
 void Init(Transform parentTransform, float offset, Stem stemPrefab, int age, float pitch, float yaw, float roll)
 {
     this.stemPrefab = stemPrefab;
     this.pitch      = pitch;
     this.yaw        = yaw;
     this.roll       = roll;
     this.age        = age;
     transform.SetParent(parentTransform);
     UpdateStemTransforms(offset);
 }
        public StemsEngineSubContext([NotNull] Stem <TItem> stem)
        {
            var implementations = stem.Services.ServiceGroup
                                  .GetProvider(stem.GetType())
                                  .GetService <EngineImplementations <TItem> >();

            Identifiers          = new AttributeIdentifierProvider <TItem>(stem, implementations);
            Fields               = new AttributeFieldProvider <TItem>(stem, implementations);
            AuthorizationChecker = new StemAuthorizationChecker <TItem>(stem, implementations);
        }
Exemple #25
0
 internal VerbForm(Stem stem, Conjugation conjugation, Person person, Number number, Mood mood, Voice voice, Tense tense, string suffix)
     : base(stem, suffix)
 {
     Conjugation = conjugation;
     Person = person;
     Number = number;
     Mood = mood;
     Voice = voice;
     Tense = tense;
 }
Exemple #26
0
 /// <summary>
 /// Converts all quote variants `’ " to standard '. Removes an open quote in First char
 /// </summary>
 internal void StandardiseApostrophesAndStripLeading()
 {
     //Make Apostrophes consistent
     Stem = Stem.Replace('’', '\'').Replace('`', '\'').Replace('"', '\'');
     //Remove initial ', if present.
     if (Stem[0] == '\'')
     {
         Stem = Stem.Remove(0, 1);
     }
 }
Exemple #27
0
 /// <summary>
 /// replace suffix y or Y by i if preceded by a non-vowel which is not the first letter of the word (so cry -> cri, by -> by, say -> say)
 /// </summary>
 internal void ReplaceSuffixStep1c()
 {
     //replace suffix y or Y by i if preceded by a non-vowel which is not the first letter of the word (so cry -> cri, by -> by, say -> say)
     if (Stem.EndsWith("y", StringComparison.OrdinalIgnoreCase) &&
         (Stem.Length > 2) &&
         (Stem.IndexOfAny(Vowels, Stem.Length - 2) != Stem.Length - 2))
     {
         Stem = Stem.Substring(0, Stem.Length - 1) + "i";
     }
 }
Exemple #28
0
 private void Spread(GameObject stemObject)
 {
     stem = stemObject.GetComponent <Stem>();
     if (!stem.isOnFire)
     {
         GameManager.ModifyFireCount(1);
         GameObject fire = Instantiate(Prefabs.fireObject, stem.transform.position, Quaternion.identity);
         fire.GetComponent <Fire>().stem = stem;
         stem.LightOnFire(fire);
     }
 }
        public IFieldReader <TItem> Get(Stem <TItem> stem)
        {
            var instanceMethod = _getInstanceReaderMethod.Invoke(stem);

            if (instanceMethod is Func <TMiddle, TValue> delegateMethod)
            {
                return(new ExpressionMiddleDelegateFieldReader <TItem, TMiddle, TValue>(_middleExpression, delegateMethod));
            }

            throw new StemAttributeSetupException("Field instance method was invalid.");
        }
        public async Task <IActionResult> PostStem([FromBody] Stem stem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Stemmen.Add(stem);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetStem", new { id = stem.StemID }, stem));
        }
Exemple #31
0
 private bool StripEnding(string[] endings)
 {
     foreach (string ending in endings)
     {
         if (Stem.EndsWith(ending))
         {
             Stem = Stem.Remove(Stem.Length - ending.Length);
             return(true);
         }
     }
     return(false);
 }
Exemple #32
0
        /// <summary>
        /// A word is called short if it ends in a short syllable, and if R1 is null.
        /// </summary>
        /// <returns></returns>
        internal bool IsShortWord()
        {
            //about to use R1
            CheckCache();

            //A word is called short if it ends in a short syllable, and if R1 is null.
            int lastVowelIndex = Stem.LastIndexOfAny(Vowels);

            return(lastVowelIndex > -1 &&
                   IsShortSyllable(lastVowelIndex) &&
                   String.IsNullOrEmpty(GetR1()));
        }
Exemple #33
0
 protected WordForm(Stem stem, string suffix)
 {
     Stem = stem;
     Suffix = suffix;
 }
Exemple #34
0
		public void AddOtherToStem()
		{
			try
			{
				WordRecord wr = new WordRecord();
				m_gd.WordRecords.Add(wr);
				Stem stem = new Stem();
				wr.Stem = stem;
				stem.Other = m_otherTop;

				AddOtherContents();

				m_otherTop = m_gd.WordRecords[0].Stem.Other;

				CheckOtherContents();
			}
			finally
			{
				DeleteFile(m_fileName);
			}
		}
		/// <summary>
		/// Do whatever it takes to convert the input this processor knows about.
		/// </summary>
		public void Convert()
		{
			string outputPathname = null;

			OpenFileDialog openFileDlg = new OpenFileDialog();

			openFileDlg.InitialDirectory = "c:\\";
			openFileDlg.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
			openFileDlg.FilterIndex = 2;
			openFileDlg.Multiselect = false;

			if (openFileDlg.ShowDialog() == DialogResult.OK)
			{
				string sourcePathname = openFileDlg.FileName;
				if (File.Exists(sourcePathname))
				{
					// Try to convert it.
					using (StreamReader reader = new StreamReader(sourcePathname))
					{
						string line = reader.ReadLine();
						Dictionary<string, bool> dictPrefixes = new Dictionary<string, bool>();
						Dictionary<string, bool> dictStems = new Dictionary<string, bool>();
						Dictionary<string, bool> dictSuffixes = new Dictionary<string, bool>();
						while (line != null)
						{
							line = line.Trim();
							if (line != String.Empty)
							{
								int openAngleLocation = line.IndexOf("<", 0);
								if (openAngleLocation < 0)
									continue;
								int closeAngleLocation = line.IndexOf(">", openAngleLocation + 1);
								if (closeAngleLocation < 0)
									continue;
								WordRecord wrdRec = new WordRecord();
								m_gd.WordRecords.Add(wrdRec);

								// Handle prefixes, if any.
								string prefixes = null;
								if (openAngleLocation > 0)
									prefixes = line.Substring(0, openAngleLocation);
								if (prefixes != null)
								{
									if (wrdRec.Prefixes == null)
										wrdRec.Prefixes = new List<Affix>();
									foreach (string prefix in prefixes.Split('-'))
									{
										if (prefix != null && prefix != "")
										{
											Affix afx = new Affix();
											afx.MIDREF = prefix;
											wrdRec.Prefixes.Add(afx);
											if (!dictPrefixes.ContainsKey(prefix))
											{
												m_gd.Morphemes.Add(new Morpheme(MorphemeType.prefix, prefix));
												dictPrefixes.Add(prefix, true);
											}
										}
									}
								}

								// Handle stem.
								string sStem = null;
								// Stem has content, so use it.
								sStem = line.Substring(openAngleLocation + 1, closeAngleLocation - openAngleLocation - 1);
								if (sStem.Length == 0)
									sStem = "stem";
								Stem stem = new Stem();
								stem.MIDREF = sStem;
								wrdRec.Stem = stem;
								if (!dictStems.ContainsKey(sStem))
								{
									m_gd.Morphemes.Add(new Morpheme(MorphemeType.stem, sStem));
									dictStems.Add(sStem, true);
								}

								// Handle suffixes, if any.
								string suffixes = null;
								if (line.Length > closeAngleLocation + 2)
									suffixes = line.Substring(closeAngleLocation + 1);
								if (suffixes != null)
								{
									if (wrdRec.Suffixes == null)
										wrdRec.Suffixes = new List<Affix>();
									foreach (string suffix in suffixes.Split('-'))
									{
										if (suffix != null && suffix != "")
										{
											Affix afx = new Affix();
											afx.MIDREF = suffix;
											wrdRec.Suffixes.Add(afx);
											if (!dictSuffixes.ContainsKey(suffix))
											{
												m_gd.Morphemes.Add(new Morpheme(MorphemeType.suffix, suffix));
												dictSuffixes.Add(suffix, true);
											}
										}
									}
								}
							}
							line = reader.ReadLine();
						}

						// Main processing.
						PositionAnalyzer anal = new PositionAnalyzer();
						anal.Process(m_gd);

						// Do any post-analysis processing here, if needed.
						// End of any optional post-processing.

						// Save, so it can be transformed.
						outputPathname = GetOutputPathname(sourcePathname);
						m_gd.SaveData(outputPathname);

						// Transform.
						XslCompiledTransform trans = new XslCompiledTransform();
						try
						{
							trans.Load(XSLPathname);
						}
						catch
						{
							MessageBox.Show("Could not load the XSL file.", "Information");
							return;
						}

						string htmlOutput = Path.GetTempFileName() + ".html";
						try
						{
							trans.Transform(outputPathname, htmlOutput);
						}
						catch
						{
							MessageBox.Show("Could not transform the input file.", "Information");
							return;
						}
						finally
						{
							if (outputPathname != null && File.Exists(outputPathname))
								File.Delete(outputPathname);
						}
						Process.Start(htmlOutput);
					} // end 'using'
				}
			}

			// Reset m_gd, in case it gets called for another file.
			m_gd = GAFAWSData.Create();
		}
Exemple #36
0
 internal NounForm(Stem stem, Case @case, Number number, string suffix)
     : base(stem, suffix)
 {
     Case = @case;
     Number = number;
 }
Exemple #37
0
 public BasicWordForm(Stem stem, string suffix)
     : base(stem, suffix)
 {
 }
Exemple #38
0
		internal void Convert(SqlCommand cmd, GAFAWSData gData, Dictionary<string, FwMsa> prefixes, Dictionary<string, List<FwMsa>> stems, Dictionary<string, FwMsa> suffixes)
		{
			if (!CanConvert)
				return;

			WordRecord wr = new WordRecord();
			// Deal with prefixes, if any.
			int startStemOrd = 0;
			foreach (KeyValuePair<int, FwMorphBundle> kvp in m_morphBundles)
			{
				FwMorphBundle mb = kvp.Value;
				string msaKey = mb.GetMsaKey(cmd);
				if (mb.MSA.Class == 5001 || mb.MSA.Class == 5031 || mb.MSA.Class == 5032 || mb.MSA.Class == 5117) // What about 5117-MoUnclassifiedAffixMsa?
				{
					// stem or derivational prefix, so bail out of this loop.
					startStemOrd = kvp.Key;
					break;
				}

				// Add prefix, if not already present.
				if (wr.Prefixes == null)
					wr.Prefixes = new List<Affix>();
				if (!prefixes.ContainsKey(msaKey))
				{
					prefixes.Add(msaKey, mb.MSA);
					gData.Morphemes.Add(new Morpheme(MorphemeType.prefix, msaKey));
				}
				Affix afx = new Affix();
				afx.MIDREF = msaKey;
				wr.Prefixes.Add(afx);
			}

			// Deal with suffixes, if any.
			// Work through the suffixes from the end of the word.
			// We stop when we hit the stem or a derivational suffix.
			int endStemOrd = 0;
			for (int i = m_morphBundles.Count; i > 0; --i)
			{
				FwMorphBundle mb = m_morphBundles[i];
				string msaKey = mb.GetMsaKey(cmd);
				if (mb.MSA.Class == 5001 || mb.MSA.Class == 5031 || mb.MSA.Class == 5032 || mb.MSA.Class == 5117) // What about 5117-MoUnclassifiedAffixMsa?
				{
					// stem or derivational suffix, so bail out of this loop.
					endStemOrd = i;
					break;
				}

				// Add suffix, if not already present.
				if (wr.Suffixes == null)
					wr.Suffixes = new List<Affix>();
				if (!suffixes.ContainsKey(msaKey))
				{
					suffixes.Add(msaKey, mb.MSA);
					gData.Morphemes.Add(new Morpheme(MorphemeType.suffix, msaKey));
				}
				Affix afx = new Affix();
				afx.MIDREF = msaKey;
				wr.Suffixes.Insert(0, afx);
			}

			// Deal with stem.
			List<FwMsa> localStems = new List<FwMsa>();
			string sStem = "";
			foreach (KeyValuePair<int, FwMorphBundle> kvp in m_morphBundles)
			{
				FwMorphBundle mb = kvp.Value;
				int currentOrd = kvp.Key;
				if (currentOrd >= startStemOrd && currentOrd <= endStemOrd)
				{
					string msaKey = mb.GetMsaKey(cmd);
					string spacer = (currentOrd == 1) ? "" : " ";
					sStem += spacer + msaKey;
				}
			}
			if (!stems.ContainsKey(sStem))
			{
				stems.Add(sStem, localStems);
				gData.Morphemes.Add(new Morpheme(MorphemeType.stem, sStem));
			}

			Stem stem = new Stem();
			stem.MIDREF = sStem;
			wr.Stem = stem;

			// Add wr.
			gData.WordRecords.Add(wr);
		}