• R/O
  • SSH
  • HTTPS

hands-free: 提交


Commit MetaInfo

修订版64 (tree)
时间2011-05-21 10:55:09
作者(del#42492)

Log Message

#25205
認識結果でプロパティが取得できない問題を解消した。
問題は、SAPIEngine にて文法設定時にプロパティを設定していないことだった。

更改概述

差异

--- trunk/main/sapi/include/spcf/sapi/utils/Phrase.hpp (revision 63)
+++ trunk/main/sapi/include/spcf/sapi/utils/Phrase.hpp (revision 64)
@@ -8,8 +8,6 @@
88 #ifndef _SPEECH_CONTROLLER_FRAMEWORK_SAPI_PHRASE_HPP_
99 #define _SPEECH_CONTROLLER_FRAMEWORK_SAPI_PHRASE_HPP_
1010
11-#include "spcf/sapi/utils/PhraseProperty.hpp"
12-
1311 #include <atlbase.h>
1412 #include <sphelper.h>
1513
@@ -18,9 +16,16 @@
1816 #include <vector>
1917
2018 #include <boost/noncopyable.hpp>
19+#include <boost/shared_ptr.hpp>
2120
2221 namespace spcf {
2322
23+ class GrammarPhrase;
24+ typedef boost::shared_ptr<GrammarPhrase> GrammarPhrasePtr;
25+
26+ class PhraseProperty;
27+ typedef boost::shared_ptr<PhraseProperty> PhrasePropertyPtr;
28+
2429 class Phrase_i;
2530
2631 /**
@@ -34,14 +39,9 @@
3439 /**
3540 * フレーズを構築します。
3641 */
37- Phrase(const std::string& phrase);
42+ Phrase(const GrammarPhrasePtr& phrase);
3843
3944 /**
40- * フレーズを構築します。
41- */
42- Phrase(const std::string& phrase, const PhraseProperty& property);
43-
44- /**
4545 * フレーズを破棄します。
4646 */
4747 ~Phrase();
@@ -55,7 +55,7 @@
5555 /**
5656 * プロパティを取得します。
5757 */
58- const PhraseProperty& getProperty() const;
58+ const PhrasePropertyPtr& getProperty() const;
5959
6060 public:
6161 /**
--- trunk/main/sapi/include/spcf/sapi/utils/PhraseProperty.hpp (revision 63)
+++ trunk/main/sapi/include/spcf/sapi/utils/PhraseProperty.hpp (revision 64)
@@ -12,6 +12,8 @@
1212
1313 #include <string>
1414
15+#include <boost/noncopyable.hpp>
16+
1517 namespace spcf {
1618
1719 class PhraseProperty_i;
@@ -19,7 +21,7 @@
1921 /**
2022 * プロパティです。
2123 */
22- class PhraseProperty {
24+ class PhraseProperty : public boost::noncopyable {
2325 private:
2426 PhraseProperty_i* impl;
2527
@@ -32,11 +34,6 @@
3234 /**
3335 * プロパティを構築します。
3436 */
35- PhraseProperty(const SPPHRASEPROPERTY* property);
36-
37- /**
38- * プロパティを構築します。
39- */
4037 PhraseProperty(const std::string& name);
4138
4239 /**
--- trunk/main/sapi/src/spcf/sapi/utils/Phrase.cpp (revision 63)
+++ trunk/main/sapi/src/spcf/sapi/utils/Phrase.cpp (revision 64)
@@ -11,10 +11,13 @@
1111
1212 #include "spcf/sapi/utils/Phrase.hpp"
1313
14+#include "spcf/core/GrammarPhrase.hpp"
1415 #include "spcf/sapi/utils/Char2WChar.hpp"
16+#include "spcf/sapi/utils/PhraseProperty.hpp"
1517
1618 #include <cstring>
1719
20+using namespace boost;
1821 using namespace std;
1922
2023 namespace spcf {
@@ -22,24 +25,15 @@
2225 class Phrase_i {
2326 public:
2427 string phrase_;
25- PhraseProperty property_;
28+ PhrasePropertyPtr property_;
2629
2730 public:
28- Phrase_i(const string& phrase) :
29- phrase_(phrase) {
30- }
31-
32- Phrase_i(const string& phrase, const PhraseProperty& property) :
33- phrase_(phrase), property_(property) {
34- }
31+ Phrase_i(const GrammarPhrasePtr& phrase);
3532 };
3633
37- Phrase::Phrase(const string& phrase) : impl(new Phrase_i(phrase)) {
34+ Phrase::Phrase(const GrammarPhrasePtr& phrase) : impl(new Phrase_i(phrase)) {
3835 }
3936
40- Phrase::Phrase(const string& phrase, const PhraseProperty& property) : impl(new Phrase_i(phrase, property)) {
41- }
42-
4337 Phrase::~Phrase() {
4438 delete impl;
4539 }
@@ -48,7 +42,7 @@
4842 return impl->phrase_;
4943 }
5044
51- const PhraseProperty& Phrase::getProperty() const {
45+ const PhrasePropertyPtr& Phrase::getProperty() const {
5246 return impl->property_;
5347 }
5448
@@ -63,18 +57,18 @@
6357 VARIANT valBuffer;
6458 Char2WChar valstrBuffer;
6559 if (impl->property_) {
66- nameBuffer = impl->property_.getName();
60+ nameBuffer = impl->property_->getName();
6761 property.pszName = nameBuffer;
6862
69- if (impl->property_.hasVal()) {
63+ if (impl->property_->hasVal()) {
7064 VariantInit(&valBuffer);
7165 V_VT(&valBuffer) = VT_I4;
72- V_I4(&valBuffer) = impl->property_.getVal();
66+ V_I4(&valBuffer) = impl->property_->getVal();
7367 property.vValue = valBuffer;
7468 }
7569
76- if (impl->property_.hasValStr()) {
77- valstrBuffer = impl->property_.getValStr();
70+ if (impl->property_->hasValStr()) {
71+ valstrBuffer = impl->property_->getValStr();
7872 property.pszValue = valstrBuffer;
7973 }
8074 }
@@ -85,7 +79,7 @@
8579 return result;
8680 }
8781
88- if (impl->property_ && impl->property_.hasVal()) {
82+ if (impl->property_ && impl->property_->hasVal()) {
8983 VariantClear(&valBuffer);
9084 }
9185
@@ -92,4 +86,21 @@
9286 return S_OK;
9387 }
9488
89+
90+
91+ Phrase_i::Phrase_i(const GrammarPhrasePtr& phrase) :
92+ phrase_(phrase->getPhrase()) {
93+ if (phrase->hasProperty()) {
94+ if (phrase->hasPropertyInt() && phrase->hasPropertyString()) {
95+ property_ = PhrasePropertyPtr(new PhraseProperty(phrase->getPhrase(), phrase->getPropertyInt(), phrase->getPropertyString()));
96+ } else if (phrase->hasPropertyInt()) {
97+ property_ = PhrasePropertyPtr(new PhraseProperty(phrase->getPhrase(), phrase->getPropertyInt()));
98+ } else if (phrase->hasPropertyString()) {
99+ property_ = PhrasePropertyPtr(new PhraseProperty(phrase->getPhrase(), phrase->getPropertyString()));
100+ } else {
101+ property_ = PhrasePropertyPtr(new PhraseProperty(phrase->getPhrase()));
102+ }
103+ }
104+ }
105+
95106 } // namespace spcf
--- trunk/main/sapi/src/spcf/sapi/SAPIEngine.cpp (revision 63)
+++ trunk/main/sapi/src/spcf/sapi/SAPIEngine.cpp (revision 64)
@@ -164,7 +164,7 @@
164164 const GrammarTransitionPtr& transition = *i;
165165 impl->insertStateMap(stateMap, topState, transition->getStartState());
166166 impl->insertStateMap(stateMap, topState, transition->getEndState());
167- Phrase(transition->getPhrase()->getPhrase()).addTransition(
167+ Phrase(transition->getPhrase()).addTransition(
168168 impl->grammar_, stateMap.find(transition->getStartState())->second, stateMap.find(transition->getEndState())->second);
169169 }
170170
Show on old repository browser