kuromoji
Version:
JavaScript implementation of Japanese morphological analyzer
59 lines (49 loc) • 2.14 kB
JavaScript
/*
* Copyright 2014 Takuya Asano
* Copyright 2010-2014 Atilika Inc. and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
;
var TokenInfoDictionary = require("./TokenInfoDictionary");
var CharacterDefinition = require("./CharacterDefinition");
var ByteBuffer = require("../util/ByteBuffer");
/**
* UnknownDictionary
* @constructor
*/
function UnknownDictionary() {
this.dictionary = new ByteBuffer(10 * 1024 * 1024);
this.target_map = {}; // class_id (of CharacterClass) -> token_info_id (of unknown class)
this.pos_buffer = new ByteBuffer(10 * 1024 * 1024);
this.character_definition = null;
}
// Inherit from TokenInfoDictionary as a super class
UnknownDictionary.prototype = Object.create(TokenInfoDictionary.prototype);
UnknownDictionary.prototype.characterDefinition = function (character_definition) {
this.character_definition = character_definition;
return this;
};
UnknownDictionary.prototype.lookup = function (ch) {
return this.character_definition.lookup(ch);
};
UnknownDictionary.prototype.lookupCompatibleCategory = function (ch) {
return this.character_definition.lookupCompatibleCategory(ch);
};
UnknownDictionary.prototype.loadUnknownDictionaries = function (unk_buffer, unk_pos_buffer, unk_map_buffer, cat_map_buffer, compat_cat_map_buffer, invoke_def_buffer) {
this.loadDictionary(unk_buffer);
this.loadPosVector(unk_pos_buffer);
this.loadTargetMap(unk_map_buffer);
this.character_definition = CharacterDefinition.load(cat_map_buffer, compat_cat_map_buffer, invoke_def_buffer);
};
module.exports = UnknownDictionary;