Permalink
Browse files

added soundsLike example

  • Loading branch information...
1 parent d33c1e6 commit b36eb9c7f23ff4b18b4c8e1027fe7b42cd748d47 @chrisumbel chrisumbel committed May 28, 2011
Showing with 18 additions and 0 deletions.
  1. +18 −0 examples/phonetics/sounds_like.js
@@ -0,0 +1,18 @@
+var natural = require('natural'),
+ phonetic = natural.Metaphone;
+
+phonetic.attach();
+var wordA = 'phonetics';
+var stdin = process.openStdin();
+stdin.setEncoding('ascii');
+
+process.stdout.write('try to enter a word that sounds like "' + wordA +'": ');
+
+stdin.on('data', function (wordB) {
+ if(wordA.soundsLike(wordB))
+ process.stdout.write('they sound alike!\n');
+ else
+ process.stdout.write('sorry, they don\'t sound alike.\n');
+
+ process.exit();
+ });

0 comments on commit b36eb9c

Please sign in to comment.