Open Chinese Convert  0.4.3
A project for conversion between Traditional and Simplified Chinese
/usr/src/RPM/BUILD/opencc-0.4.3/node/opencc.js
Go to the documentation of this file.
00001 
00029 var path = require('path');
00030 var binding = require('../build/Release/binding');
00031 
00032 var assetsPath = path.resolve(__dirname, '../build/Release');
00033 var getConfigPath = function (config) {
00034   var configPath = config;
00035   if (config[0] !== '/' && config[1] !== ':') {
00036     // Resolve relative path
00037     configPath = path.join(assetsPath, config);
00038   }
00039   return configPath;
00040 };
00041 
00049 var OpenCC = module.exports = function (config) {
00050   if (!config) {
00051     config = 'zhs2zht.ini';
00052   }
00053   config = getConfigPath(config);
00054   this.handler = new binding.Opencc(config);
00055 };
00056 
00057 
00063 OpenCC.CONVERSION_FAST = 0;
00064 
00070 OpenCC.CONVERSION_SEGMENT_ONLY = 1;
00071 
00077 OpenCC.CONVERSION_LIST_CANDIDATES = 2;
00078 
00088 OpenCC.prototype.convert = function (input, callback) {
00089   return this.handler.convert(input.toString(), callback);
00090 };
00091 
00101 OpenCC.prototype.convertSync = function (input) {
00102   return this.handler.convertSync(input.toString());
00103 };
00104 
00113 OpenCC.prototype.setConversionMode = function (conversionMode) {
00114   return this.handler.setConversionMode(conversionMode);
00115 };
 All Data Structures Files Functions Variables Defines