Skip to content

Commit

Permalink
Rename outputDirectory to directory in storage engines.
Browse files Browse the repository at this point in the history
  • Loading branch information
datumbox committed Jan 13, 2017
1 parent 9669a68 commit b05fbf9
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 31 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -47,7 +47,8 @@ Version 0.8.0-SNAPSHOT - Build 20170113
- When we close() a Trainer that has not be saved or loaded the knowledgeBase will be deleted to remove any temporary files. - When we close() a Trainer that has not be saved or loaded the knowledgeBase will be deleted to remove any temporary files.
- The models of a specific storageName are added in a directory structure. - The models of a specific storageName are added in a directory structure.
- Created an other level of abstraction for File-based Storage Engines and Configurations. - Created an other level of abstraction for File-based Storage Engines and Configurations.
- Rename Folder to Directory on comments, methods, vars and configuration files. - Rename Folder to Directory on comments, methods, vars and configuration files.
- Rename outputDirectory to directory in storage engines.
- Empty parent directories of the algorithm output are automatically cleaned up. - Empty parent directories of the algorithm output are automatically cleaned up.
- The Dataset can now be saved and loaded. - The Dataset can now be saved and loaded.
- All objects that save, delete and close implement the savable interfrace. - All objects that save, delete and close implement the savable interfrace.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -55,7 +55,7 @@ All the public methods and classes of the Framework are documented with Javadoc
Pre-trained Models Pre-trained Models
------------------ ------------------


