view widgets/SpeechFileHandler.cpp @ 282:d9319859a4cf tip

(none)
author benoitrigolleau
date Fri, 31 Oct 2008 11:00:24 +0000
parents 96121bc067fb
children
line wrap: on
line source
#include "SpeechFileHandler.h"

SpeechFileHandler::SpeechFileHandler(){
	_tag_vocal_query_result="vocal_query_result";
	_tag_word="word";
	_tag_confidence = "confidence";
	_result = "";
}
SpeechFileHandler::~SpeechFileHandler(){

}
bool SpeechFileHandler::fatalError (const QXmlParseException & exception){
	return false;
}

bool SpeechFileHandler::characters ( const QString &str){
	return true;
}

bool SpeechFileHandler::endDocument (){
	return true;
}

bool SpeechFileHandler::endElement (const QString &namespaceURI, const QString &localName, const QString &qName ){
	_currentTag = "";
	if(localName==_tag_vocal_query_result){
		_resultAux+="<br>";
		if(!_resultAux.contains("0.0")){
			_result += _resultAux;
		}
		_resultAux = "";

	}
	return true;
}

bool SpeechFileHandler::startDocument (){
	return true;
}

bool SpeechFileHandler::startElement (const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &attribs ){
	_currentTag = localName;
	if(localName == _tag_vocal_query_result){
		for(int i = 0 ; i < attribs.length() ; i++){
			QString aux = attribs.localName(i);
			if(aux==_tag_word){
				_resultAux+="<b>";
				_resultAux+=attribs.value(i);
				_resultAux+="</b>";
			}else if(aux == _tag_confidence ){
				_resultAux+="   ";
				_resultAux+=attribs.value(i);
			}
		}
	}
	return true;
}
	
QString SpeechFileHandler::getResult(){
	return _result;
}