null+****@clear*****
null+****@clear*****
2012年 8月 9日 (木) 14:59:24 JST
SHIMODA Hiroshi 2012-08-09 14:59:24 +0900 (Thu, 09 Aug 2012) New Revision: fca86ffddf37434de47b22420b4041d1fcaa0d22 https://github.com/groonga/gcs/commit/fca86ffddf37434de47b22420b4041d1fcaa0d22 Log: Add gcs-confiugre-text-options Added files: bin/gcs-configure-text-options Modified files: package.json Added: bin/gcs-configure-text-options (+71 -0) 100644 =================================================================== --- /dev/null +++ bin/gcs-configure-text-options 2012-08-09 14:59:24 +0900 (0975ad7) @@ -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); + } +} + + Modified: package.json (+1 -0) =================================================================== --- package.json 2012-08-09 14:59:08 +0900 (32c9b0a) +++ package.json 2012-08-09 14:59:24 +0900 (26f88b2) @@ -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" }, -------------- next part -------------- HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...Download