LexicalReorderingState* HierarchicalReorderingForwardState::Expand(const TranslationOption& topt, Scores& scores) const {
  const LexicalReorderingConfiguration::ModelType modelType = m_configuration.GetModelType();
  const WordsRange currWordsRange = topt.GetSourceWordsRange();
  // keep track of the current coverage ourselves so we don't need the hypothesis
  WordsBitmap coverage = m_coverage;
  coverage.SetValue(currWordsRange.GetStartPos(), currWordsRange.GetEndPos(), true);
  
  ReorderingType reoType;
  
  if (m_first) {
      ClearScores(scores);
  } else {
    if (modelType == LexicalReorderingConfiguration::MSD) {
      reoType = GetOrientationTypeMSD(currWordsRange, coverage);
    } else if (modelType == LexicalReorderingConfiguration::MSLR) {
      reoType = GetOrientationTypeMSLR(currWordsRange, coverage);
    } else if (modelType == LexicalReorderingConfiguration::Monotonic) {
      reoType = GetOrientationTypeMonotonic(currWordsRange, coverage);
    } else {
      reoType = GetOrientationTypeLeftRight(currWordsRange, coverage);
    }
  
    CopyScores(scores, topt, reoType);
  }
  
  return new HierarchicalReorderingForwardState(this, topt);
}
LexicalReorderingState* PhraseBasedReorderingState::Expand(const TranslationOption& topt, Scores& scores) const
{
  ReorderingType reoType;
  const WordsRange currWordsRange = topt.GetSourceWordsRange();
  const LexicalReorderingConfiguration::ModelType modelType = m_configuration.GetModelType();

  if (m_direction == LexicalReorderingConfiguration::Forward && m_first) {
    ClearScores(scores);
  } else {
    if (!m_first || m_useFirstBackwardScore) {
      if (modelType == LexicalReorderingConfiguration::MSD) {
        reoType = GetOrientationTypeMSD(currWordsRange);
      } else if (modelType == LexicalReorderingConfiguration::MSLR) {
        reoType = GetOrientationTypeMSLR(currWordsRange);
      } else if (modelType == LexicalReorderingConfiguration::Monotonic) {
        reoType = GetOrientationTypeMonotonic(currWordsRange);
      } else {
        reoType = GetOrientationTypeLeftRight(currWordsRange);
      }
      CopyScores(scores, topt, reoType);
    }
  }

  return new PhraseBasedReorderingState(this, topt);
}
Esempio n. 3
0
void MSTree::ClearScores(MSTreeNode* rt, double* VP) // initialize the score
{
	if (rt==NULL) return;
    for (int i=0; i<NP; i++)
    {
	    //cout << "i=" << i <<" Tmark=" << rt->Tmark << " VP[Tmark]=" << VP[i]  << "..." << endl;
        if (i == rt->Tmark)
        {
            rt->Initialize(0.0, VP[i]);
            rt->Tvector = VP[i];
            //cout << "Tmark=" << *(rt->Tmark) << " VP[Tmark]=" << VP[i]  << "..." << endl;
        }
    }       // initialize the var = sigma*bl
	ClearScores(rt->LeftChild, VP);
	ClearScores(rt->RightChild, VP);
}
Esempio n. 4
0
void MSTree::ClearAllScores(double* VP, char* NumParam)
{
	NP = atof(NumParam);
    //cout << NP << "..." << endl;
    ClearScores(root, VP);
	tScore = 0.0;
}
Esempio n. 5
0
 virtual void PXCAPI OnAlert(const PXCSpeechRecognition::AlertData *data) {
     if(data->label == PXCSpeechRecognition::AlertType::ALERT_SPEECH_UNRECOGNIZABLE)
     {
         ClearScores(m_hWnd);
     }
     PrintStatus(m_hWnd,AlertToString(data->label));
 }
Esempio n. 6
0
    virtual void PXCAPI OnRecognition(const PXCSpeechRecognition::RecognitionData *data) {
        if (data->scores[0].label<0) {
            PrintConsole(m_hWnd,(pxcCHAR*)data->scores[0].sentence);
            if (data->scores[0].tags[0])
                PrintConsole(m_hWnd,(pxcCHAR*)data->scores[0].tags);
        } else {
            ClearScores(m_hWnd);
            for (int i=0; i<sizeof(data->scores)/sizeof(data->scores[0]); i++) {
                if (data->scores[i].label < 0 || data->scores[i].confidence == 0) continue;
                SetScore(m_hWnd,data->scores[i].label,data->scores[i].confidence);
            }

            // Dispatch differnt work here
            switch (data->scores[0].label) {
            case 0:
                PrintStatus(m_hWnd, (pxcCHAR*)L"Reading text for you, my pleasure.");
                break;
            case 1:
                PrintStatus(m_hWnd, (pxcCHAR*)L"Yes master, Avery and Lasse are smiling.");
                break;
            case 2:
                PrintStatus(m_hWnd, (pxcCHAR*)L"Today is sunday.");
                break;
            default:
                break;
            }

            if (data->scores[0].tags[0])
                PrintStatus(m_hWnd,(pxcCHAR*)data->scores[0].tags);
        }
    }