⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ghmm_gmlclass.cpp

📁 一个通用的隐性马尔可夫C代码库 开发环境:C语言 简要说明:这是一个通用的隐性马尔可夫C代码库
💻 CPP
字号:
/* * * created: 26 Feb 2002 by Wasinee Rungsarityotin * authors: Wasinee Rungsarityotin (rungsari@molgen.mpg.de) * file   : $Source: /cvsroot/ghmm/ghmm/ghmm++/GHMM_GMLClass.cpp,v $ * $Id: GHMM_GMLClass.cpp,v 1.1 2003/04/24 17:23:57 wasinee Exp $ * revision date   : $Date: 2003/04/24 17:23:57 $  _Copyright (C) 1998-2001, ZAIK/ZPR, Universit鋞 zu K鰈n  _  _This program is free software; you can redistribute it and/or modify  _it under the terms of the GNU General Public License as published by  _the Free Software Foundation; either version 2 of the License, or  _(at your option) any later version.  _  _This program is distributed in the hope that it will be useful,  _but WITHOUT ANY WARRANTY; without even the implied warranty of  _MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  _GNU General Public License for more details.  _  _You should have received a copy of the GNU General Public License  _along with this program; if not, write to the Free Software  _Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  _  */#include <iostream>#include <xmlio/XMLIO_Document.h>#include "ghmm++/GHMM_GMLClass.h"#ifdef HAVE_NAMESPACESusing namespace std;#endifGHMM_GMLClass::GHMM_GMLClass() {  alphabet_type     = GHMM_SINGLE_CHAR_ALPHABET;  xmlio_indent_type = XMLIO_INDENT_BOTH;  tag               = "hmm:class";  reading = READ_NONE;  attributes["hmm:type"] = "discrete";   attributes["hmm:low"]  = "0";  attributes["hmm:high"]  = "0";}GHMM_GMLClass::GHMM_GMLClass(GHMM_Alphabet *alp) {  char tmp[10];  alphabet_type     = GHMM_SINGLE_CHAR_ALPHABET;  xmlio_indent_type = XMLIO_INDENT_BOTH;  tag               = "hmm:class";  reading           = READ_NONE;  attributes["hmm:type"] = "discrete";   attributes["hmm:low"]  = "0";  sprintf(tmp, "%2d", alp->size()-1);   attributes["hmm:high"]  = tmp;  for (int i = 0; i < alp->size(); ++i) {      addSymbol(alp->getSymbol(i));  }}GHMM_GMLClass::~GHMM_GMLClass() {}XMLIO_Element* GHMM_GMLClass::XMLIO_startTag(const string& tag, XMLIO_Attributes &attrs) {  reading = READ_NONE;  if (tag == "map")     {      return this;    }  else    if (tag == "symbol") // HACK!! We should look at the text node , not attribute      { 	reading = READ_SINGLE_CHAR;	return this;      }    return NULL;}void GHMM_GMLClass::XMLIO_endTag(const string& tag) {  reading = READ_NONE;}void GHMM_GMLClass::XMLIO_getCharacters(const string& characters) {  switch (reading) {  case READ_SINGLE_CHAR:    cout << "Alphabet seen: " << characters.c_str() << endl;    addSymbol(characters);    char tmp[3];    sprintf(tmp, "%d", size()-1);    attributes["hmm:high"]  = tmp;    break;  case READ_NONE:    break;  }}const int GHMM_GMLClass::XMLIO_writeContent(XMLIO_Document& writer) {  int total_bytes = 0;  int result;  unsigned int i;  result = writer.writeEndl();  if (result < 0)    return result;  total_bytes += result;  writer.changeIndent(2);  result = writer.writef("%s<map>\n",writer.indent);  total_bytes += result;  for (i = 0; i < symbols.size(); ++i) {    result = writer.writef("%s<symbol code=\"%2d\">%s</symbol>\n",			   writer.indent, i, symbols[i].c_str());    if (result < 0)      return result;    total_bytes += result;  }  result = writer.writef("%s</map>\n",writer.indent);  total_bytes += result;  return total_bytes;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -