From 83d670c92322f76322955496820adaf95a0835f5 Mon Sep 17 00:00:00 2001 From: groverlynn Date: Sun, 16 Jul 2023 11:35:22 +0200 Subject: [PATCH] configure node --- data/CMakeLists.txt | 24 +++++----- node/configs.gypi | 18 +++++++- node/dicts.gypi | 107 ++++++++++++++++++++++++++++++++------------ node/test.js | 15 ++++++- 4 files changed, 121 insertions(+), 43 deletions(-) diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 473d1aa85..3d0e93ca4 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -212,36 +212,36 @@ foreach(DICT ${DICTS}) endforeach(DICT) set(CONFIG_FILES - config/hk2s.json - config/hk2t.json - config/jp2t.json - config/s2hk.json - config/s2t.json - config/s2tw.json - config/t2hk.json - config/t2jp.json - config/t2s.json - config/t2tw.json - config/tw2s.json - config/tw2t.json config/hk2cnp.json config/hk2myp.json + config/hk2s.json config/hk2sgp.json + config/hk2t.json + config/jp2t.json config/s2cnp.json + config/s2hk.json config/s2hkp.json config/s2mop.json config/s2myp.json config/s2sgp.json + config/s2t.json + config/s2tw.json config/s2twp.json config/t2cnp.json + config/t2hk.json config/t2hkp.json + config/t2jp.json config/t2mop.json config/t2myp.json + config/t2s.json config/t2sgp.json + config/t2tw.json config/t2twp.json config/tw2cnp.json config/tw2myp.json + config/tw2s.json config/tw2sgp.json + config/tw2t.json ) install( diff --git a/node/configs.gypi b/node/configs.gypi index 796107621..2507d4a2b 100644 --- a/node/configs.gypi +++ b/node/configs.gypi @@ -5,19 +5,35 @@ "copies": [{ "destination": "<(PRODUCT_DIR)", "files": [ + "../data/config/hk2cnp.json", + "../data/config/hk2myp.json", "../data/config/hk2s.json", + "../data/config/hk2sgp.json", "../data/config/hk2t.json", "../data/config/jp2t.json", + "../data/config/s2cnp.json", "../data/config/s2hk.json", + "../data/config/s2hkp.json", + "../data/config/s2mop.json", + "../data/config/s2myp.json", + "../data/config/s2sgp.json", "../data/config/s2t.json", "../data/config/s2tw.json", "../data/config/s2twp.json", + "../data/config/t2cnp.json", "../data/config/t2hk.json", + "../data/config/t2hkp.json", "../data/config/t2jp.json", + "../data/config/t2mop.json", + "../data/config/t2myp.json", "../data/config/t2s.json", + "../data/config/t2sgp.json", "../data/config/t2tw.json", + "../data/config/t2twp.json", + "../data/config/tw2cnp.json", + "../data/config/tw2myp.json", "../data/config/tw2s.json", - "../data/config/tw2sp.json", + "../data/config/tw2sgp.json", "../data/config/tw2t.json", ] }] diff --git a/node/dicts.gypi b/node/dicts.gypi index 99faed868..e8e4337e9 100644 --- a/node/dicts.gypi +++ b/node/dicts.gypi @@ -42,73 +42,122 @@ "outputs": ["<(output_prefix)TSPhrases.ocd2"], "action": ["node", "<(cmd)", "<(input)", "<@(_outputs)"] }, { - "action_name": "TWVariants", + "action_name": "CNVocabulary.txt", + "inputs": ["<(cmd)"], + "outputs": ["<(output_prefix)CNVocabulary.txt"], + "action": ["python", "<(dict_merge)", "<(input_prefix)CNVocabToponym.txt", "<(input_prefix)CNVocabSciTech.txt", "<(input_prefix)CNVocabOthers.txt", "<@(_outputs)"] + }, { + "action_name": "CNVocabulary", "variables": { - "input": "<(input_prefix)TWVariants.txt", + "input": "<(output_prefix)CNVocabulary.txt", }, "inputs": ["<(input)"], - "outputs": ["<(output_prefix)TWVariants.ocd2"], + "outputs": ["<(output_prefix)CNVocabulary.ocd2"], "action": ["node", "<(cmd)", "<(input)", "<@(_outputs)"] }, { - "action_name": "TWVariantsRevPhrases", + "action_name": "HKVocabulary.txt", + "inputs": ["<(cmd)"], + "outputs": ["<(output_prefix)HKVocabulary.txt"], + "action": ["python", "<(dict_merge)", "<(input_prefix)HKVocabToponym.txt", "<(input_prefix)HKVocabSciTech.txt", "<(input_prefix)HKVocabOthers.txt", "<@(_outputs)"] + }, { + "action_name": "HKVocabulary", "variables": { - "input": "<(input_prefix)TWVariantsRevPhrases.txt", + "input": "<(output_prefix)HKVocabulary.txt", }, "inputs": ["<(input)"], - "outputs": ["<(output_prefix)TWVariantsRevPhrases.ocd2"], + "outputs": ["<(output_prefix)HKVocabulary.ocd2"], "action": ["node", "<(cmd)", "<(input)", "<@(_outputs)"] }, { - "action_name": "JPVariants", + "action_name": "MOVocabulary.txt", + "inputs": ["<(cmd)"], + "outputs": ["<(output_prefix)MOVocabulary.txt"], + "action": ["python", "<(dict_merge)", "<(input_prefix)MOVocabToponym.txt", "<(input_prefix)MOVocabSciTech.txt", "<(input_prefix)MOVocabOthers.txt", "<@(_outputs)"] + }, { + "action_name": "MOVocabulary", "variables": { - "input": "<(input_prefix)JPVariants.txt", + "input": "<(output_prefix)MOVocabulary.txt", }, "inputs": ["<(input)"], - "outputs": ["<(output_prefix)JPVariants.ocd2"], + "outputs": ["<(output_prefix)MOVocabulary.ocd2"], "action": ["node", "<(cmd)", "<(input)", "<@(_outputs)"] }, { - "action_name": "TWPhrases.txt", + "action_name": "MYVocabulary.txt", "inputs": ["<(cmd)"], - "outputs": ["<(output_prefix)TWPhrases.txt"], - "action": ["python", "<(dict_merge)", "<(input_prefix)TWPhrasesIT.txt", "<(input_prefix)TWPhrasesName.txt", "<(input_prefix)TWPhrasesOther.txt", "<@(_outputs)"] + "outputs": ["<(output_prefix)MYVocabulary.txt"], + "action": ["python", "<(dict_merge)", "<(input_prefix)MYVocabToponym.txt", "<(input_prefix)MYVocabSciTech.txt", "<(input_prefix)MYVocabOthers.txt", "<@(_outputs)"] }, { - "action_name": "TWVariantsRev.txt", + "action_name": "MYVocabulary", "variables": { - "input": "<(input_prefix)TWVariants.txt", + "input": "<(output_prefix)MYVocabulary.txt", }, "inputs": ["<(input)"], - "outputs": ["<(output_prefix)TWVariantsRev.txt"], - "action": ["python", "<(dict_reverse)", "<(input)", "<@(_outputs)"] + "outputs": ["<(output_prefix)MYVocabulary.ocd2"], + "action": ["node", "<(cmd)", "<(input)", "<@(_outputs)"] + }, { + "action_name": "SGVocabulary.txt", + "inputs": ["<(cmd)"], + "outputs": ["<(output_prefix)SGVocabulary.txt"], + "action": ["python", "<(dict_merge)", "<(input_prefix)SGVocabToponym.txt", "<(input_prefix)SGVocabSciTech.txt", "<(input_prefix)SGVocabOthers.txt", "<@(_outputs)"] }, { - "action_name": "TWPhrasesRev.txt", + "action_name": "SGVocabulary", "variables": { - "input": "<(output_prefix)TWPhrases.txt", + "input": "<(output_prefix)SGVocabulary.txt", }, "inputs": ["<(input)"], - "outputs": ["<(output_prefix)TWPhrasesRev.txt"], - "action": ["python", "<(dict_reverse)", "<(input)", "<@(_outputs)"] + "outputs": ["<(output_prefix)SGVocabulary.ocd2"], + "action": ["node", "<(cmd)", "<(input)", "<@(_outputs)"] + }, { + "action_name": "TWVocabulary.txt", + "inputs": ["<(cmd)"], + "outputs": ["<(output_prefix)TWVocabulary.txt"], + "action": ["python", "<(dict_merge)", "<(input_prefix)TWVocabToponym.txt", "<(input_prefix)TWVocabSciTech.txt", "<(input_prefix)TWVocabOthers.txt", "<@(_outputs)"] }, { - "action_name": "TWPhrases", + "action_name": "TWVocabulary", "variables": { - "input": "<(output_prefix)TWPhrases.txt", + "input": "<(output_prefix)TWVocabulary.txt", }, "inputs": ["<(input)"], - "outputs": ["<(output_prefix)TWPhrases.ocd2"], + "outputs": ["<(output_prefix)TWVocabulary.ocd2"], "action": ["node", "<(cmd)", "<(input)", "<@(_outputs)"] }, { - "action_name": "TWVariantsRev", + "action_name": "TWVariants", "variables": { - "input": "<(output_prefix)TWVariantsRev.txt", + "input": "<(input_prefix)TWVariants.txt", }, "inputs": ["<(input)"], - "outputs": ["<(output_prefix)TWVariantsRev.ocd2"], + "outputs": ["<(output_prefix)TWVariants.ocd2"], "action": ["node", "<(cmd)", "<(input)", "<@(_outputs)"] }, { - "action_name": "TWPhrasesRev", + "action_name": "TWVariantsRevPhrases", "variables": { - "input": "<(output_prefix)TWPhrasesRev.txt", + "input": "<(input_prefix)TWVariantsRevPhrases.txt", }, "inputs": ["<(input)"], - "outputs": ["<(output_prefix)TWPhrasesRev.ocd2"], + "outputs": ["<(output_prefix)TWVariantsRevPhrases.ocd2"], + "action": ["node", "<(cmd)", "<(input)", "<@(_outputs)"] + }, { + "action_name": "JPVariants", + "variables": { + "input": "<(input_prefix)JPVariants.txt", + }, + "inputs": ["<(input)"], + "outputs": ["<(output_prefix)JPVariants.ocd2"], + "action": ["node", "<(cmd)", "<(input)", "<@(_outputs)"] + }, { + "action_name": "TWVariantsRev.txt", + "variables": { + "input": "<(input_prefix)TWVariants.txt", + }, + "inputs": ["<(input)"], + "outputs": ["<(output_prefix)TWVariantsRev.txt"], + "action": ["python", "<(dict_reverse)", "<(input)", "<@(_outputs)"] + }, { + "action_name": "TWVariantsRev", + "variables": { + "input": "<(output_prefix)TWVariantsRev.txt", + }, + "inputs": ["<(input)"], + "outputs": ["<(output_prefix)TWVariantsRev.ocd2"], "action": ["node", "<(cmd)", "<(input)", "<@(_outputs)"] }, { "action_name": "HKVariants", diff --git a/node/test.js b/node/test.js index 70d644412..be7256476 100644 --- a/node/test.js +++ b/node/test.js @@ -5,18 +5,31 @@ const util = require('util'); const OpenCC = require('./opencc'); const configs = [ + 'hk2myp', 'hk2s', + 'hk2sgp', 'hk2t', 'jp2t', + 's2cnp', 's2hk', + 's2hkp', + 's2mop', + 's2myp', + 's2sgp', 's2t', 's2tw', 's2twp', 't2hk', + 't2hkp', 't2jp', + 't2mop', + 't2myp', 't2s', + 't2sgp', + 'tw2cnp', + 'tw2myp', 'tw2s', - 'tw2sp', + 'tw2sgp', 'tw2t', ];