Files, directories and input/output tools

Main tools at imbSCI.Core.files namespace:

  • Meta-Directory tree-node structure: folderNode (API Documentation)
  • Data structure that serializes in multiple files and directory tree: fileDataStructure (API Documentation)
  • Interface for searching & quering large textual files: fileTextOperater and fileTextOperaterMulti (API Documentation)
  • Object serialization to and from XLM and JSON, in single method call (API Documentation)

folderNode

As most of imbSCI libraries, this wrapper around DirectoryInfo and System.IO namespace is designed to support reporting, automatic directory_readme generation and provide never-exception approach to directory creation, file path validation … etc. The class is implicitly convertible to and from DirectoryInfo.

How to construct the instance:

// This will create a folder node pointing to the directory of .exe file
folderNode folder = new folderNode();

// Here we create subdirectory NLP
var nlpFolder = folder.Add("NLP", "Natural Language Processing", "Folder with results of imbNLP.PartOfSpeech library tests");

// Now, to create subdirectory of the NLP folder, we can do it like this:
var waFolder = folder.Add("NLP\\WordAnalysis", "Word analysis", "Folder with results of word analysis tests");

// or, like this:
var waFolder = nlpFolder.Add("WordAnalysis", "Word analysis", "Folder with results of word analysis tests");


Or you can just convert it from DirectoryInfo instance:

var directoryInfo = new DirectoryInfo("some path bla bla");
folderNode folder = directoryInfo;

 

Now, typical use:

To get path for a file, existing file will be overwritten (if exist), directory tree will be automatically created (if missing) and specified file description will show up in directory readme file

String pcPath = classReportFolder.pathFor("pipeline_signatures.txt", imbSCI.Data.enums.getWritableFileMode.overwrite, "Content pipeline result signatures for all categories");

The enumeration getWritableFileMode , provides some useful out-of-box functionalities, when it comes to auto-renaming, overwriting, backing up & etc:

newOrExisting

  • It will create new file if no existing detected, or get existing

existing

  • It will not create new file if no existing detected

overwrite

  • It will delete any existing file and provide newly created

autoRenameThis

  • It will automatically modify path with _Counter suffix so the new file has unique filename, with preservation of the specified file extension

autoRenameExistingOnOtherDate

  • The automatically renames the existing file if it was created on another date

autoRenameExistingToOld  or autoRenameExistingToBack will simply add one of the suffixes.

 

Read me files are generated for complete descendant graph (or optionally depth limited) with generateReadmeFiles method:

folder.generateReadmeFiles(appManager.AppInfo);

Example of directory readme file:

### Directory information

#### Experiment WoffCoffXdiv_IDFFalse_psFalse_k10_LPF6_DFC0.0_rnd_off

 > \exp_WoffCoffXdiv_IDFFalse_psFalse_k10_LPF6_DFC0.0_rnd_off

 > Directory with all information on the experiment [WoffCoffXdiv_IDFFalse_psFalse_k10_LPF6_DFC0.0_rnd_off]

 ------------------------------------------------------------------------------------

### Files in this directory:

01 : [ModelMetrics.xml                                  ] The FVE with highest S1 score, for this experiment

02 : [ReportSummary.txt                                 ] Short summary on the results of the experiment

03 : [ReportSummary.xml                                 ] XML Serialized ReportSummary object - for automatic multi-experiment results processing

04 : [TopPerformers.xml                                 ] XML Serialized object - with best performing FVE models - for later results post-reporting

05 : [directory_readme.txt                              ] Description of directory content (this file)

06 : [dt_topperformers.xlsx                             ] Excel spreadsheet report on [Topperformers] data table

07 : [experimentSetup.xml                               ] Serialized configuration [Experiment Setup] object

08 : [lexicResourceSignature.txt                        ] Signature of the lexic resource

09 : [log.txt                                           ] Complete log output of this experiment session

10 : [note.txt                                          ] Notes on experiment setup and execution log

 ------------------------------------------------------------------------------------

### Subdirectories of: G:\imbWBI_Release\reports\exp_WoffCoffXdiv_IDFFalse_psFalse_k10_LPF6_DFC0.0_rnd_off

 -- > Error logs                                             : \errors                                                                                             

 -- | Directory with error reports produced if an exception occours. Normally, if everything was ok this folder should have only two files inside: directory_readme.txt and empty: note.txt).

 -- > cSSRM_rnd_off_E2                                       : \cSSRM_rnd_off_E2                                                                                   

 -- | cSSRM_rnd_off_E2 10-fold validation

 --  -- > cSSRM_rnd_off_E2000                                : \cSSRM_rnd_off_E2\cSSRM_rnd_off_E2000                                                               

 --  -- | Operational files and reports for k-fold [cSSRM_rnd_off_E2000]

 --  --  -- > Cases                                          : \cSSRM_rnd_off_E2\cSSRM_rnd_off_E2000\cases                                                         

 --  --  -- | Repository with knowledge on cases

 --  -- > cSSRM_rnd_off_E2001                                : \cSSRM_rnd_off_E2\cSSRM_rnd_off_E2001                                                               

 --  -- | Operational files and reports for k-fold [cSSRM_rnd_off_E2001]

 --  --  -- > Cases                                          : \cSSRM_rnd_off_E2\cSSRM_rnd_off_E2001\cases                                                         

 --  --  -- | Repository with knowledge on cases


.....
....

------------------------------------------------------------------------------------

**Author**: _Goran Grubić_

**E-mail**: _hardy@veles.rs_

**Web**: _http://blog.veles.rs_

**Copyright**: _Copyright (c) 2017-2018_

**License**: _GNU General Public Licence v3.0_

**Software**: _imbWBI Console tool_

**Organization**: _imbVeles_

**Comment**: _Console tool for command line and ACE script execution of imbWBI experiments and analitics tasks_

------------------------------------------------------------------------------------

File generated: Friday, February 16, 2018 8:52:18 AM

Some other interesting methods:

  • ScanReadMe – learns description, files description and other meta information from readme txt file
  • Add – creates sub directory, and specifies its caption and description
  • FindUniqueDirectoryName – easy creation of new, uniquely named sub-directory

From folderNode instance, single extension method call is required to generate DirectedGraph (DGML) or other graph structure, that describes content of the folder.

Example of generated DGML, rendered with VisualStudio


 

Spread the love