/// <summary> /// Extracts words from the folder path and file name /// </summary> /// <param name="ParentFolderPath">Folder path beneath which all files are included for word extraction</param> /// <param name="AppContext">Application context.</param> static void ExtractWords(string ParentFolderPath, ApplicationContext AppContext) { AppContext.TruncateDocumentWords(); List <DocumentFileInfo> dfs = AppContext.DocumentFiles .Where(x => x.FilePath.StartsWith(ParentFolderPath)) .Select(x => new DocumentFileInfo { FilePath = x.FilePath, DocumentHash = x.DocumentHash }) .ToList <DocumentFileInfo>(); DocumentCollector dc = new DocumentCollector(AppContext); int WordFileCounter = 0; foreach (DocumentFileInfo df in dfs) { dc.ProcessWords(df.FilePath, df.DocumentHash); WordFileCounter += 1; if (WordFileCounter % 100 == 0) { AppContext.SaveChanges(); } // Console.WriteLine("Words extracted for \"{0}\".", df.FilePath); } // final database save AppContext.SaveChanges(); Console.WriteLine("Document word extraction completed."); }
/// <summary> /// Collects and stores information about documents under the root folder paths. /// </summary> /// <param name="RootFolderPaths">String array of folder paths.</param> /// <param name="AppContext">Application context.</param> static void Collect(string[] RootFolderPaths, ApplicationContext AppContext) { DocumentCollector dc = new DocumentCollector(AppContext); foreach (string path in RootFolderPaths) { bool IgnoreDeleteCheck = false; dc.CollectDocuments(path, true, IgnoreDeleteCheck); Console.WriteLine("Completed collection for \"{0}\".", path); } Console.WriteLine("Document collection completed."); }
public DocumentCollector AddAggregateFunction(AggregateFunctionType type, IEvaluable field) { if (_aggregations == null) { _aggregations = new List <DocumentCollector>(); } IAggregation function; switch (type) { case AggregateFunctionType.AVG: function = new AVG(); break; case AggregateFunctionType.COUNT: function = new COUNT(); break; case AggregateFunctionType.MAX: function = new MAX(); break; case AggregateFunctionType.MIN: function = new MIN(); break; case AggregateFunctionType.SUM: function = new SUM(); break; //case AggregateFunctionType.FIRST: // function = new FIRST(field); // break; //case AggregateFunctionType.LAST: // function = new LAST(field); // break; default: throw new QuerySystemException(ErrorCodes.Query.AGGREGATION_INVALID_FUNCTION); } var aggregator = new DocumentCollector(function, field); _aggregations.Add(aggregator); return(aggregator); }