[Groonga-commit] groonga/gcs [master] Strip extra white spaces

Back to archive index

null+****@clear***** null+****@clear*****
2012年 8月 9日 (木) 15:38:58 JST


SHIMODA Hiroshi	2012-08-09 15:38:58 +0900 (Thu, 09 Aug 2012)

  New Revision: 60aa027cbd637d0442d6449d993a1ee7402f4be4
  https://github.com/groonga/gcs/commit/60aa027cbd637d0442d6449d993a1ee7402f4be4

  Log:
    Strip extra white spaces

  Modified files:
    bin/gcs-configure-text-options

  Modified: bin/gcs-configure-text-options (+7 -2)
===================================================================
--- bin/gcs-configure-text-options    2012-08-09 15:36:51 +0900 (893644c)
+++ bin/gcs-configure-text-options    2012-08-09 15:38:58 +0900 (86ca9ff)
@@ -43,6 +43,10 @@ commandLine
 commandLine.assertHaveDomainName();
 commandLine.assertDomainExists();
 
+function strip(string) {
+  return string.replace(/^\s+|\s+$/g, '');
+}
+
 if (commandLine.options.printStems) {
 } else if (commandLine.options.printStopwords) {
 } else if (commandLine.options.printSynonyms) {
@@ -60,11 +64,12 @@ if (commandLine.options.printStems) {
     var synonymsCSV = fs.readFileSync(synonymsFile, 'UTF-8');
     var synonyms = {};
     synonymsCSV.split('\n').forEach(function(synonym) {
+      synonym = strip(synonym);
       if (!synonym) return;
       var terms = synonym.split(',');
-      var key = terms.shift();
+      var key = strip(terms.shift());
       var previousTerms = synonyms[key] || [];
-      synonyms[key] = previousTerms.concat(terms);
+      synonyms[key] = previousTerms.concat(terms.map(strip));
     });
     commandLine.domain.updateSynonymsSync(synonyms);
     console.log('%s synonyms are loaded.', Object.keys(synonyms).length);
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



Groonga-commit メーリングリストの案内
Back to archive index