当前位置: 首页>>代码示例>>C#>>正文


C# Tokenizer.Tokenizing方法代码示例

本文整理汇总了C#中Tokenizer.Tokenizing方法的典型用法代码示例。如果您正苦于以下问题:C# Tokenizer.Tokenizing方法的具体用法?C# Tokenizer.Tokenizing怎么用?C# Tokenizer.Tokenizing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tokenizer的用法示例。


在下文中一共展示了Tokenizer.Tokenizing方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: m_tokenizingWorker_DoWork

        private void m_tokenizingWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            string[] _lines = txtbox_input.Lines;
            int _currentProgress = 0;
            m_tokenizingWorker.ReportProgress(0);

            try
            {
                foreach (string _line in _lines)
                {
                    try
                    {
                        string _inputPath = _line.Replace("\r", String.Empty);
                        var _readStream = new System.IO.FileStream(_inputPath,
                                          System.IO.FileMode.Open,
                                          System.IO.FileAccess.Read,
                                          System.IO.FileShare.ReadWrite);
                        var _reader = new System.IO.StreamReader(_readStream, System.Text.Encoding.UTF8, true, 128);

                        string _id = _reader.ReadLine();
                        string _friendly_url = _reader.ReadLine();
                        string _title = _reader.ReadLine();
                        string _tags = _reader.ReadLine();
                        string _content = _reader.ReadToEnd();

                        _reader.Dispose();
                        _readStream.Dispose();

                        Tokenizer _tokenizer = new Tokenizer();

                        ArrayList _result = null;
                        if (m_untokenizedOutputDirectory == "")
                            _result = _tokenizer.Tokenizing(_content);
                        else
                            _result = _tokenizer.Tokenizing(_content, true, m_untokenizedOutputDirectory + "\\" + _id + '-' + _friendly_url + ".not");

                        string _outputPath = m_outputDirectory + "\\" + _id + '-' + _friendly_url + ".tok";
                        var _writetream = new System.IO.FileStream(_outputPath,
                                          System.IO.FileMode.Create,
                                          System.IO.FileAccess.Write,
                                          System.IO.FileShare.ReadWrite);
                        var _writer = new System.IO.StreamWriter(_writetream, System.Text.Encoding.UTF8, 128);
                        _writer.Write(_id + Environment.NewLine + _friendly_url + Environment.NewLine +
                                        _title + Environment.NewLine + _tags + Environment.NewLine +
                                        string.Join(Environment.NewLine, _result.ToArray(typeof(string)) as string[]));

                        _writer.Dispose();
                        _writetream.Dispose();

                        m_inputTokenized += _outputPath + Environment.NewLine;

                        _currentProgress++;
                        m_tokenizingWorker.ReportProgress(_currentProgress * 100 / _lines.Count());

                        if(m_tokenizingWorker.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }
                    }
                    catch
                    {

                    }
                }
            }
            catch
            {
                MessageBox.Show("No file to tokenize. Process failed...");
            }
        }
开发者ID:uit-cs217-g11,项目名称:smart-search,代码行数:71,代码来源:MainForm.cs


注:本文中的Tokenizer.Tokenizing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。