/** * Grabs the head verb of the verb phrase and sets it to future tense if the * phrase is future tense. It also turns off negation if the group has a * modal. * * @param phrase * the <code>PhraseElement</code> representing this noun phrase. * @param tenseValue * the <code>Tense</code> of the phrase. * @param hasModal * <code>true</code> if the verb phrase has a modal. * @return the modified head element */ private static INLGElement grabHeadVerb(PhraseElement phrase, Tense tenseValue, bool hasModal) { INLGElement frontVG = phrase.getHead(); if (frontVG != null) { if (frontVG is WordElement) { frontVG = new InflectedWordElement((WordElement)frontVG); } frontVG.setFeature(Feature.TENSE.ToString(), tenseValue); // if (Tense.FUTURE.Equals(tenseValue) && frontVG != null) { // frontVG.setFeature(Feature.TENSE, Tense.FUTURE); // } if (hasModal) { frontVG.setFeature(Feature.NEGATED.ToString(), false); } } return(frontVG); }
public static void Verify(string expectedString, int unit, TimeUnit timeUnit, Tense tense) { var deltaFromNow = new TimeSpan(); unit = Math.Abs(unit); if (tense == Tense.Past) unit = -unit; switch (timeUnit) { case TimeUnit.Second: deltaFromNow = TimeSpan.FromSeconds(unit); break; case TimeUnit.Minute: deltaFromNow = TimeSpan.FromMinutes(unit); break; case TimeUnit.Hour: deltaFromNow = TimeSpan.FromHours(unit); break; case TimeUnit.Day: deltaFromNow = TimeSpan.FromDays(unit); break; case TimeUnit.Month: deltaFromNow = TimeSpan.FromDays(unit*31); break; case TimeUnit.Year: deltaFromNow = TimeSpan.FromDays(unit*366); break; } VerifyWithCurrentDate(expectedString, deltaFromNow); VerifyWithDateInjection(expectedString, deltaFromNow); }
/// <summary> /// Constructor /// </summary> /// <param name="propLine">Prop entry line</param> public VerbInfo(string propLine) : this() { Match propLineMatch = _propLineRE.Match(propLine); if (!propLineMatch.Success) { throw new Exception("Failed to match proposition line"); } // verb role set example: hit.01 - when automatically tagging, the predicate might end up with a period in it (probably an SRL error), so use last period string verbRoleSet = propLineMatch.Groups["role_set"].Value; int roleSetLastPeriodLoc = verbRoleSet.LastIndexOf('.'); string roleSet = verbRoleSet.Substring(roleSetLastPeriodLoc + 1); // set verb and role set ID _verb = verbRoleSet.Substring(0, roleSetLastPeriodLoc); _roleSetID = roleSet != "XX" ? int.Parse(roleSet) : -1; // get other information _file = propLineMatch.Groups["file_name"].Value.Replace('/', Path.DirectorySeparatorChar); // use environment-specific path separators _sentenceNumber = int.Parse(propLineMatch.Groups["sent_num"].Value); _leafNumber = int.Parse(propLineMatch.Groups["leaf_num"].Value); _tagger = propLineMatch.Groups["tagger"].Value; _vForm = _strFormMap[propLineMatch.Groups["form"].Value]; _vTense = _strTenseMap[propLineMatch.Groups["tense"].Value]; _vAspect = _strAspectMap[propLineMatch.Groups["aspect"].Value]; _vPerson = _strPersonMap[propLineMatch.Groups["person"].Value]; _vVoice = _strVoiceMap[propLineMatch.Groups["voice"].Value]; _labeledNodeLocations = propLineMatch.Groups["labelLocations"].Value; }
/*###################################################### *######### Up till here is pretty final code ########## *######################################################*/ /*FUNCTION DESCRIPRION ASK ABOUT WHERE (ask about where an object is) * Paramaters expects either a type or a specfici object. function assumes object has a spatial parent. * if type, should ask about an indefinite. if specific; should ask about definite * Asking about facts of a given object * * SPECIFIC ENTITY * 1)Where + Aux + proper noun? "where is osnabruck?" (constraints: unique, i.e. one of a kind) * 2)where + <modal: might/would/could/can> + I find noun? * x)TODO AUX + Pr + prep + NP? "is NP/PR in the house?" * * TYPE * 4)Where + can i find a/some? "where is osnabruck?" (constraints: unique, i.e. one of a kind) * 5)where + <modal: might/would/could/can> + I find noun? * x)TODO AUX + Pr + prep + NP? "is there a/some NP/PR in the house?" * * first check whether its a physical entity or a type */ public String senseAskAboutWhere(String utterer, object targetObject, Tense t) { Type type = targetObject.GetType(); String subject, output = ""; /*CHOOSE PRODUCTION RULE*/ int productionRule; if (type == typeof(PhysicalEntity)) { productionRule = r.Next(1, 2); } else if (type == typeof(TypeDefinition)) { productionRule = r.Next(4, 5); } else //error { return("error in senseAskAboutWhere: " + targetObject.ToString() + " neither a Physical Entity nor a Type Definition."); } subject = renderConstituent(targetObject, false); if (productionRule == 1) { output = "where is " + subject + "?"; } //remove duplicate whitespace output = System.Text.RegularExpressions.Regex.Replace(output, @" {2,}", " "); //capitalise first letter output = char.ToUpper(output[0]) + output.Substring(1); return(output); }
public static string GetTensedVerb( Subject subject, Tense tense, Specificity specificity, Verb verb, string subjectText = null, string adverb = null ) { if (subjectText == null) { subjectText = GetDefaultSubjectText(subject); } return(GetTensedVerb( tense, specificity, verb.conjugations[subject], verb.pastConjugations[subject], verb.participle, verb.flatInfinitive, verb.gerund, subjectText, verb.subjectVerbInversion, (verb.subjectVerbInversion ? null : GetConjugatedDo(subject)), GetConjugatedHave(subject), GetVerbToBeFlat(subject), GetVerbToBeFlatPast(subject), verb.usePastParticiple, adverb )); }
public PhraseNode(string word, WordType wordType, Tense tense) : this() { BaseWord = word; WordType = wordType; Tense = tense; }
public Ending(Number number, Person person, Tense tense, Voice voice) { _number = number; _person = person; _tense = tense; _voice = voice; }
public MainPage(ISet <int> verbGroups, Tense tense) { InitializeComponent(); dbConn = new SQLiteAsyncConnection(App.VerbsDBPath); next_btn.Clicked += (a, b) => CurrentWord = verbs[++currWordIndx]; chk_btn.Clicked += (a, b) => CheckCorrectness(); answr_btn.Clicked += (a, b) => ShowAnswer(); var query = $"select * from {tenseEnumToTable[tense]}, verbs " + $"where verbs.word={tenseEnumToTable[tense]}.word " + $"and verbs.'group' in ({string.Join(",", verbGroups.Select(x => x + ""))}) " + $"and first_singular not like '' " + $"and second_singular not like '' " + $"and third_singular not like '' " + $"and first_plural not like '' " + $"and second_plural not like '' " + $"and third_plural not like '' " + $"order by random()"; dbConn.QueryAsync <VerbForms>(query).ContinueWith((queryTsk) => { verbs = queryTsk.Result; Device.BeginInvokeOnMainThread(() => { next_btn.IsEnabled = true; answr_btn.IsEnabled = true; chk_btn.IsEnabled = true; CurrentWord = verbs[currWordIndx]; }); }); }
public Tense tense;//can use for this for e.g. 'frog was a tadpole' 'coffee was hot' //empty constructor public Descriptor() { //you'd better be sure and set at minimum a trait name and verb when creating this object //else you'll break stuff this.value = true; this.tense = Tense.presentContinuous; probability = 1.0;//1 means always }
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; }
// Token: 0x06000212 RID: 530 RVA: 0x0000C4CC File Offset: 0x0000A6CC private string GetResourceForDate(TimeUnit unit, Tense timeUnitTense, int count) { string resourceKey = ResourceKeys.DateHumanize.GetResourceKey(unit, timeUnitTense, count); if (count != 1) { return(this.Format(resourceKey, count)); } return(this.Format(resourceKey)); }
public string Conjugate(INoun noun, Tense tense = Tense.Past) { if (tense == Tense.Past) { return("became"); } return(noun.Class == NounClass.It ? "becomes" : "become"); }
public string Conjugate(INoun noun, Tense tense = Tense.Past) { if (tense == Tense.Past) { return("went"); } return(noun.Class == NounClass.It ? "goes" : "go"); }
public string Conjugate(INoun noun, Tense tense = Tense.Past) { if (tense == Tense.Past) { return("occurred"); } return(noun.Class == NounClass.It ? "occurs" : "occur"); }
internal void SetValue(Tense t, string s) { int x = (int)t; _items[x] = s; if (Match(_items[x], _master.Item(t))) { _items[x] = _master.Item(t); } }
public string Conjugate(INoun noun, Tense tense = Tense.Past) { if (tense == Tense.Past) { return(m_Stem.EndsWith("e") ? $"{m_Stem}d" : $"{m_Stem}ed"); } return(noun.Class == NounClass.It ? $"{m_Stem}s" : m_Stem); }
public VerbExpression( IVerb verb, INoun subject = null, INoun objct = null, Tense tense = Tense.Past) { Verb = verb; Tense = tense; Subject = subject; Object = objct; }
/// <summary> /// Причастие (спряжение по залогу, падежу, роду и времени) /// </summary> public string Participle(Voice voice, Case @case, Gender gender, Tense tense) { var i = @case.IndexWithAnimate(gender); i += (int)voice * 78; i += 14; i += 8 * (int)gender.Gen(); i += 32 * (int)tense; return(Verbs.schemas[SchemaIndex].GetForm(Word, i)); }
private string DescribeHours(TimeSpan span, Tense tense, bool friendly) { if (span.TotalHours.InRange(23, 36)) //23-36 hours { return(Describe(TimeScale.Day, span.Days, friendly, tense)); } if (span.TotalHours.InRange(37, 24 * 25)) //37 hours to 25 days { return(Describe(TimeScale.Days, span.Days, friendly, tense)); } return(string.Empty); }
private string DescribeMinutes(TimeSpan span, Tense tense, bool friendly) { if (span.TotalMinutes.InRange(46, 90)) //46 minutes to 90 minutes { return(Describe(TimeScale.Hour, span.Hours, friendly, tense)); } if (span.TotalMinutes.InRange(91, 60 * 22)) //91 minutes to 22 hours { return(Describe(TimeScale.Hours, span.Hours, friendly, tense)); } return(string.Empty); }
internal string[] Lookup(Mode m, Tense t) { var p = _conj[m]; if (!p.ContainsKey(t)) { return(new string[6]); } return(p[t]); }
/// <summary> /// Generates Resource Keys accordning to convention. /// </summary> /// <param name="timeUnit">Time unit</param> /// <param name="timeUnitTense">Is time unit in future or past</param> /// <param name="count">Number of units, default is One.</param> /// <returns>Resource key, like DateHumanize_SingleMinuteAgo</returns> public static string GetResourceKey(TimeUnit timeUnit, Tense timeUnitTense, int count = 1) { ValidateRange(count); if (count == 0) return Now; var singularity = count == 1 ? Single : Multiple; var tense = timeUnitTense == Tense.Future ? FromNow : Ago; var unit = timeUnit.ToString().ToQuantity(count, ShowQuantityAs.None); return DateTimeFormat.FormatWith(singularity, unit, tense); }
public static void Verify(string expectedString, int unit, TimeUnit timeUnit, Tense tense, double? precision = null, CultureInfo culture = null, DateTime? baseDate = null, DateTime? baseDateUtc = null) { // We lock this as these tests can be multi-threaded and we're setting a static lock (LockObject) { if (precision.HasValue) Configurator.DateTimeHumanizeStrategy = new PrecisionDateTimeHumanizeStrategy(precision.Value); else Configurator.DateTimeHumanizeStrategy = new DefaultDateTimeHumanizeStrategy(); var deltaFromNow = new TimeSpan(); unit = Math.Abs(unit); if (tense == Tense.Past) unit = -unit; switch (timeUnit) { case TimeUnit.Millisecond: deltaFromNow = TimeSpan.FromMilliseconds(unit); break; case TimeUnit.Second: deltaFromNow = TimeSpan.FromSeconds(unit); break; case TimeUnit.Minute: deltaFromNow = TimeSpan.FromMinutes(unit); break; case TimeUnit.Hour: deltaFromNow = TimeSpan.FromHours(unit); break; case TimeUnit.Day: deltaFromNow = TimeSpan.FromDays(unit); break; case TimeUnit.Month: deltaFromNow = TimeSpan.FromDays(unit*31); break; case TimeUnit.Year: deltaFromNow = TimeSpan.FromDays(unit*366); break; } if (baseDate == null) { VerifyWithCurrentDate(expectedString, deltaFromNow, culture); VerifyWithDateInjection(expectedString, deltaFromNow, culture); } else { VerifyWithDate(expectedString, deltaFromNow, culture, baseDate.Value, baseDateUtc.Value); } } }
private string WrapInTense(Tense tense, string describedTime) { switch (tense) { case Tense.Past: return($"{describedTime} ago"); case Tense.Future: return($"in {describedTime}"); } return(describedTime); }
void ButtonDeleteTenseClick(object sender, EventArgs e) { if (listLang.SelectedIndex != -1 && listTenses.SelectedIndex != -1) { Tense selected_tense = (Tense)listTenses.SelectedItem; KryptonListItem item = (KryptonListItem)listLang.Items[listLang.SelectedIndex]; Language language = (Language)item.Tag; language.RemoveTense(selected_tense); listTenses.Items.Remove(selected_tense); } }
static string FirstPersonIndicativeStem(string infinitive) { string stem = infinitive.Substring(0, infinitive.Length - 2); Tense t = Tenses.Find(o => o.conjugation == Conjugation.Present); IrregularVerb iv = t.irregularVerbs.Find(o => o.m_infinitive == infinitive); if (iv != null) { IrregularConjugation c = iv.m_conjugations.Find(o => o.m_person == Person.firstPersonSingular); stem = c.m_conjugatedVerb.Substring(0, c.m_conjugatedVerb.Length - 1); } return(stem); }
private string DescribeFriendly(TimeScale scale, int number, Tense tense) { if (scale == TimeScale.Seconds && number <= _nowSeconds) { return(GetFriendlyName(scale, number)); } var described = GetFriendlyName(scale, number); if (string.IsNullOrWhiteSpace(described)) { described = DescribeDistance(scale, number, Tense.Present); } return(WrapInTense(tense, described)); }
/// <summary> /// Generates Resource Keys accordning to convention. /// </summary> /// <param name="timeUnit">Time unit</param> /// <param name="timeUnitTense">Is time unit in future or past</param> /// <param name="count">Number of units, default is One.</param> /// <returns>Resource key, like DateHumanize_SingleMinuteAgo</returns> public static string GetResourceKey(TimeUnit timeUnit, Tense timeUnitTense, int count = 1) { ValidateRange(count); if (count == 0) { return(Now); } var singularity = count == 1 ? Single : Multiple; var tense = timeUnitTense == Tense.Future ? FromNow : Ago; var unit = timeUnit.ToString().ToQuantity(count, ShowQuantityAs.None); return(DateTimeFormat.FormatWith(singularity, unit, tense)); }
static string ThirdPersonPluralPreteriteStem(string infinitive) { string stem = infinitive.Substring(0, infinitive.Length - 2); Tense t = Tenses.Find(o => o.conjugation == Conjugation.Preterite); IrregularVerb iv = t.irregularVerbs.Find(o => o.m_infinitive == infinitive); if (iv != null) { IrregularConjugation c = iv.m_conjugations.Find(o => o.m_person == Person.thirdPersonPlural); stem = c.m_conjugatedVerb.Substring(0, c.m_conjugatedVerb.Length - 2); } return(stem); }
void ButtonChangeTenseClick(object sender, EventArgs e) { if (listLang.SelectedIndex != -1 && listTenses.SelectedIndex != -1) { string tenseName; Tense selected_tense = (Tense)listTenses.SelectedItem; if (EditValueDialog.ShowDialog(this, Strings.TenseNameHeader, Strings.TenseNameEnter, selected_tense.Name, out tenseName)) { KryptonListItem item = (KryptonListItem)listLang.Items[this.listLang.SelectedIndex]; Language language = (Language)item.Tag; selected_tense.Name = tenseName; listTenses.Refresh(); } } }
private string DescribeSeconds(TimeSpan span, Tense tense, bool friendly) { if (span.TotalSeconds.InRange(0, 45)) { return(Describe(TimeScale.Seconds, span.Seconds, friendly, tense)); } if (span.TotalSeconds.InRange(46, 90)) { return(Describe(TimeScale.Minute, span.Minutes, friendly, tense)); } if (span.TotalSeconds.InRange(91, 60 * 45)) { return(Describe(TimeScale.Minutes, span.Minutes, friendly, tense)); } return(string.Empty); }
public static IConjugation Get(Mood mood, Voice voice, Tense tense) { if (!CONJUGATIONS.ContainsKey(mood)) { throw new NotSupportedException(string.Format("unrecognised mood of sum : {0}", mood)); } if (!CONJUGATIONS[mood].ContainsKey(voice)) { throw new NotSupportedException(string.Format("unrecognised voice of sum : {0}", voice)); } if (!CONJUGATIONS[mood][voice].ContainsKey(tense)) { throw new NotSupportedException(string.Format("unrecognised tense of sum : {0}", tense)); } return CONJUGATIONS[mood][voice][tense]; }
static string conjugateIrregularVerb(string infinitive, PersonalPronoun pronoun, Conjugation conjugation) { string conjugatedVerb = null; Tense tense = Tenses.Find(o => o.conjugation == conjugation); List <IrregularVerb> irregularVerbs = tense.irregularVerbs; // not guaranteed to find IrregularVerb v = irregularVerbs.Find(o => o.m_infinitive == infinitive); if (v != null) { // guaranteed to find IrregularConjugation c = v.m_conjugations.Find(o => o.m_person == pronoun.person); conjugatedVerb = c.m_conjugatedVerb; } return(conjugatedVerb); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Tense tense = (Tense)((dynamic)value).Tense; switch (tense) { case Tense.Future: return(DateTime.Now.GetRange(DateTime.Now.AddDays(Days)).ToList()); case Tense.Past: return(DateTime.Now.AddDays(-Days).GetRange(DateTime.Now).ToList()); default: return(new[] { DateTime.Now }); } }
public string Conjugate(INoun noun, Tense tense = Tense.Past) { switch (noun.Class) { case NounClass.I: return(tense == Tense.Present ? "have" : "had"); case NounClass.You: return(tense == Tense.Present ? "have" : "had"); case NounClass.It: return(tense == Tense.Present ? "has" : "had"); default: throw new ArgumentOutOfRangeException(nameof(noun.Class)); } }
/// <summary> /// Constructor /// </summary> /// <param name="verb">Verb</param> /// <param name="file">Annotation file</param> /// <param name="sentenceNumber">Sentence wichin annotation file</param> /// <param name="leafNumber">Leaf within sentence</param> /// <param name="tagger">Tagger used</param> /// <param name="roleSetID">ID of role set for this instance</param> /// <param name="form">Form flag</param> /// <param name="tense">Tense flag</param> /// <param name="aspect">Aspect flag</param> /// <param name="person">Person flag</param> /// <param name="voice">Voice flag</param> /// <param name="labeledNodeLocations">Labeled node locations</param> public VerbInfo(string verb, string file, int sentenceNumber, int leafNumber, string tagger, int roleSetID, Form form, Tense tense, Aspect aspect, Person person, Voice voice, string labeledNodeLocations) { _verb = verb; _file = file; _sentenceNumber = sentenceNumber; _leafNumber = leafNumber; _tagger = tagger; _roleSetID = roleSetID; _vForm = form; _vTense = tense; _vAspect = aspect; _vPerson = person; _vVoice = voice; _labeledNodeLocations = labeledNodeLocations; }
private WordForm GetFirstConjugationForm(Person person, Number number, Mood mood, Voice voice, Tense tense) { var suffix = string.Empty; if (person == Person.First && number == Number.Singluar && mood == Mood.Indicative && voice == Voice.Active) suffix = "m"; if (person == Person.Second && number == Number.Singluar && mood == Mood.Indicative && voice == Voice.Active) suffix = "s"; if (person == Person.Third && number == Number.Singluar && mood == Mood.Indicative && voice == Voice.Active) suffix = "t"; if (person == Person.First && number == Number.Plural && mood == Mood.Indicative && voice == Voice.Active) suffix = "mus"; if (person == Person.Second && number == Number.Plural && mood == Mood.Indicative && voice == Voice.Active) suffix = "tis"; if (person == Person.Third && number == Number.Plural && mood == Mood.Indicative && voice == Voice.Active) suffix = "nt"; return new VerbForm(this, Conjugation, person, number, mood, voice, tense, suffix); }
public static void Verify(string expectedString, int unit, TimeUnit timeUnit, Tense tense, double? precision = null, CultureInfo culture = null) { if (precision.HasValue) Configurator.DateTimeHumanizeStrategy = new PrecisionDateTimeHumanizeStrategy(precision.Value); else Configurator.DateTimeHumanizeStrategy = new DefaultDateTimeHumanizeStrategy(); var deltaFromNow = new TimeSpan(); unit = Math.Abs(unit); if (tense == Tense.Past) unit = -unit; switch (timeUnit) { case TimeUnit.Millisecond: deltaFromNow = TimeSpan.FromMilliseconds(unit); break; case TimeUnit.Second: deltaFromNow = TimeSpan.FromSeconds(unit); break; case TimeUnit.Minute: deltaFromNow = TimeSpan.FromMinutes(unit); break; case TimeUnit.Hour: deltaFromNow = TimeSpan.FromHours(unit); break; case TimeUnit.Day: deltaFromNow = TimeSpan.FromDays(unit); break; case TimeUnit.Month: deltaFromNow = TimeSpan.FromDays(unit*31); break; case TimeUnit.Year: deltaFromNow = TimeSpan.FromDays(unit*366); break; } VerifyWithCurrentDate(expectedString, deltaFromNow, culture); VerifyWithDateInjection(expectedString, deltaFromNow, culture); }
public void CanSpecifyCultureExplicitly(int unit, TimeUnit timeUnit, Tense tense, string culture, string expected) { DateHumanize.Verify(expected, unit, timeUnit, tense, culture: new CultureInfo(culture)); }
public VerbStemWithSpecificForm(Conjugation conjugation, Person person, Number number, Mood mood, Voice voice, Tense tense, string specificForm, DictionaryEntry entry) : base(conjugation, specificForm, entry) { _forms = new[] { new VerbForm(this, conjugation, person, number, mood, voice, tense, string.Empty) }; }
/// <summary> /// Returns the string representation of the provided DateTime /// </summary> /// <param name="timeUnit"></param> /// <param name="timeUnitTense"></param> /// <param name="unit"></param> /// <returns></returns> public virtual string DateHumanize(TimeUnit timeUnit, Tense timeUnitTense, int unit) { return GetResourceForDate(timeUnit, timeUnitTense, unit); }
private string GetResourceForDate(TimeUnit unit, Tense timeUnitTense, int count) { var resourceKey = ResourceKeys.DateHumanize.GetResourceKey(unit, timeUnitTense: timeUnitTense, count: count); return count == 1 ? Format(resourceKey) : Format(resourceKey, count); }
public void Add(Person person, Number number, Mood mood, Voice voice, Tense tense) { _formsToGenerate.Add(Tuple.Create(person, number, mood, voice, tense)); }