public void Parse(string html, int location) { TextProcess proc = new TextProcess(); parseProperties(html, proc, location); int end = 0; for (int i = this.location + 1; i < html.Length; i++) { if (html[i] == '<') { if (html[i + 1] == '/') { end = html.IndexOf('>', i + 1); string name = proc.Cut(html, i + 2, end - 1); if (TagName == name) { TagClosed = true; location = end; break; } } else { tags.Add(new HtmlTag(html, i, this)); i = tags[tags.Count - 1].location; continue; } } } }
private async void TextBox_data_MouseDoubleClick(object sender, MouseButtonEventArgs e) { var fileName = MyLib.Open(); if (fileName == null) { return; } var encodingSelected = MessageBox.Show("\"Yes\" to use UTF-8\r\n\"No\" to use UTF-16 (Unicode)", "", MessageBoxButton.YesNo); if (encodingSelected == MessageBoxResult.None) { return; } Log.Assert(encodingSelected == MessageBoxResult.Yes || encodingSelected == MessageBoxResult.No); var encoding = encodingSelected == MessageBoxResult.Yes ? Encoding.UTF8 : Encoding.Unicode; int dataPreprocessMethodId = radioPanel_newData.SelectedIndex; bool debugMode = (bool)checkBox_debugMode.IsChecked; await stackPanel_tasksQueue.EnqueueTaskAsync($"Read Data {fileName} {encoding} {debugMode} {dataPreprocessMethodId}", new Func <Task>(async() => { mainData = await Task.Run(() => TextProcess.ReadTextStream(new FileStream(fileName, FileMode.Open, FileAccess.Read), encoding, debugMode)); await Task.Run(() => TextProcess.Process(ref mainData, dataPreprocessMethodId)); Log.Write(" OK"); })); }
public void ProcessFileTest() { TextProcess file = new TextProcess(); file.ProcessFile("testTXT.txt"); string expectedData = "Work with Text file"; Assert.AreEqual(expectedData, file.Data); }
public HtmlTag(string html, int location, HtmlTag tag) { using (TextProcess proc = new TextProcess()) { StringBuilder b = new StringBuilder(); int index = 0; for (int i = location + 1; i < html.Length; i++) { if (html[i] == '>') { index = i; if (PropertiesParsed == false) { TagName = b.ToString(); PropertiesParsed = true; break; } } if (char.IsWhiteSpace(html[i]) == true) { index = i; TagName = b.ToString(); break; } if (html[i] != '>' && char.IsWhiteSpace(html[i]) != true) { b.Append(html[i]); } } TagName = b.ToString(); if (PropertiesParsed == false) { parseProperties(html, proc, index); PropertiesParsed = true; } Parse(html, index); } }
void BuildData(Stream s, Encoding encoding, int dataPreprocessMethodId, int maxWordLength, bool debugMode) { Log.SubTask(() => { Log.AppendLog($"maxWordLength: {maxWordLength}"); int methodId = radioPanel_newData.SelectedIndex; Log.WriteLine($"Data preprocessing method: {dataPreprocessMethodId}"); string data = TextProcess.ReadTextStream(s, encoding, debugMode); Log.AppendLog($"Charactors Read = {data.Length}"); Log.WriteLine("Preprocessing Data..."); TextProcess.Process(ref data, dataPreprocessMethodId); OutputText = data.Length > 10000 ? data.Remove(10000) : data; long baseDataLength = data.Length; Log.AppendLog($"baseDataLength: {baseDataLength}"); Dispatcher.Invoke(() => inputField_data["baseDataLength"].Text = baseDataLength.ToString()); Log.WriteLine("TrieTabPage.BuildData..."); trie.Build(data, maxWordLength); Log.Write(" OK"); }); }
void SetContent(string content) { text.text = TextProcess.Process(content); }
void parseProperties(string html, TextProcess proc, int loc) { StringBuilder builder = new StringBuilder(); int end = 0; string propertyValue = ""; string propertyName = ""; int mode = 0; for (int i = loc; i < html.Length; i++) { if (html[i] == '"' || html[i] == '\'') { end = html.IndexOf(html[i], i + 1); propertyValue = proc.Cut(html, i + 1, end - 1); i = end; if (properties.ContainsKey(propertyName) == false) { properties.Add(propertyName, propertyValue); builder.Clear(); } continue; } if (html[i] == '>') { location = i; break; } if (html[i] == '=') { if (mode == 0) { propertyName = builder.ToString(); builder.Clear(); mode = 1; continue; } } if (mode == 1 && char.IsWhiteSpace(html[i]) == true) { if (properties.ContainsKey(propertyName) == false) { properties.Add(propertyName, builder.ToString()); builder.Clear(); } mode = 0; } if (mode == 0) { if (char.IsWhiteSpace(html[i]) == false) { builder.Append(html[i]); } } else { builder.Append(html[i]); } } }
public void Set(Info info) { StartCoroutine(Downloader.Instance.LoadTexture(info.imageUrl, OnTextureLoaded)); text.text = TextProcess.Process(info.description); }