static void Main(string[] args) { WordsssDBManager dbManager = new WordsssDBManager(); //if (dbManager.addWord("test")) // Console.WriteLine("添加成功"); //if (dbManager.deleteWord(3)) // Console.WriteLine("delete successfully"); //if (dbManager.updateWord(2,"updateword")) // Console.WriteLine("update successfully"); /*Console.WriteLine(dbManager.queryWord(1)); var result = dbManager.getAllWord(); foreach (var word in result) { Console.WriteLine(word); } */ //Console.Write("word_name:"); //string word_name = Console.ReadLine(); //Console.Write("word_paraphase:"); //string word_paraphase = Console.ReadLine(); //dbManager.addParaphase(word_name, 0, word_paraphase); /*dbManager.updateParaphase(1,0,"update关于"); var paraphaseList = dbManager.getParaphase("about", 0); foreach (string paraphase in paraphaseList) { Console.WriteLine(paraphase); } dbManager.deleteParagraph(2, 0); var paraphaseList2 = dbManager.getParaphase("about", 0); foreach (string paraphase in paraphaseList2) { Console.WriteLine(paraphase); }*/ StreamReader reader = new StreamReader("oxford.txt",Encoding.GetEncoding("gb2312")); while (!reader.EndOfStream) { string s = reader.ReadLine(); string[] split = s.Split(new char[] { ' ' }, 2); string word_name = split[0]; string paraphase = split[1]; // dbManager.addParaphase(word_name, 1, paraphase); Console.WriteLine("{0} {1}", word_name, paraphase); } dbManager.CloseManager(); }
static void Main(string[] args) { XmlDocument doc = new XmlDocument(); doc.Load("wl.xml"); XmlNode dictNode = doc.ChildNodes[1]; Console.WriteLine(dictNode.ChildNodes.Count); XmlNodeList wlWordList = dictNode.ChildNodes; FileStream fs = new FileStream("result.txt", FileMode.Create); StreamWriter writer = new StreamWriter(fs); int count = 0; WordsssDBManager manager = new WordsssDBManager(); foreach (XmlNode wordNode in wlWordList) { string word_name; string word_meaning; word_name = wordNode.SelectSingleNode("单词").FirstChild.Value; word_meaning = wordNode.SelectSingleNode("单词解释块/基本词义/单词项/解释项").FirstChild.Value; Regex matchWord = new Regex("^[a-z]+$"); if (matchWord.IsMatch(word_name)) { manager.addWlListWord(word_name, word_meaning); writer.WriteLine(word_name); writer.WriteLine(word_meaning); count++; if (count % 100 == 0) Console.WriteLine(count); } } writer.WriteLine(count); writer.Close(); manager.CloseManager(); }
static void Main(string[] args) { Regex matchWord = new Regex("^\\s([a-z]+)\\s*$"); //Regex matchWord = new Regex("^ "); Regex matchMeaning = new Regex("^[^\\s\\[]\\s*"); Regex matchMemory = new Regex("^\\[(.*)\\](.*)\\s*$"); FileStream fs = new FileStream("GRE.txt", FileMode.Open); StreamReader reader = new StreamReader(fs, Encoding.UTF8); FileStream fout = new FileStream("result.txt", FileMode.Create); StreamWriter writer = new StreamWriter(fout); int pos = 0; WordsssDBManager manager = new WordsssDBManager(); string word_name = ""; string word_meaning = ""; int gre_list_word_id = -1; int count = 0; bool begin = true; while (!reader.EndOfStream) { string strLine = reader.ReadLine(); if (pos == 0 && matchWord.IsMatch(strLine)) { word_name = matchWord.Match(strLine).Groups[1].Value; writer.WriteLine("word==>" + word_name); pos ++; } else if (pos == 1 && matchMeaning.IsMatch(strLine)) { word_meaning = strLine; writer.WriteLine("meaning==>" + strLine); pos++; if(begin) gre_list_word_id = manager.addGREListWord(word_name, word_meaning); if (count++ % 100 == 0) Console.WriteLine(count); } else if (pos == 2 && matchMemory.IsMatch(strLine)) { string type; string description; if (word_name == "capitulate") begin = true; type = matchMemory.Match(strLine).Groups[1].Value; description = matchMemory.Match(strLine).Groups[2].Value; writer.WriteLine("["+type+"]"+description); if(begin) manager.addGREListMemory(type, description, gre_list_word_id); } else if (pos == 2 && strLine == "") { pos = 0; } } manager.CloseManager(); writer.Close(); }
static void Main(string[] args) { XmlDocument doc = new XmlDocument(); doc.Load("cs.xml"); XmlNode dictNode = doc.ChildNodes[1]; Console.WriteLine(dictNode.ChildNodes.Count); XmlNodeList csWordList = dictNode.ChildNodes; FileStream fs = new FileStream("result.txt", FileMode.Create); StreamWriter writer = new StreamWriter(fs); int count = 0; WordsssDBManager manager = new WordsssDBManager(); foreach (XmlNode csWordNode in csWordList) { XmlNode word_name = csWordNode.SelectSingleNode("单词"); XmlNode word_meaning = csWordNode.SelectSingleNode("单词解释块/基本词义/单词项/解释项"); Regex pattern = new Regex("^[a-z]+$"); Regex pattern2 = new Regex(",[ ]*[A-Z]+$"); if (pattern.IsMatch(word_name.FirstChild.Value)) { string strName = word_name.FirstChild.Value; string strMeaning = word_meaning.FirstChild.Value; manager.addCsListWord(strName, "", strMeaning); writer.WriteLine(word_name.FirstChild.Value); writer.WriteLine(word_meaning.FirstChild.Value); count++; if (count % 100 == 0) { Console.WriteLine(count); } } else if (pattern2.IsMatch(word_name.FirstChild.Value)) { string strName = word_name.FirstChild.Value; Regex patterShort = new Regex("[A-Z]+$"); string shortName = patterShort.Match(strName).Value; string[] strSplit = strName.Split(new char[]{','},StringSplitOptions.RemoveEmptyEntries); string fullName = strSplit[0]; shortName = shortName.Replace(" ", ""); fullName = fullName.Replace("'", "''"); manager.addCsListWord(shortName, fullName, word_meaning.FirstChild.Value); writer.WriteLine("-"+shortName); writer.WriteLine(fullName); writer.WriteLine(word_meaning.FirstChild.Value); count ++; if (count % 100 == 0) { Console.WriteLine(count); } } } writer.WriteLine(count); writer.Close(); manager.CloseManager(); }
static void Main(string[] args) { XmlDocument doc = new XmlDocument(); doc.Load("GRE_sense.xml"); XmlNode wordDocument = doc.ChildNodes[2]; Console.WriteLine(wordDocument.Name); string uri = wordDocument.NamespaceURI; XmlNamespaceManager manager = new XmlNamespaceManager(doc.NameTable); manager.AddNamespace("w",uri); manager.AddNamespace("wsp","http://schemas.microsoft.com/office/word/2003/wordml/sp2"); XmlNodeList pList = wordDocument.SelectNodes("//w:p[@wsp:rsidR='00E60542']",manager); FileStream fs = new FileStream("sense2.txt", FileMode.Create); StreamWriter writer = new StreamWriter(fs); Console.WriteLine(pList.Count); WordsssDBManager dbManager = new WordsssDBManager(); int currentLevel = 0; Dictionary<int, int> senseParentDict = new Dictionary<int, int>(); for (int i = 0; i < 6; i++) { senseParentDict.Add(i,0); } foreach (XmlNode node in pList) { Regex pattern = new Regex("^[0-9.]+"); Regex pattern2 = new Regex("^[\u4e00-\u9fa5]"); Regex pattern3 = new Regex("^[a-z]+"); if (pattern.IsMatch(node.InnerText) || pattern2.IsMatch(node.InnerText)) { string num = ""; string sense_name = ""; int splitCount = 0; int senseId = 0; if (pattern.IsMatch(node.InnerText)) { num = pattern.Match(node.InnerText, 0).ToString(); splitCount = num.Split(new char[]{'.'},StringSplitOptions.RemoveEmptyEntries).Count(); sense_name = node.InnerText.Replace(num,"").Replace(" ",""); } else { num = node.InnerText.Split(' ')[0]; sense_name = node.InnerText.Split(' ')[1]; } while (currentLevel >= splitCount) { currentLevel--; } currentLevel++; if (currentLevel != 0) { int parentId = senseParentDict[currentLevel-1]; senseId = dbManager.addSense(sense_name, parentId); writer.WriteLine(sense_name + "--->" + senseId + "," + parentId); // add sense_name.Peek() as parent into current num } else { senseId = dbManager.addSense(sense_name); writer.WriteLine(sense_name + "--->" + senseId); } senseParentDict[currentLevel] = senseId; } else if(pattern3.IsMatch(node.InnerText)) { string word_name = pattern3.Match(node.InnerText).ToString(); string word_meaning = node.InnerText.Replace(word_name, "").Remove(0,1); int senseId = senseParentDict[currentLevel]; dbManager.addWordSense(word_name,senseId,word_meaning); writer.WriteLine(word_name + "--->" + senseId); writer.WriteLine(word_meaning); } } dbManager.CloseManager(); writer.Close(); }