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


C# Indexer.Indexing方法代码示例

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


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

示例1: m_indexingWorker_DoWork

        private void m_indexingWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            string[] _lines = txtbox_tokenized.Lines;
            int _currentProgress = 0;
            m_indexingWorker.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();
                        ArrayList _wordsTokenized = new ArrayList();
                        string _wordToken = null;

                        while ((_wordToken = _reader.ReadLine()) != null)
                        {
                            _wordsTokenized.Add(_wordToken);
                        }

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

                        Indexer _indexer = new Indexer();
                        ArrayList _result = _indexer.Indexing(_title, _tags, _wordsTokenized);

                        string _outputPath = m_outputDirectory + "\\" + _id + '-' + _friendly_url + ".ind";
                        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);

                        foreach (Word _word in _result)
                        {
                            _writer.WriteLine(_word.m_content + '|' + _word.m_weight + '|' + 1);
                        }

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

                        m_inputIndexed += _outputPath + Environment.NewLine;

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

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

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


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