public void Close() { m_UNKTokens = null; m_CharProperty = null; m_Dictionaries = null; m_UNKDictionary = null; }
//--------------------------------------------------------------------------- public bool Open(string tDirectory) { Close(); // UNKDictionary Open m_UNKDictionary = new WordDictionary(); if (m_UNKDictionary.Open(Path.Combine(tDirectory, UNK_DIC_FILE).Replace("\\", "/")) == false) { return(false); } //---------------------------------- // SystemDictionary Open m_Dictionaries = new List <WordDictionary>(); WordDictionary tSystemDictionary = new WordDictionary(); if (tSystemDictionary.Open(Path.Combine(tDirectory, SYS_DIC_FILE).Replace("\\", "/")) == false) { return(false); } if (tSystemDictionary.Type != 0) { return(false); } // 文字コード文字列から文字コード識別値を取得する m_CharsetCode = GetCharsetCode(tSystemDictionary.Charset); // 辞書リストに追加する m_Dictionaries.Add(tSystemDictionary); //---------------------------------- // CharProperty Open m_CharProperty = new CharProperty(m_CharsetCode); if (m_CharProperty.Open(tDirectory) == false) { return(false); } //---------------------------------- int tLast = m_Dictionaries.Count - 1; m_LSize = ( uint )m_Dictionaries[tLast].LSize; m_RSize = ( uint )m_Dictionaries[tLast].RSize; //---------------------------------------------------------- // UNKToken Open m_UNKTokens = new List <KeyValuePair <Token, int> >(); for (int i = 0; i < m_CharProperty.Size; ++i) { byte[] tKey = m_CharProperty.GetName(i); DoubleArray.Word n = m_UNKDictionary.ExactMatchSearch(tKey); if (n.value == -1) { Debug.LogWarning("cannot find UNK category: " + tKey); return(false); } Token tToken = m_UNKDictionary.GetToken(n); int tSize = m_UNKDictionary.GetSize(n); m_UNKTokens.Add(new KeyValuePair <Token, int>(tToken, tSize)); } //---------------------------------------------------------- m_Space = m_CharProperty.GetCharInfo(0x20); // ad-hoc m_BOSFeature = StringToBytes(m_CharsetCode, BOS_FEATURE); // m_MaxGroupingSize = DEFAULT_MAX_GROUPING_SIZE ; return(true); }