public ActionResult RemoveZoneDescriptive(string id = "", string authorize = "") { string message = string.Empty; string zoneId = ""; if (string.IsNullOrWhiteSpace(authorize)) { message = "You must check the proper authorize radio button first."; } else { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); string[] values = authorize.Split(new string[] { "|||" }, StringSplitOptions.RemoveEmptyEntries); if (values.Count() != 2) { message = "You must check the proper authorize radio button first."; } else { string type = values[0]; string phrase = values[1]; IZone obj = LiveCache.Get <IZone>(new LiveCacheKey(typeof(IZone), id)); if (obj == null) { message = "That does not exist"; } else { GrammaticalType grammaticalType = (GrammaticalType)Enum.Parse(typeof(GrammaticalType), type); ISensoryEvent existingOccurrence = obj.Descriptives.FirstOrDefault(occurrence => occurrence.Event.Role == grammaticalType && occurrence.Event.Phrase.Equals(phrase, StringComparison.InvariantCultureIgnoreCase)); zoneId = obj.BirthMark; if (existingOccurrence != null) { obj.Descriptives.Remove(existingOccurrence); if (obj.Save()) { LoggingUtility.LogAdminCommandUsage("*WEB* - LIVE DATA - RemoveDescriptive[" + id.ToString() + "|" + type.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Delete Successful."; } else { message = "Error; Removal failed."; } } else { message = "That does not exist"; } } } } return(RedirectToAction("Zone", new { Message = message, birthMark = id })); }
private bool CheckNonPivotValidity(ILexicalSentence first, ILexicalSentence second) { GrammaticalType[] significantTypes = new GrammaticalType[] { GrammaticalType.Verb, GrammaticalType.ConjugatedVerb, GrammaticalType.Subject, GrammaticalType.DirectObject }; global::System.Collections.Generic.IEnumerable <Tuple <ISensoryEvent, short> > firstChecks = first.Predicate.Where(word => word.Item1?.Event != null && word.Item1.Event.Role != SubjectPivot && significantTypes.Contains(word.Item1.Event.Role)); global::System.Collections.Generic.IEnumerable <Tuple <ISensoryEvent, short> > secondChecks = second.Subject.Where(word => word.Item1?.Event != null && word.Item1.Event.Role != PredicatePivot && significantTypes.Contains(word.Item1.Event.Role)); global::System.Collections.Generic.IEnumerable <Tuple <ISensoryEvent, short> > firstMatches = second.Predicate.Where(word => word.Item1?.Event != null && word.Item1.Event.Role != SubjectPivot && significantTypes.Contains(word.Item1.Event.Role)); global::System.Collections.Generic.IEnumerable <Tuple <ISensoryEvent, short> > secondMatches = first.Subject.Where(word => word.Item1?.Event != null && word.Item1.Event.Role != PredicatePivot && significantTypes.Contains(word.Item1.Event.Role)); bool returnValue = !PivotMatch; if (firstChecks.Any()) { returnValue = returnValue && !PivotMatch == firstChecks.Any(wordPair => firstMatches.Any(matchPair => matchPair.Item1.Event.Role == wordPair.Item1.Event.Role && matchPair.Item1.Event.Phrase.Equals(wordPair.Item1.Event.Phrase, StringComparison.InvariantCultureIgnoreCase))); } if (secondChecks.Any()) { returnValue = returnValue && !PivotMatch == secondChecks.Any(wordPair => secondMatches.Any(matchPair => matchPair.Item1.Event.Role == wordPair.Item1.Event.Role && matchPair.Item1.Event.Phrase.Equals(wordPair.Item1.Event.Phrase, StringComparison.InvariantCultureIgnoreCase))); } return(returnValue); }
public SentenceGrammarRule(GrammaticalType fragment, short modificationOrder, bool subjectPredicate, SentenceType type) { SubjectPredicate = subjectPredicate; ModificationOrder = modificationOrder; Fragment = fragment; Type = type; }
/// <summary> /// Try to add a modifier to a lexica /// </summary> /// <param name="modifier">the lexica that is the modifier</param> /// <returns>Whether or not it succeeded</returns> public ILexica TryModify(LexicalType type, GrammaticalType role, string phrase, bool passthru = false) { ILexica modifier = new Lexica(type, role, phrase, Context); modifier = TryModify(modifier); return(passthru ? this : modifier); }
public ActionResult RemoveDescriptive(long id, string authorize) { string message = string.Empty; if (string.IsNullOrWhiteSpace(authorize)) { message = "You must check the proper authorize radio button first."; } else { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); string[] values = authorize.Split(new string[] { "|||" }, StringSplitOptions.RemoveEmptyEntries); if (values.Count() != 2) { message = "You must check the proper authorize radio button first."; } else { short type = short.Parse(values[0]); string phrase = values[1]; IRoomTemplate obj = TemplateCache.Get <IRoomTemplate>(id); if (obj == null) { message = "That does not exist"; } else { GrammaticalType grammaticalType = (GrammaticalType)type; ISensoryEvent existingOccurrence = obj.Descriptives.FirstOrDefault(occurrence => occurrence.Event.Role == grammaticalType && occurrence.Event.Phrase.Equals(phrase, StringComparison.InvariantCultureIgnoreCase)); if (existingOccurrence != null) { obj.Descriptives.Remove(existingOccurrence); if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - RemoveDescriptive[" + id.ToString() + "|" + type.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Delete Successful."; } else { message = "Error; Removal failed."; } } else { message = "That does not exist"; } } } } return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); }
public Lexica(LexicalType type, GrammaticalType role, string phrase, IEntity origin, IEntity observer) { Type = type; Phrase = phrase; Role = role; Modifiers = new HashSet <ILexica>(); Context = BuildContext(origin, observer); GetDictata(); }
public Lexica(LexicalType type, GrammaticalType role, string phrase, LexicalContext context) { Type = type; Phrase = phrase; Role = role; Modifiers = new HashSet <ILexica>(); Context = context.Clone(); GetDictata(); }
public Lexica(LexicalType type, GrammaticalType role, string phrase, IEntity origin, IEntity observer) { Type = type; Phrase = phrase; Role = role; Modifiers = new HashSet <ILexica>(); LexicalProcessor.VerifyLexeme(this); Context = BuildContext(origin, observer); }
public Lexica(LexicalType type, GrammaticalType role, string phrase, LexicalContext context) { Type = type; Phrase = phrase; Role = role; Modifiers = new HashSet <ILexica>(); LexicalProcessor.VerifyLexeme(this); Context = context.Clone(); }
public ActionResult AddEditDescriptive(long id, short descriptiveType, string phrase) { string message = string.Empty; IRoomTemplate obj = TemplateCache.Get <IRoomTemplate>(id); if (obj == null) { message = "That room does not exist"; return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); } OccurrenceViewModel vModel = new OccurrenceViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), DataObject = obj, AdminTypeName = "Room" }; if (descriptiveType > -1) { GrammaticalType grammaticalType = (GrammaticalType)descriptiveType; vModel.SensoryEventDataObject = obj.Descriptives.FirstOrDefault(occurrence => occurrence.Event.Role == grammaticalType && occurrence.Event.Phrase.Equals(phrase, StringComparison.InvariantCultureIgnoreCase)); } if (vModel.SensoryEventDataObject != null) { vModel.LexicaDataObject = vModel.SensoryEventDataObject.Event; } else { vModel.SensoryEventDataObject = new SensoryEvent { Event = new Lexica() }; } return(View("~/Views/GameAdmin/Room/SensoryEvent.cshtml", "_chromelessLayout", vModel)); }
/// <summary> /// Grab the specific event from the sentence that represents the specific role /// </summary> /// <param name="eventType">the lexical role to grab</param> /// <returns>the role event</returns> public ISensoryEvent GetSpecificEvent(GrammaticalType eventType) { IEnumerable <ISensoryEvent> events = Unpack(); return(events.FirstOrDefault(ev => ev.Event.Role == eventType)); }
/// <summary> /// Try to add a modifier to a lexica /// </summary> /// <param name="modifier">the lexica that is the modifier</param> /// <returns>Whether or not it succeeded</returns> public ILexica TryModify(LexicalType type, GrammaticalType role, string phrase, bool passthru = false) { return(Event.TryModify(type, role, phrase, passthru)); }
/// <summary> /// Create a lexica from this /// </summary> /// <returns></returns> public ILexica GetLexica(GrammaticalType role, LexicalContext context) { return(new Lexica(WordType, role, Name, context)); }