public void CalcStatisticsSingle(RegExpProcessingParamsBase param, bool excludeLookarounds, string outputFileName) { using (var docsConnection = DatabaseHelper.CreateConnection(param.DocumentsDatabaseFilePath, param.Password)) { docsConnection.Open(); /////////////////////////////////////////////////////////////////////////////// var noteColumnCount = DatabaseHelper.GetNoteColumnCount(docsConnection, "Documents", "NOTE_TEXT"); var docsCount = DatabaseHelper.GetRowsCount(docsConnection, "Documents"); ////////////////////////////////////////////////////////////////////////////// List <int> noteColumnIndexList = new List <int>(); noteColumnIndexList.Add(1); /////////////////////////////////////////////////////////////////////////////// var selectQuery = "SELECT ED_ENC_NUM, NOTE_TEXT"; for (var i = 1; i < noteColumnCount; i++) { selectQuery += ", NOTE_TEXT" + i.ToString(); noteColumnIndexList.Add(i + 1); } selectQuery += " FROM Documents"; var documentRecords = DatabaseHelper.GetDataRecords(docsConnection, selectQuery); /////////////////////////////////////////////////////////////////////////////// if (excludeLookarounds) { _regExp.LookAhead.Items.Clear(); _regExp.NegLookAhead.Items.Clear(); _regExp.LookBehind.Items.Clear(); _regExp.NegLookBehind.Items.Clear(); _regExp.Build(); } /////////////////////////////////////////////////////////////////////////////// var results = Parallel_CalcStatisticsSingle(documentRecords, docsCount, 0, noteColumnIndexList); results.Serialize(param.GetFullPath(outputFileName)); if (_maxTotalMatchesReached) { _logger.AppendToLog("More than 20K overall matches found, aborting..."); } if (_maxUniqueMatchesReached) { _logger.AppendToLog("More than 500 unique matches found, aborting..."); } } }
public static int Main(string[] arguments) { try { if (arguments.Length < 1) { return(1); } /////////////////////////////////////////////////////////////////////////////// if (Properties.Settings.Default.ShowStartupMessage) { MessageBox.Show("TOOL STARTED"); } /////////////////////////////////////////////////////////////////////////////// var startupDelay = Properties.Settings.Default.StartupDelay; if (startupDelay > 0) { System.Threading.Thread.Sleep(startupDelay); } /////////////////////////////////////////////////////////////////////////////// var paramsFilePath = arguments[0]; var param = RegExpProcessingParamsBase.Deserialize <RegExpProcessingParamsBase>(paramsFilePath); _logger = new Logger(param.GetFullPath(param.ProgressFileName), param.GetFullPath(param.LogFileName)); switch (param.Operation) { case ProcessingOperation.RegExp_CalcScores: RegExp_CalcScores(RegExpProcessingParamsBase.Deserialize <RegExpScoreProcessingParams>(paramsFilePath)); break; case ProcessingOperation.RegExp_CalcStatistics: RegExp_CalcStatistics(RegExpProcessingParamsBase.Deserialize <RegExpStatisticsProcessingParams>(paramsFilePath)); break; case ProcessingOperation.RegExp_CalcStatistics_Single: RegExp_CalcStatistics_Single(RegExpProcessingParamsBase.Deserialize <RegExpStatisticsSingleProcessingParams>(paramsFilePath)); break; case ProcessingOperation.ColRegExp_CalcStatistics_Single: ColRegExp_CalcStatistics_Single(RegExpProcessingParamsBase.Deserialize <RegExpStatisticsSingleProcessingParams>(paramsFilePath)); break; case ProcessingOperation.ColRegExp_CalcStatistics: ColRegExp_CalcScores(RegExpProcessingParamsBase.Deserialize <ColRegExpStatisticsProcessingParams>(paramsFilePath)); break; case ProcessingOperation.ColRegExp_Extract: ColRegExp_Extract(RegExpProcessingParamsBase.Deserialize <ColRegExpExtractProcessingParams>(paramsFilePath)); break; default: throw new ArgumentOutOfRangeException(); } /////////////////////////////////////////////////////////////////////////////// return(0); } catch (Exception ex) { try { if (_logger != null) { _logger.HandleException(ex); } } catch { } return(2); } }