📄 ghmm_gmltransition.cpp
字号:
/* * * created: 26 Feb 2002 by Wasinee Rungsarityotin * authors: Wasinee Rungsarityotin (rungsari@molgen.mpg.de) * file : $Source: /cvsroot/ghmm/ghmm/ghmm++/GHMM_GMLTransition.cpp,v $ * $Id: GHMM_GMLTransition.cpp,v 1.2 2003/04/24 17:24:00 wasinee Exp $ * revision date : $Date: 2003/04/24 17:24:00 $ _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 <xmlio/XMLIO_Document.h>#include "GHMM_GMLTransition.h"#include "GHMM_Toolkit.h"#include "GHMM_StateT.hh"#ifdef HAVE_NAMESPACESusing namespace std;#endifGHMM_GMLTransition::GHMM_GMLTransition(XMLIO_Attributes &attrs) :GHMM_TransitionT<GHMM_GMLState>(attrs){ reading = GHMM_TRANSITION_READING_NONE; source = attrs["source"]; target = attrs["target"]; attributes = attrs; tag = "edge"; xmlio_indent_type = XMLIO_INDENT_BOTH;}GHMM_GMLTransition::GHMM_GMLTransition(GHMM_GMLState* my_source, GHMM_GMLState* my_target, vector<double> my_prob) : GHMM_TransitionT<GHMM_GMLState>(my_source, my_target){ reading = GHMM_TRANSITION_READING_NONE; source = my_source->index; target = my_target->index; probs = my_prob; attributes["source"] = my_source->id; attributes["target"] = my_target->id; tag = "edge"; xmlio_indent_type = XMLIO_INDENT_BOTH;}const char* GHMM_GMLTransition::toString() const { return "GHMM_GMLTransition";}void GHMM_GMLTransition::XMLIO_getCharacters(const string& characters) { unsigned int pos; switch (reading) { case GHMM_TRANSITION_READING_PROB: for (pos = 0; pos < characters.size(); ++pos) { while (pos < characters.size() && isspace(characters[pos])) ++pos; if (pos < characters.size()) probs.push_back(atof(characters.substr(pos).c_str())); while (pos < characters.size() && !isspace(characters[pos])) ++pos; } break; case GHMM_TRANSITION_READING_NONE: break; }}XMLIO_Element* GHMM_GMLTransition::XMLIO_startTag(const string& tag, XMLIO_Attributes &attrs) { if (tag == "data") { if (attrs["key"] == "prob") { reading = GHMM_TRANSITION_READING_PROB; return this; } } fprintf(stderr,"tag '%s' not recognized in transition element\n",tag.c_str()); exit(1); return NULL;}const int GHMM_GMLTransition::XMLIO_writeContent(XMLIO_Document& writer) { int result = 0; int i; writer.changeIndent(2); result = writer.writeEndl(); result += writer.writef("<data key=\"prob\">"); for(i=0; i < (int)(probs.size())-1; i++) { result += writer.writef(" %.10f,", probs[i]); // A leading space is important } result += writer.writef(" %.10f", probs[i]); // A leading space is important result += writer.writef("</data>\n",prob); return result;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -