public void Free(ILexeme lexeme) { var parseEngineLexeme = lexeme as ParseEngineLexeme; if(parseEngineLexeme == null) throw new Exception($"Unable to free lexeme of type {lexeme.GetType()} from ParseEngineLexeme."); _queue.Enqueue(parseEngineLexeme); }
private bool TryParseExistingToken() { // PERF: Avoid Linq FirstOrDefault due to lambda allocation ILexeme longestAcceptedMatch = null; int doNotFreeLexemeIndex = -1; for (int i = 0; i < _existingLexemes.Count; i++) { var lexeme = _existingLexemes[i]; if (lexeme.IsAccepted()) { doNotFreeLexemeIndex = i; longestAcceptedMatch = lexeme; break; } } if (longestAcceptedMatch == null) { return(false); } //var token = CreateTokenFromLexeme(longestAcceptedMatch); //if (token == null) // return false; if (!ParseEngine.Pulse(longestAcceptedMatch)) { return(false); } ClearExistingLexemes(doNotFreeLexemeIndex); return(true); }
public AddEditDictataViewModel(ILexeme parent, IDictata obj) { ParentObject = (Lexeme)parent; ValidLanguages = ConfigDataCache.GetAll <ILanguage>(); DataObject = (Dictata)obj; ValidWords = ConfigDataCache.GetAll <ILexeme>().Where(lex => lex.Language == parent.Language && lex != parent).SelectMany(lex => lex.WordForms).OrderBy(form => form.Name); }
public void Free(ILexeme lexeme) { var stringLiteralLexeme = lexeme as StringLiteralLexeme; if (stringLiteralLexeme == null) throw new Exception($"Unable to free lexeme of type {lexeme.GetType()} from StringLiteralLexemeFactory."); _queue.Enqueue(stringLiteralLexeme); }
public ActionResult Edit(string id, AddEditDictionaryViewModel vModel) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); ILexeme obj = ConfigDataCache.Get<ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), id, ConfigDataType.Dictionary)); string message; if (obj == null) { message = "That does not exist"; return RedirectToAction("Index", new { Message = message }); } obj.Name = vModel.DataObject.Name; obj.Language = vModel.DataObject.Language; if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - EditLexeme[" + obj.UniqueKey + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Edit Successful."; } else { message = "Error; Edit failed."; } return RedirectToAction("Index", new { Message = message }); }
public ActionResult AddDictata(string lexemeId, AddEditDictataViewModel vModel) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); ILexeme lex = ConfigDataCache.Get<ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), lexemeId, ConfigDataType.Dictionary)); if (lex == null) { return RedirectToAction("Index", new { Message = "That does not exist" }); } IDictata newObj = vModel.DataObject; lex.AddNewForm(newObj); string message; if (lex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - AddDictata[" + newObj.UniqueKey + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Creation Successful."; } else { message = "Error; Creation failed."; } return RedirectToAction("Index", new { Message = message }); }
public ActionResult RemoveDictata(string removeId = "", string authorizeRemove = "") { string message; if (!string.IsNullOrWhiteSpace(authorizeRemove) && removeId.Equals(authorizeRemove)) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); ILexeme lex = ConfigDataCache.Get<ILexeme>(removeId.Substring(0, removeId.LastIndexOf("_") - 1)); IDictata obj = lex?.WordForms?.FirstOrDefault(form => form.UniqueKey == removeId); if (obj == null) { message = "That does not exist"; } else { HashSet<IDictata> wordForms = lex.WordForms.ToHashSet(); wordForms.RemoveWhere(form => form.UniqueKey == removeId); lex.WordForms = wordForms.ToArray(); lex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)); LoggingUtility.LogAdminCommandUsage("*WEB* - RemoveConstants[" + removeId + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Delete Successful."; } } else { message = "You must check the proper remove or unapprove authorization radio button first."; } return RedirectToAction("Index", new { Message = message }); }
public void Free(ILexeme lexeme) { var dfaLexeme = lexeme as DfaLexeme; if (dfaLexeme == null) throw new Exception($"Unable to free lexeme of type {lexeme.GetType()} with DfaLexemeFactory"); _queue.Enqueue(dfaLexeme); }
public ActionResult Remove(string removeId = "", string authorizeRemove = "") { string message; if (!string.IsNullOrWhiteSpace(authorizeRemove) && removeId.Equals(authorizeRemove)) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); ILexeme obj = ConfigDataCache.Get<ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), removeId, ConfigDataType.Dictionary)); if (obj == null) { message = "That does not exist"; } else if (obj.Remove(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - RemoveConstants[" + removeId + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Delete Successful."; } else { message = "Error; Removal failed."; } } else { message = "You must check the proper remove or unapprove authorization radio button first."; } return RedirectToAction("Index", new { Message = message }); }
/// <summary> /// Get the lexeme for this word /// </summary> /// <returns>the lexeme</returns> public ILexeme GetLexeme() { ILexeme lex = ConfigDataCache.Get <ILexeme>(string.Format("{0}_{1}_{2}", ConfigDataType.Dictionary, Language.Name, Name)); if (lex != null) { if (!lex.WordForms.Any(form => form == this)) { lex.AddNewForm(this); lex.SystemSave(); lex.PersistToCache(); } } else { lex = new Lexeme() { Name = Name, Language = Language }; lex.SystemSave(); lex.PersistToCache(); lex.AddNewForm(this); } return(lex); }
/// <summary> /// Verify the dictionary has this word already /// </summary> /// <param name="lexeme">dictata to check</param> public static ILexeme VerifyLexeme(ILexeme lexeme) { if (lexeme == null || string.IsNullOrWhiteSpace(lexeme.Name) || lexeme.Name.IsNumeric()) { return(null); } //Set the language to default if it is absent and save it, if it has a language it already exists if (lexeme.Language == null) { IGlobalConfig globalConfig = ConfigDataCache.Get <IGlobalConfig>(new ConfigDataCacheKey(typeof(IGlobalConfig), "LiveSettings", ConfigDataType.GameWorld)); if (globalConfig.BaseLanguage != null) { lexeme.Language = globalConfig.BaseLanguage; } } ConfigDataCacheKey cacheKey = new ConfigDataCacheKey(lexeme); ILexeme maybeLexeme = ConfigDataCache.Get <ILexeme>(cacheKey); if (maybeLexeme != null) { lexeme = maybeLexeme; } lexeme.IsSynMapped = false; lexeme.MapSynNet(); lexeme.FillLanguages(); return(lexeme); }
public void Free(ILexeme lexeme) { if (!(lexeme is ParseEngineLexeme parseEngineLexeme)) { throw new Exception($"Unable to free lexeme of type {lexeme.GetType()} from ParseEngineLexeme."); } _queue.Enqueue(parseEngineLexeme); }
public void Free(ILexeme lexeme) { if (!(lexeme is StringLiteralLexeme stringLiteralLexeme)) { throw new Exception($"Unable to free lexeme of type {lexeme.GetType()} from StringLiteralLexemeFactory."); } _queue.Enqueue(stringLiteralLexeme); }
public void Free(ILexeme lexeme) { var terminalLexeme = lexeme as TerminalLexeme; if (terminalLexeme == null) throw new Exception($"Unable to free lexeme of type {lexeme.GetType()} from TerminalLexemeFactory"); _queue.Enqueue(terminalLexeme); }
public void Free(ILexeme lexeme) { if (!(lexeme is DfaLexeme dfaLexeme)) { throw new Exception($"Unable to free lexeme of type {lexeme.GetType()} with DfaLexemeFactory"); } _queue.Enqueue(dfaLexeme); }
public AddEditDictataViewModel(ILexeme parent) { ParentObject = (Lexeme)parent; ValidPhrases = ConfigDataCache.GetAll <IDictataPhrase>().OrderBy(word => word.Language.Name).ThenBy(word => word.Name); ValidLanguages = ConfigDataCache.GetAll <ILanguage>(); DataObject = new Dictata(); ValidWords = ConfigDataCache.GetAll <ILexeme>().Where(lex => lex.Language == parent.Language && lex != parent).SelectMany(lex => lex.WordForms).OrderBy(form => form.Name); }
/// <summary> /// Make a dictata from a lexica /// </summary> /// <param name="lexica">the incoming lexica phrase</param> public Dictata(ILexica lexica) { Name = ""; Antonyms = new HashSet <IDictata>(); Synonyms = new HashSet <IDictata>(); PhraseAntonyms = new HashSet <IDictataPhrase>(); PhraseSynonyms = new HashSet <IDictataPhrase>(); Semantics = new HashSet <string>(); IGlobalConfig globalConfig = ConfigDataCache.Get <IGlobalConfig>(new ConfigDataCacheKey(typeof(IGlobalConfig), "LiveSettings", ConfigDataType.GameWorld)); if (lexica.Context?.Language == null) { if (globalConfig?.BaseLanguage == null) { Language = ConfigDataCache.GetAll <ILanguage>().FirstOrDefault(); } else { Language = globalConfig.BaseLanguage; } } else { Language = lexica.Context.Language; } ILexeme maybeLex = ConfigDataCache.Get <ILexeme>( new ConfigDataCacheKey(typeof(ILexeme), string.Format("{0}_{1}", Language.Name, lexica.Phrase), ConfigDataType.Dictionary)); if (maybeLex == null) { Name = lexica.Phrase; WordType = lexica.Type; } else if (maybeLex.WordForms.Any(form => form.WordType == lexica.Type)) { IDictata wordForm = maybeLex.WordForms.FirstOrDefault(form => form.WordType == lexica.Type); Name = lexica.Phrase; WordType = lexica.Type; Synonyms = wordForm.Synonyms; Antonyms = wordForm.Antonyms; PhraseSynonyms = wordForm.PhraseSynonyms; PhraseAntonyms = wordForm.PhraseAntonyms; Determinant = wordForm.Determinant; Elegance = wordForm.Elegance; Feminine = wordForm.Feminine; Perspective = wordForm.Perspective; Plural = wordForm.Plural; Positional = wordForm.Positional; Possessive = wordForm.Possessive; Quality = wordForm.Quality; Semantics = wordForm.Semantics; Severity = wordForm.Severity; Tense = wordForm.Tense; } }
private IToken CreateTokenFromLexeme(ILexeme lexeme) { var capture = lexeme.Value; return(new Token( capture, Position - capture.Length - 1, lexeme.TokenType)); }
public void Free(ILexeme lexeme) { if (!(lexeme is TerminalLexeme terminalLexeme)) { throw new Exception($"Unable to free lexeme of type { lexeme.GetType()} from TerminalLexemeFactory"); } _queue.Enqueue(terminalLexeme); }
public void Free(ILexeme lexeme) { var stringLiteralLexeme = lexeme as StringLiteralLexeme; if (stringLiteralLexeme == null) { throw new Exception($"Unable to free lexeme of type {lexeme.GetType()} from StringLiteralLexemeFactory."); } _queue.Enqueue(stringLiteralLexeme); }
public void Free(ILexeme lexeme) { var dfaLexeme = lexeme as DfaLexeme; if (dfaLexeme == null) { throw new Exception($"Unable to free lexeme of type {lexeme.GetType()} with DfaLexemeFactory"); } _queue.Enqueue(dfaLexeme); }
public void Free(ILexeme lexeme) { var parseEngineLexeme = lexeme as ParseEngineLexeme; if (parseEngineLexeme == null) { throw new Exception($"Unable to free lexeme of type {lexeme.GetType()} from ParseEngineLexeme."); } _queue.Enqueue(parseEngineLexeme); }
public void Free(ILexeme lexeme) { var terminalLexeme = lexeme as TerminalLexeme; if (terminalLexeme == null) { throw new Exception($"Unable to free lexeme of type {lexeme.GetType()} from TerminalLexemeFactory"); } _queue.Enqueue(terminalLexeme); }
/// <summary> /// Get the dictata from this lexica /// </summary> /// <returns>A dictata</returns> public IDictata GetDictata() { ILexeme lex = ConfigDataCache.Get <ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), string.Format("{0}_{1}", Context?.Language?.Name, Phrase), ConfigDataType.Dictionary)); IDictata dict = lex?.GetForm(Type); if (dict == null) { dict = GenerateDictata(); } return(dict); }
public ActionResult AddDictata(string lexemeId) { ILexeme lex = ConfigDataCache.Get<ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), lexemeId, ConfigDataType.Dictionary)); if (lex == null) { string message = "That does not exist"; return RedirectToAction("Index", new { Message = message }); } AddEditDictataViewModel vModel = new AddEditDictataViewModel(lex) { AuthedUser = UserManager.FindById(User.Identity.GetUserId()) }; return View("~/Views/GameAdmin/Dictionary/AddDictata.cshtml", vModel); }
public ActionResult EditDictata(string lexemeId, string id) { ILexeme lex = ConfigDataCache.Get<ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), lexemeId, ConfigDataType.Dictionary)); IDictata obj = lex?.WordForms?.FirstOrDefault(form => form.UniqueKey == id); if (obj == null) { return RedirectToAction("Index", new { Message = "That does not exist" }); } AddEditDictataViewModel vModel = new AddEditDictataViewModel(lex, obj) { AuthedUser = UserManager.FindById(User.Identity.GetUserId()) }; return View("~/Views/GameAdmin/Dictionary/EditDictata.cshtml", vModel); }
public ActionResult Edit(string id) { ILexeme obj = ConfigDataCache.Get<ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), id, ConfigDataType.Dictionary)); if (obj == null) { string message = "That does not exist"; return RedirectToAction("Index", new { Message = message }); } AddEditDictionaryViewModel vModel = new AddEditDictionaryViewModel(obj.WordForms) { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), DataObject = (Lexeme)obj }; return View("~/Views/GameAdmin/Dictionary/Edit.cshtml", vModel); }
public ActionResult Add(AddEditDictionaryViewModel vModel) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); ILexeme newObj = vModel.DataObject; string message; if (newObj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - AddLexeme[" + newObj.UniqueKey + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Creation Successful."; } else { message = "Error; Creation failed."; } return RedirectToAction("Index", new { Message = message }); }
/// <summary> /// Create or modify a lexeme within this language /// </summary> /// <param name="word">the word we're making</param> /// <returns></returns> public ILexeme CreateOrModifyLexeme(string word, LexicalType form, string[] semantics) { word = word.ToLower(); Regex rgx = new Regex("[^a-z -]"); word = rgx.Replace(word, ""); if (string.IsNullOrWhiteSpace(word) || word.All(ch => ch == '-') || word.IsNumeric()) { return(null); } ILexeme lex = ConfigDataCache.Get <ILexeme>(string.Format("{0}_{1}_{2}", ConfigDataType.Dictionary, Name, word)); if (lex == null) { lex = new Lexeme() { Name = word, Language = this }; lex.SystemSave(); lex.PersistToCache(); } if (form != LexicalType.None && lex.GetForm(form, semantics, false) == null) { var newDict = new Dictata() { Name = word, WordType = form, Language = this, Semantics = new HashSet <string>(semantics) }; lex.AddNewForm(newDict); } return(lex); }
/// <summary> /// Verify the dictionary has this word already /// </summary> /// <param name="lexeme">dictata to check</param> public static ILexeme VerifyLexeme(ILexeme lexeme) { if (lexeme == null || string.IsNullOrWhiteSpace(lexeme.Name) || lexeme.Name.IsNumeric()) { return(null); } var deepLex = false; //Set the language to default if it is absent and save it, if it has a language it already exists if (lexeme.Language == null) { IGlobalConfig globalConfig = ConfigDataCache.Get <IGlobalConfig>(new ConfigDataCacheKey(typeof(IGlobalConfig), "LiveSettings", ConfigDataType.GameWorld)); if (globalConfig.BaseLanguage != null) { lexeme.Language = globalConfig.BaseLanguage; } deepLex = globalConfig?.DeepLexActive ?? false; } ILexeme maybeLexeme = ConfigDataCache.Get <ILexeme>(string.Format("{0}_{1}_{2}", ConfigDataType.Dictionary, lexeme.Language, lexeme.Name)); if (maybeLexeme != null) { lexeme = maybeLexeme; } lexeme.IsSynMapped = false; lexeme.PersistToCache(); lexeme.SystemSave(); lexeme.MapSynNet(); return(lexeme); }
private IToken CreateTokenFromLexeme(ILexeme lexeme) { var capture = lexeme.Capture; return new Token( capture, Position - capture.Length - 1, lexeme.TokenType); }
private void FreeLexeme(ILexeme lexeme) { var lexemeFactory = _lexemeFactoryRegistry.Get(lexeme.LexerRule.LexerRuleType); lexemeFactory.Free(lexeme); }
public IEnumerable <ILexeme <Matrix> > Parse(string inputString) { var lexemes = new List <ILexeme <Matrix> >(); var index = 0; while (index <= inputString.Length - 1) { if (char.IsWhiteSpace(inputString[index])) { ++index; continue; } ILexeme <Matrix> lexeme = null; foreach (var operationLexeme in OperationLexemes) { if (operationLexeme.Key.Length > inputString.Length - index) { continue; } var stringLexeme = inputString.Substring(index); if (stringLexeme.StartsWith(operationLexeme.Key)) { lexeme = operationLexeme; var last = lexemes.LastOrDefault(); if (last == null || ((last is IBinaryOperationLexeme <Matrix> || last is IOpenTagLexeme <Matrix>) && (lexeme is IBinaryOperationLexeme <Matrix>))) { var sameUnary = OperationLexemes.FirstOrDefault(op => op.Key == operationLexeme.Key && op is IUnaryOperationLexeme <Matrix>); if (sameUnary != null) { lexeme = sameUnary; } } index += operationLexeme.Key.Length; break; } } if (lexeme == null && inputString[index] == '[') { var end = inputString.IndexOf(']', index); if (end != -1) { var matrixString = inputString.Substring(index + 1, end - index - 1); var stringRows = matrixString.Split(';', StringSplitOptions.RemoveEmptyEntries); var regex = new Regex(@"\s+", RegexOptions.IgnoreCase | RegexOptions.Compiled); var columnCount = regex.Replace(stringRows.FirstOrDefault(), " ").Split(' ', StringSplitOptions.RemoveEmptyEntries).Length; var matrix = new Matrix(stringRows.Length, columnCount); for (int r = 0; r < stringRows.Length; ++r) { var stringRow = regex.Replace(stringRows[r], " "); var cols = stringRow.Split(' ', StringSplitOptions.RemoveEmptyEntries); if (cols.Length != columnCount) { throw new InvalidOperationException("Invalid input."); } for (int c = 0; c < cols.Length; ++c) { if (!double.TryParse(cols[c], NumberStyles.Any, CultureInfo.InvariantCulture, out var value)) { throw new InvalidOperationException("Invalid input."); } matrix[r, c] = value; } } lexeme = new OperantLexeme <Matrix>(matrix); index = end + 1; } } if (lexeme != null) { lexemes.Add(lexeme); } else { throw new Exception("Incorrent syntax."); } } return(lexemes); }
public ActionResult EditDictata(string lexemeId, string id, AddEditDictataViewModel vModel) { string message = string.Empty; ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); ILexeme lex = ConfigDataCache.Get<ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), lexemeId, ConfigDataType.Dictionary)); IDictata obj = lex?.WordForms?.FirstOrDefault(form => form.UniqueKey == id); if (obj == null) { message = "That does not exist"; return RedirectToAction("Index", new { Message = message }); } obj.Name = vModel.DataObject.Name; obj.Severity = vModel.DataObject.Severity; obj.Quality = vModel.DataObject.Quality; obj.Elegance = vModel.DataObject.Elegance; obj.Tense = vModel.DataObject.Tense; obj.Synonyms = vModel.DataObject.Synonyms; obj.Antonyms = vModel.DataObject.Antonyms; obj.PhraseSynonyms = vModel.DataObject.PhraseSynonyms; obj.PhraseAntonyms = vModel.DataObject.PhraseAntonyms; obj.Language = vModel.DataObject.Language; obj.WordType = vModel.DataObject.WordType; obj.Feminine = vModel.DataObject.Feminine; obj.Possessive = vModel.DataObject.Possessive; obj.Plural = vModel.DataObject.Plural; obj.Determinant = vModel.DataObject.Determinant; obj.Positional = vModel.DataObject.Positional; obj.Perspective = vModel.DataObject.Perspective; obj.Semantics = vModel.DataObject.Semantics; lex.AddNewForm(obj); if (lex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { foreach (IDictata syn in obj.Synonyms) { if (!syn.Synonyms.Any(dict => dict == obj)) { HashSet<IDictata> synonyms = syn.Synonyms; synonyms.Add(obj); ILexeme synLex = syn.GetLexeme(); syn.Synonyms = synonyms; synLex.AddNewForm(syn); synLex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)); } } foreach (IDictata ant in obj.Antonyms) { if (!ant.Antonyms.Any(dict => dict == obj)) { HashSet<IDictata> antonyms = ant.Antonyms; antonyms.Add(obj); ILexeme antLex = ant.GetLexeme(); ant.Antonyms = antonyms; antLex.AddNewForm(ant); antLex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)); } } foreach (IDictataPhrase syn in obj.PhraseSynonyms) { if (!syn.Synonyms.Any(dict => dict == obj)) { HashSet<IDictata> synonyms = syn.Synonyms; synonyms.Add(obj); syn.Synonyms = synonyms; syn.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)); } } foreach (IDictataPhrase ant in obj.PhraseAntonyms) { if (!ant.Antonyms.Any(dict => dict == obj)) { HashSet<IDictata> antonyms = ant.Antonyms; antonyms.Add(obj); ant.Antonyms = antonyms; ant.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)); } } LoggingUtility.LogAdminCommandUsage("*WEB* - EditDictata[" + obj.UniqueKey + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Edit Successful."; } else { message = "Error; Edit failed."; } return RedirectToAction("Index", new { Message = message }); }
private IToken CreateTokenFromLexeme(ILexeme lexeme) { return new Token( lexeme.Capture, Position - lexeme.Capture.Length, lexeme.TokenType); }
public ActionResult AddRelatedWord(string lexemeId, string id, AddEditDictataViewModel vModel) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); ILexeme lex = ConfigDataCache.Get<ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), lexemeId, ConfigDataType.Dictionary)); if (lex == null) { return RedirectToAction("Index", new { Message = "That does not exist" }); } IDictata dict = lex.WordForms.FirstOrDefault(form => form.UniqueKey == id); if (dict == null) { return RedirectToAction("Index", new { Message = "That does not exist" }); } Lexeme relatedLex = new Lexeme { Name = vModel.Word, Language = lex.Language }; Dictata relatedWord = new Dictata() { Name = vModel.Word, Severity = dict.Severity + vModel.Severity, Quality = dict.Quality + vModel.Quality, Elegance = dict.Elegance + vModel.Elegance, Tense = dict.Tense, Language = dict.Language, WordType = dict.WordType, Feminine = dict.Feminine, Possessive = dict.Possessive, Plural = dict.Plural, Determinant = dict.Determinant, Positional = dict.Positional, Perspective = dict.Perspective, Semantics = dict.Semantics }; HashSet<IDictata> synonyms = dict.Synonyms; synonyms.Add(dict); if (vModel.Synonym) { relatedWord.Synonyms = synonyms; relatedWord.Antonyms = dict.Antonyms; relatedWord.PhraseSynonyms = dict.PhraseSynonyms; relatedWord.PhraseAntonyms = dict.PhraseAntonyms; } else { relatedWord.Synonyms = dict.Antonyms; relatedWord.Antonyms = synonyms; relatedWord.PhraseSynonyms = dict.PhraseAntonyms; relatedWord.PhraseAntonyms = dict.PhraseSynonyms; } relatedLex.AddNewForm(relatedWord); string message; if (relatedLex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { if (vModel.Synonym) { HashSet<IDictata> mySynonyms = dict.Synonyms; mySynonyms.Add(relatedWord); dict.Synonyms = mySynonyms; } else { HashSet<IDictata> antonyms = dict.Antonyms; antonyms.Add(relatedWord); dict.Antonyms = antonyms; } lex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)); relatedLex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)); LoggingUtility.LogAdminCommandUsage("*WEB* - EditLexeme[" + lex.UniqueKey + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Edit Successful."; } else { message = "Error; Edit failed."; } return RedirectToAction("Index", new { Message = message }); }