private void createtrie(string[] words, string[] meanings) { int lim = words.Length; int wind = 0; int meanind = 0; int limit = words.Length; for (wind = 0; wind < limit; wind++) { string w = words[wind]; hashtable2.Add(w, meanings[meanind]); char[] ar = w.ToCharArray(); node t = root; int index = 0; foreach (var i in ar)//var is char { index++; node newnode = new node(i); t = insert(t, newnode); if (index == ar.Length) { newnode = new node('#');//Marks the end of the word t = insert(t, newnode); } }//A word is created hashtable.Add(w, s_no++); definition freq_and_mean = new definition(0, "no"); meaning_list.Add(freq_and_mean); meanind += 2; //feed_to_db(w); } }
///// <summary> ///// 当前循环集合 ///// </summary> //protected object _loopValues_; ///// <summary> ///// 当前循环值 ///// </summary> //protected object _loopValue_; /// <summary> /// 输出类定义开始段代码 /// </summary> /// <param name="language">代码生成语言</param> /// <param name="isOutDefinition">是否输出类定义</param> /// <returns>类定义</returns> protected bool outStart(fastCSharp.code.auto.language language, bool isOutDefinition) { _definition_ = null; _language_ = language; if (isOutDefinition) { _code_.Empty(); if (fastCSharp.code.coder.Add(GetType(), type.Type)) { switch (_language_) { case auto.language.JavaScript: case auto.language.TypeScript: _definition_ = new definition.javaScript(type); break; default: _definition_ = new definition.cSharp(type, true, false); break; } _code_.Add(_definition_.Start); return(true); } return(false); } return(true); }
///// <summary> ///// 当前循环集合 ///// </summary> //protected object _loopValues_; ///// <summary> ///// 当前循环值 ///// </summary> //protected object _loopValue_; /// <summary> /// 输出类定义开始段代码 /// </summary> /// <returns>类定义</returns> protected definition outStart() { if (fastCSharp.setup.cSharp.coder.Add(GetType(), CodeType.Type, null)) { definition definition = new definition(type, true, false); _code_.Empty(); _code_.Add(definition.Start); return(definition); } return(null); }
void inputafterenter() { if ((correct_input == 0) && (incorrect_input == 0))//no char entered { predictionbox.Visible = false; label1.Visible = false; return; } if ((cont == true) && (incorrect_input == 0)) { if (next.data == '#') { word_found(sear); complete_word = true; } else { while (next.sibling != null)//this special while loop is for those words //which had their prefixes as an independent word in the database. //eg:kill...the word kill has kil as a prefix which is in the trie { next = next.sibling; if (next.data == '#') { word_found(sear); complete_word = true; return; } } } if (complete_word == true) { int i; int.TryParse((hashtable[sear]).ToString(), out i); definition d = meaning_list[i]; d.incfreq(); meaning_list.RemoveAt(i); meaning_list.Insert(i, d); } if (complete_word == false)//incomplete word { let_me_complete_it(); } } if ((cont == true) && (complete_word != false))//correct match { predictionbox.ResetText(); predictionbox.Visible = false; } refresh_for_next_word(); }
private void sorted_predictions(List <string> wordlist, int xcord = 0) { int k = 0; int[] t = new int[wordlist.Count]; //label2.Text = t.ToString(); for (k = 0; k < t.Length; k++) { t[k] = k; } int i, key, j, key_t; int[] frqs = new int[wordlist.Count]; k = 0; foreach (var word in wordlist) { int ind; int.TryParse((hashtable[word]).ToString(), out ind); definition d = meaning_list[ind]; frqs[k] = d.freq; k++; } for (i = 1; i < k; i++) { key = frqs[t[i]]; key_t = t[i]; j = i - 1; while (j >= 0 && frqs[t[j]] < key) { t[j + 1] = t[j]; j = j - 1; } t[j + 1] = key_t; } List <string> sorted = new List <string>(); for (int v = 0; v < k; v++) { sorted.Add(wordlist[t[v]]); } predictionbox.DataSource = null; predictionbox.DataSource = sorted; }
/// <summary> /// 安装下一个类型 /// </summary> protected override void NextCreate() { if (!serviceAttributes.TryGetValue(Attribute.ServiceName, out ServiceAttribute)) { serviceAttributes.Add(Attribute.ServiceName, ServiceAttribute = tcpServer.GetConfig(Attribute.ServiceName)); } if (Attribute.VerifyType != null) { ServiceAttribute.VerifyType = Attribute.VerifyType; } int methodIndex = methodIndexs.Count; MethodIndexs = methodInfo.GetMethods <tcpCall>(type, Attribute.filter, false, Attribute.IsAttribute, Attribute.IsBaseTypeAttribute, Attribute.IsInheritAttribute) .getArray(value => new methodIndex { Method = value, MethodIndex = methodIndex++, MethodType = type, ServiceAttribute = ServiceAttribute, TypeAttribute = Attribute, IsTypeGenericParameterName = type.Type.IsGenericType }); methodIndexs.Add(MethodIndexs); if (ServiceAttribute.IsSegmentation) { stringBuilder clientCallCode; if (!clientCallCodes.TryGetValue(Attribute.ServiceName, out clientCallCode)) { clientCallCodes.Add(Attribute.ServiceName, clientCallCode = new stringBuilder()); } definition definition = new definition(type, true, false); _code_.Empty(); create(false); fastCSharp.setup.cSharp.coder.Add(GetType(), CodeType.Type, definition.Start + _partCodes_["SERVERCALL"] + definition.End); clientCallCode.Add(definition.Start + _partCodes_["CLIENTCALL"] + definition.End); } else { create(true); } }
/// <summary> /// 获取所有Definition信息 /// </summary> /// <returns></returns> public OperateResult GetAllDefinition(int cid) { using (var db = new CGDataBase()) { var list = db.jb_definition.Where(jd => jd.c_id == cid).ToList(); if (list != null) { List <definition> definitionList = new List <definition>(); foreach (var item in list) { definition definition = new definition() { id = item.id, desc = item.desc, content = StringDispose.AESDecrypt(item.content), c_id = cid }; definitionList.Add(definition); } return(new OperateResult(ResultStatus.Success, "", definitionList)); } return(new OperateResult(ResultStatus.Error, "错误,找不到数据")); } }
public ActionResult CodeAdd(RequestFormInfo formInfo, int bl, int kj, int qj, int mr, int jssx, int ff) { //遍历自定义变量并放入集合 List <definition> bianlianglist = new List <definition>(); for (int i = 1; i <= bl; i++) { string desc = Request.Form["bldesc" + i]; string content = Request.Form["bl" + i]; if (!string.IsNullOrWhiteSpace(desc) && !string.IsNullOrWhiteSpace(content)) { definition definition = new definition() { desc = desc, content = content }; bianlianglist.Add(definition); } } //遍历控件部件并放入集合 List <components> kongjianList = new List <components>(); for (int i = 1; i <= kj; i++) { string desc = Request.Form["kjdesc" + i]; string content = Request.Form["kj" + i]; if (!string.IsNullOrWhiteSpace(desc) && !string.IsNullOrWhiteSpace(content)) { components components = new components() { desc = desc, content = content }; kongjianList.Add(components); } } //遍历全局变量并放入集合 List <data> quanjuList = new List <data>(); for (int i = 1; i <= qj; i++) { string content = Request.Form["qjdesc" + i]; string desc = Request.Form["qj" + i]; if (!string.IsNullOrWhiteSpace(content) && !string.IsNullOrWhiteSpace(desc)) { data data = new data() { content = content, desc = desc }; quanjuList.Add(data); } } //遍历默认数据并放入集合 List <@default> morenList = new List <@default>(); for (int i = 1; i <= mr; i++) { string desc = Request.Form["mrdesc" + i]; string key = Request.Form["mrkey" + i]; string value = Request.Form["mrvalue" + i]; if (!string.IsNullOrWhiteSpace(desc) && !string.IsNullOrWhiteSpace(key) && !string.IsNullOrWhiteSpace(value)) { @default @default = new @default() { desc = desc, key = key, value = value }; morenList.Add(@default); } } //遍历计算属性并放入集合 List <computed> jssxList = new List <computed>(); for (int i = 1; i <= jssx; i++) { string jssxname = Request.Form["jssxname" + i]; string jssxdesc = Request.Form["jssxdesc" + i]; string jssxff = Request.Form["jssxff" + i]; if (!string.IsNullOrWhiteSpace(jssxname) && !string.IsNullOrWhiteSpace(jssxdesc) && !string.IsNullOrWhiteSpace(jssxff)) { computed computed = new computed() { desc = jssxdesc, name = jssxname, content = jssxff }; jssxList.Add(computed); } } //遍历控件方法并放入集合 List <rests> qtfangfaList = new List <rests>(); for (int i = 1; i <= ff; i++) { string qtffname = Request.Form["qtffname" + i]; string qtffdesc = Request.Form["qtffdesc" + i]; string qtffti = Request.Form["qtffti" + i]; if (!string.IsNullOrWhiteSpace(qtffname) && !string.IsNullOrWhiteSpace(qtffdesc) && !string.IsNullOrWhiteSpace(qtffti)) { rests rests = new rests() { name = qtffname, desc = qtffdesc, content = qtffti }; qtfangfaList.Add(rests); } } //遍历控件方法并放入集合 List <methods> fangfaList = new List <methods>(); for (int i = 1; i <= ff; i++) { string ffname = Request.Form["ffname" + i]; string ffdesc = Request.Form["ffdesc" + i]; string ffti = Request.Form["ffti" + i]; if (!string.IsNullOrWhiteSpace(ffname) && !string.IsNullOrWhiteSpace(ffdesc) && !string.IsNullOrWhiteSpace(ffti)) { methods methods = new methods() { name = ffname, desc = ffdesc, content = ffti }; fangfaList.Add(methods); } } //调用方法开始进行数据库存储 //实例化代码入库类 CodeDataBase codeInDataBase = new CodeDataBase(); int result = codeInDataBase.AddCodeInBase(formInfo, bianlianglist, kongjianList, quanjuList, morenList, jssxList, qtfangfaList, fangfaList); switch (result) { case 0: return(Json(new { code = 1, msg = "代码入库失败!" }, JsonRequestBehavior.AllowGet)); case 1: return(Json(new { code = 1, msg = "代码入库成功!" }, JsonRequestBehavior.AllowGet)); case 2: return(Json(new { code = 1, msg = "html代码入库失败!" }, JsonRequestBehavior.AllowGet)); case 3: return(Json(new { code = 1, msg = "Css样式入库失败!" }, JsonRequestBehavior.AllowGet)); case 4: return(Json(new { code = 1, msg = "自定义变量入库失败!" }, JsonRequestBehavior.AllowGet)); case 5: return(Json(new { code = 1, msg = "控件部件入库失败!" }, JsonRequestBehavior.AllowGet)); case 6: return(Json(new { code = 1, msg = "全局变量入库失败!" }, JsonRequestBehavior.AllowGet)); case 7: return(Json(new { code = 1, msg = "默认数据入库失败!" }, JsonRequestBehavior.AllowGet)); case 8: return(Json(new { code = 1, msg = "计算属性入库失败!" }, JsonRequestBehavior.AllowGet)); case 9: return(Json(new { code = 1, msg = "控件方法入库失败!" }, JsonRequestBehavior.AllowGet)); case 10: return(Json(new { code = 1, msg = "添加到PageShow页面失败!" }, JsonRequestBehavior.AllowGet)); } return(View()); }
internal T LookupOrStartThunk <T>(Definition definition, IAddress?address) => ActorAs <T>(ActorLookupOrStartThunk(definition, address) !);
set => AddPiece(definition, value);
exports = GetExportsCore(definition, atomicComposition);
void AcceptStringInput(string userInput) { //Grabs the text from the game object thetext = textBox.GetComponent <Text>(); //Grabs the word to search from user input string word = userInput.ToLower(); //Retrieve the textbox for the Webster API string words = thetext.text.ToLower().Replace("\n", " "); //Split input into seperate words (split by single space) //Using StringSplitOptions.RemoveEmptyEntries helps get rid of extra space so it does not search for space //string[] strings = inputField.text.ToLower().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); //Split text box into seperate words (split by single space) string[] strings = words.Split(' '); int i = 0; //If the text contains my input from the input field return found to unity console, else return not found Debug.Log("Length: " + strings.Length); while (i < strings.Length) { if (definition.RemoveSpecialCharacters(strings[i].Replace("’", "'")).Equals(definition.RemoveSpecialCharacters(word))) { Debug.Log("FOUND: " + word); definition def = new definition(); int wordPos = i; Debug.Log("Position: " + wordPos); List <string> strResults = def.getWebsterDef(words, wordPos, word); if (strResults.Count >= 2) { while (strResults[1].Replace(":", "").Replace(" ", "").Length < 1) { strResults[1] = strResults[2]; strResults.RemoveAt(2); } theWord.text = (word + "\n-----------\n" + strResults[0] + "\n\n" + strResults[1]).Replace(":", ""); //Amelia - added .Replace(":","") } //theWord.text = (word + "\n_______\n" + strResults[0] + "\n" + strResults[1]); else if (strResults.Count == 1) { theWord.text = (word + "\n-----------\n" + strResults[0]).Replace(":", ""); //Amelia - added .Replace(":","") } else if (word.Length == 1 && strResults.Count == 0) { theWord.text = word + "\n-----------\n" + "No definition found."; } //call function for finding definition with inputField.text.ToLower(); //lowercase ver of string break; } else { theWord.text = word + "\nWord not in text.\n"; Debug.Log("NOT FOUND: " + word); } i++; } //After word is found, input field is cleared and has focus InputComplete(); }
///// <summary> ///// 当前循环集合 ///// </summary> //protected object _loopValues_; ///// <summary> ///// 当前循环值 ///// </summary> //protected object _loopValue_; /// <summary> /// 输出类定义开始段代码 /// </summary> /// <returns>类定义</returns> protected definition outStart() { if (fastCSharp.setup.cSharp.coder.Add(GetType(), CodeType.Type, null)) { definition definition = new definition(type, true, false); _code_.Empty(); _code_.Add(definition.Start); return definition; } return null; }