Navigation Menu

Skip to content

Commit

Permalink
Add gcs-confiugre-text-options
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 9, 2012
1 parent b8c83a3 commit fca86ff
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
71 changes: 71 additions & 0 deletions bin/gcs-configure-text-options
@@ -0,0 +1,71 @@
#!/usr/bin/env node

var CLI = require(__dirname + '/../lib/command-line').CommandLineInterface;
var commandLine = new CLI();
var fs = require('fs');

commandLine
.option('--name <field name>',
'The name of the field you are configuring or deleting. Required.',
String)
.option('-stems <path to stems file>',
'The path for a stemming dictionary file. The stemming ' +
'dictionary file should contain one comma-separated ' +
'term, stem pair per line. For example:\n' +
' mice, mouse\n' +
' people, person\n' +
' running, run',
String)
.option('--stopwords <path to stopwords file>',
'The path for a stopwords dictionary file. The stopwords ' +
'dictionary file should contain one stopword per line. ' +
'For example:\n' +
' the\n' +
' or\n' +
' and',
String)
.option('-synonyms <path to synonyms file>',
'The path for a synonyms dictionary file. Each line in the '+
'file should specify term forrowed by a comma-separated ' +
'list of its synonyms. For example:\n' +
' cat, feline, kitten\n' +
' dog, canine, puppy\n' +
' hourse, equite, ',
String)
.option('-psm, --print-stems',
'List the domain's stems.')
.option('-psw, --print-stopwords',
'List the domain's stopwords.')
.option('-psn, --print-synonyms',
'List the domain's synonyms.')
.parse();

commandLine.assertHaveDomainName();
commandLine.assertDomainExists();

if (commandLine.options.printStems) {
} else if (commandLine.options.printStopwords) {
} else if (commandLine.options.printSynonyms) {
var synonyms = commandLine.database.getSynonymsSync();
Object.keys(synonyms).forEach(function(term) {
console.log([term].concat(synonyms[term]).join(','));
});
} else {
if (commandLine.options.stems) {
}
if (commandLine.options.stopwords) {
}
if (commandLine.options.synonyms) {
var synonymsFile = CLI.resolve(commandLine.options.synonyms);
var synonymsCSV = fs.readFileSync(synonymsFile, 'UTF-8');
var synonyms = {};
synonymsCSV.split('\n').forEach(function(synonym) {
var terms = synonym.split(',');
var key = terms.shift();
synonyms[key] = terms;
});
commandLine.database.updateSynonymsSync(synonyms);
}
}


1 change: 1 addition & 0 deletions package.json
Expand Up @@ -37,6 +37,7 @@
"gcs-delete-domain": "./bin/gcs-delete-domain",
"gcs-describe-domain": "./bin/gcs-describe-domain",
"gcs-configure-fields": "./bin/gcs-configure-fields",
"gcs-configure-text-options": "./bin/gcs-configure-text-options",
"gcs-index-documents": "./bin/gcs-index-documents",
"gcs-import-examples": "./bin/gcs-import-examples"
},
Expand Down

0 comments on commit fca86ff

Please sign in to comment.