Datumbox comes with a large number of pre-trained models which allow you to perform Sentiment Analysis (Document & Twitter), Subjectivity Analysis, Topic Classification, Spam Detection, Adult Content Detection, Language Detection, Commercial Detection, Educational Detection and Gender Detection. To get the binary models check out the [Datumbox Zoo](https://github.com/datumbox/datumbox-framework-zoo). Datumbox comes with a large number of pre-trained models which allow you to perform Sentiment Analysis (Document & Twitter), Subjectivity Analysis, Topic Classification, Spam Detection, Adult Content Detection, Language Detection, Commercial Detection, Educational Detection and Gender Detection. To get the binary models check out the [Datumbox Zoo](https://github.com/datumbox/datumbox-framework-zoo/).


Which methods/algorithms are supported? Which methods/algorithms are supported?
--------------------------------------- ---------------------------------------
Expand All @@ -81,7 +81,7 @@ Useful Links
------------ ------------


- [Code Examples](https://github.com/datumbox/datumbox-framework-examples/) - [Code Examples](https://github.com/datumbox/datumbox-framework-examples/)
- [Datumbox Zoo: Pre-trained models](https://github.com/datumbox/datumbox-framework-zoo) - [Datumbox Zoo: Pre-trained models](https://github.com/datumbox/datumbox-framework-zoo/)
- [Datumbox.com](http://www.datumbox.com/) - [Datumbox.com](http://www.datumbox.com/)
- [Machine Learning Blog](http://blog.datumbox.com/) - [Machine Learning Blog](http://blog.datumbox.com/)


Expand Up @@ -27,9 +27,9 @@
public abstract class AbstractFileStorageConfiguration implements StorageConfiguration { public abstract class AbstractFileStorageConfiguration implements StorageConfiguration {


/** /**
* The output directory of the models. * The directory of the models.
*/ */
protected String outputDirectory = null; protected String directory = null;


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
Expand All @@ -38,21 +38,21 @@ public String getStorageNameSeparator() {
} }


/** /**
* Getter for the output directory where the data files are stored. * Getter for the directory where the data files are stored.
* *
* @return * @return
*/ */
public String getOutputDirectory() { public String getDirectory() {
return outputDirectory; return directory;
} }


/** /**
* Setter for the output directory where the data files are stored. * Setter for the directory where the data files are stored.
* *
* @param outputDirectory * @param directory
*/ */
public void setOutputDirectory(String outputDirectory) { public void setDirectory(String directory) {
this.outputDirectory = outputDirectory; this.directory = directory;
} }


} }
Expand Up @@ -40,19 +40,19 @@ protected AbstractFileStorageEngine(String storageName, SC storageConfiguration)
} }


/** /**
* Returns the location of the output directory from the configuration or the temporary directory if not defined. * Returns the location of the directory from the configuration or the temporary directory if not defined.
* *
* @return * @return
*/ */
protected String getOutputDirectory() { protected String getDirectory() {
//get the default filepath of the permanet storage file //get the default filepath of the permanet storage file
String outputDirectory = storageConfiguration.getOutputDirectory(); String directory = storageConfiguration.getDirectory();


if(outputDirectory == null || outputDirectory.isEmpty()) { if(directory == null || directory.isEmpty()) {
outputDirectory = System.getProperty("java.io.tmpdir"); //write them to the tmp directory directory = System.getProperty("java.io.tmpdir"); //write them to the tmp directory
} }


return outputDirectory; return directory;
} }


/** /**
Expand All @@ -62,7 +62,7 @@ protected String getOutputDirectory() {
* @return * @return
*/ */
protected Path getRootPath(String storageName) { protected Path getRootPath(String storageName) {
return Paths.get(getOutputDirectory() + File.separator + storageName); return Paths.get(getDirectory() + File.separator + storageName);
} }


/** /**
Expand Down Expand Up @@ -113,14 +113,14 @@ protected boolean deleteDirectory(Path path, boolean cleanParent) throws IOExcep
} }


/** /**
* Removes recursively all empty parent directories up to and excluding the output directory. * Removes recursively all empty parent directories up to and excluding the storage directory.
* *
* @param path * @param path
* @throws IOException * @throws IOException
*/ */
private void cleanEmptyParentDirectory(Path path) throws IOException { private void cleanEmptyParentDirectory(Path path) throws IOException {
Path normPath = path.normalize(); Path normPath = path.normalize();
if(normPath.equals(Paths.get(getOutputDirectory()).normalize()) || normPath.equals(Paths.get(System.getProperty("java.io.tmpdir")).normalize())) { //stop if we reach the output or temporary directory if(normPath.equals(Paths.get(getDirectory()).normalize()) || normPath.equals(Paths.get(System.getProperty("java.io.tmpdir")).normalize())) { //stop if we reach the output or temporary directory
return; return;
} }
try { try {
Expand Down
Expand Up @@ -38,7 +38,7 @@ public StorageEngine createStorageEngine(String storageName) {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void load(Properties properties) { public void load(Properties properties) {
outputDirectory = properties.getProperty("inMemoryConfiguration.outputDirectory"); directory = properties.getProperty("inMemoryConfiguration.directory");
} }


} }
Expand Up @@ -14,5 +14,5 @@
# limitations under the License. # limitations under the License.
# #


# The relative or absolute path for the output directory where the models are stored (if not specified the temporary directory is used): # The relative or absolute path for the directory where the models are stored (if not specified the temporary directory is used):
inMemoryConfiguration.outputDirectory= inMemoryConfiguration.directory=
Expand Up @@ -47,7 +47,7 @@ public StorageEngine createStorageEngine(String storageName) {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void load(Properties properties) { public void load(Properties properties) {
outputDirectory = properties.getProperty("mapDBConfiguration.outputDirectory"); directory = properties.getProperty("mapDBConfiguration.directory");
cacheSize = Integer.parseInt(properties.getProperty("mapDBConfiguration.cacheSize")); cacheSize = Integer.parseInt(properties.getProperty("mapDBConfiguration.cacheSize"));
compressed = "true".equalsIgnoreCase(properties.getProperty("mapDBConfiguration.compressed")); compressed = "true".equalsIgnoreCase(properties.getProperty("mapDBConfiguration.compressed"));
hybridized = "true".equalsIgnoreCase(properties.getProperty("mapDBConfiguration.hybridized")); hybridized = "true".equalsIgnoreCase(properties.getProperty("mapDBConfiguration.hybridized"));
Expand Down
Expand Up @@ -14,8 +14,8 @@
# limitations under the License. # limitations under the License.
# #


# The relative or absolute path for the output directory where the models are stored (if not specified the temporary directory is used): # The relative or absolute path for the directory where the models are stored (if not specified the temporary directory is used):
mapDBConfiguration.outputDirectory= mapDBConfiguration.directory=


# The number of records kept in each LRU cache. Setting it to 0 will disable caching (not recommended): # The number of records kept in each LRU cache. Setting it to 0 will disable caching (not recommended):
mapDBConfiguration.cacheSize=10000 mapDBConfiguration.cacheSize=10000
Expand Down
Expand Up @@ -14,5 +14,5 @@
# limitations under the License. # limitations under the License.
# #


# The relative or absolute path for the output directory where the models are stored (if not specified the temporary directory is used): # The relative or absolute path for the directory where the models are stored (if not specified the temporary directory is used):
inMemoryConfiguration.outputDirectory= inMemoryConfiguration.directory=
Expand Up @@ -14,8 +14,8 @@
# limitations under the License. # limitations under the License.
# #


# The relative or absolute path for the output directory where the models are stored (if not specified the temporary directory is used): # The relative or absolute path for the directory where the models are stored (if not specified the temporary directory is used):
mapDBConfiguration.outputDirectory= mapDBConfiguration.directory=


# The number of records kept in each LRU cache. Setting it to 0 will disable caching (not recommended): # The number of records kept in each LRU cache. Setting it to 0 will disable caching (not recommended):
mapDBConfiguration.cacheSize=10000 mapDBConfiguration.cacheSize=10000
Expand Down

0 comments on commit b05fbf9

Please sign in to comment.