-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathviterbi.cpp
61 lines (51 loc) · 2.23 KB
/
viterbi.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//-------------------------------------------------------------------------------------
// Copyright 2014 Michael Peeri
//
// This file is part of hmmdsl.
// hmmdsl 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 3 of the License, or
// (at your option) any later version.
//
// hmmdsl 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 hmmdsl. If not, see <http://www.gnu.org/licenses/>.
//-------------------------------------------------------------------------------------
#include "viterbi.hpp"
#include <boost/format.hpp>
namespace v2
{
const char* AlignmentLineFormat = "%1%%|13t|%2%%|18t|%3% %4%";
std::ostream& operator<< (std::ostream& stream, const v2::decoding_t& decoding)
{
using boost::format;
using boost::str;
#ifdef EXCESSIVE_DEBUG_PRINTING
stream<< "decoding_t:";
#endif
if( decoding._uninitialized )
{
stream<< "decoding_t: (Null)"<< std::endl;
return stream;
}
const size_t totalLength = decoding._s1.length();
const size_t width = 50;
for( size_t pos = 0; pos <totalLength; pos += width )
{
const size_t segmentLength = (pos + width <= totalLength) ? (width) : (totalLength-pos);
stream<< "\n";
//stream<< decoding._id1.substr(0, 8)<< " "<< pos+1<< " "<< decoding._s1.substr(pos, segmentLength)<< " "<< pos+segmentLength<< std::endl;
stream<< str( boost::format(AlignmentLineFormat) % decoding._id1.substr(0,12) % (pos+1) % decoding._s1.substr(pos,segmentLength) % (pos+segmentLength) );
stream<< std::endl;
//stream<< decoding._id2.substr(0, 8)<< " "<< pos+1<< " "<< decoding._s2.substr(pos, segmentLength)<< " "<< pos+segmentLength<< std::endl;
stream<< str( boost::format(AlignmentLineFormat) % decoding._id2.substr(0,12) % (pos+1) % decoding._s2.substr(pos,segmentLength) % (pos+segmentLength) );
stream<< std::endl;
}
stream<< std::flush;
return stream;
}
} // namespace v2