/// <summary> /// Gets the file search operter instance /// </summary> /// <param name="source">The source.</param> /// <returns></returns> public fileTextOperater getOperater(lexiconSourceTypeEnum source) { lexiconSourceFile sourceFile = this.First(x => x.sourceType == source); fileTextOperater output = new fileTextOperater(sourceFile.filepath); return(output); }
/// <summary> /// Prepares resource file for querying and loads the grammar tag converter specification /// </summary> /// <param name="resourceFilePath">The text resource file path</param> /// <param name="grammSpecFilename">The Excel file with the grammar tag converter</param> /// <param name="output">The output.</param> protected void Setup(string resourceFilePath, string grammSpecFilename, ILogBuilder output = null) { if (resourceFilePath.isNullOrEmpty()) { imbACE.Services.terminal.aceTerminalInput.askYesNo("Resource file path is empty (textResourceResolverBase.Setup)!"); throw new ArgumentNullException(nameof(resourceFilePath)); return; } if (grammSpecFilename.isNullOrEmpty()) { imbACE.Services.terminal.aceTerminalInput.askYesNo("Grammar conversion specification file path is empty (textResourceResolverBase.Setup)!"); throw new ArgumentNullException(nameof(grammSpecFilename)); return; } resourceFileOperater = new fileTextOperater(resourceFilePath, true); grammTagConverter = new resourceConverterForGramaticTags(); if (grammSpecFilename.EndsWith(".xlsx")) { if (output != null) { output.log("Grammar conversion specification loading from Excel file"); } grammTagConverter.LoadSpecificationExcelFile(grammSpecFilename, output); } else if (grammSpecFilename.EndsWith(".csv")) { string filebase = Path.GetFileNameWithoutExtension(grammSpecFilename); string filepath = Path.GetDirectoryName(grammSpecFilename); if (output != null) { output.log("Grammar conversion specification loading from CSV files"); } string gramSpecFileFormat = filepath + Path.DirectorySeparatorChar + filebase + "_format.csv"; string gramSpecFileTranslation = filepath + Path.DirectorySeparatorChar + filebase + "_translation.csv"; grammTagConverter.LoadSpecificationCSV(gramSpecFileFormat, gramSpecFileTranslation, output); } else { if (output != null) { output.log("Grammar conversion file format not recognized from the filepath! [" + grammSpecFilename + "]"); } else { throw new ArgumentOutOfRangeException("File format not recognized for " + nameof(textResourceResolverBase) + " Setup call.", nameof(grammSpecFilename)); } } }
//public static translationEnumTable posTypeVsRegex //private Dictionary<string, termExploreModel> _models = new Dictionary<string, termExploreModel>(); ///// <summary> ///// ///// </summary> //protected Dictionary<string, termExploreModel> models //{ // get // { // //if (_models == null)_models = new Dictionary<String, termExploreModel>(); // return _models; // } // set { _models = value; } //} public termExplorer(string projectFolderPath = "") { if (projectFolderPath.isNullOrEmpty()) { failedList = new fileTextOperater(manager.constructor.projectFolderStructure.pathFor("word_check_fails.txt"), true); } else { failedList = new fileTextOperater(projectFolderPath.add("word_check_fails.txt", "\\"), true); } }
/// <summary> /// Prepares the instance to query the dictionary /// </summary> /// <param name="_settings">The settings.</param> /// <param name="_logger">The logger.</param> /// <param name="resourceFolder">The resource folder to search for, if not specified then <see cref="appManager.Application.folder_resources"/> is used.</param> /// <returns>True if ready for use</returns> public Boolean prepare(dictionaryResourceSetup _settings, ILogBuilder _logger = null, folderNode resourceFolder = null) { if (_logger != null) { logger = _logger; } else { logger = new builderForLog(); imbSCI.Core.screenOutputControl.logToConsoleControl.setAsOutput(logger, "Apertium"); } if (resourceFolder == null) { resourceFolder = appManager.Application.folder_resources; } settings = _settings; String filepath = resourceFolder.findFile(settings.fileNameSearchPattern, SearchOption.AllDirectories); if (filepath.isNullOrEmpty()) { logger.log("Dictionary file: [" + settings.fileNameSearchPattern + "] not found"); return(false); } else { try { if (settings.useTextInsteadOfXML) { dictionaryOperator = new fileTextOperater(filepath); } else { dictionaryXml = new XmlDocument(); dictionaryXml.LoadXml(filepath); } logger.log("Dictionary file: [" + filepath + "] found"); isReady = true; } catch (Exception ex) { logger.log("Dictionary [" + filepath + "] load failed: " + ex.Message); isReady = false; } } return(isReady); }
private void connectWithFiles() { #region creating state lists failedTasks = new fileTextOperater(failedTasks_filepath, true); scheduledTasks = new fileTextOperater(scheduledTasks_filepath, true); processedTasks = new List <string>(); taskShadow = new List <string>(); if (!File.Exists(processedTasks_filepath)) { File.WriteAllLines(processedTasks_filepath, new string[] { }); } if (!File.Exists(shadow_filepath)) { File.WriteAllLines(shadow_filepath, new string[] { }); } processedTasks = processedTasks_filepath.openFileToList(true); taskShadow = processedTasks_filepath.openFileToList(true); #endregion }
/// <summary> /// Gets the text file search operater /// </summary> /// <param name="useMemMap">if set to <c>true</c> [use memory map].</param> /// <returns></returns> public fileTextOperater getOperater(bool useMemMap = false) { var op = new fileTextOperater(info.FullName, useMemMap); return(op); }