예제 #1
0
void HwcmScorer::setReferenceFiles(const vector<string>& referenceFiles)
{
  // For each line in the reference file, create a tree object
  if (referenceFiles.size() != 1) {
    throw runtime_error("HWCM only supports a single reference");
  }
  m_ref_trees.clear();
  m_ref_hwc.clear();
  ifstream in((referenceFiles[0] + ".trees").c_str());
  if (!in) {
    throw runtime_error("Unable to open " + referenceFiles[0] + ".trees");
  }
  string line;
  while (getline(in,line)) {
    line = this->preprocessSentence(line);
    TreePointer tree (boost::make_shared<InternalTree>(line));
    m_ref_trees.push_back(tree);
    vector<map<string, int> > hwc (kHwcmOrder);
    vector<string> history(kHwcmOrder);
    extractHeadWordChain(tree, history, hwc);
    m_ref_hwc.push_back(hwc);
    vector<int> totals(kHwcmOrder);
    for (size_t i = 0; i < kHwcmOrder; i++) {
      for (map<string, int>::const_iterator it = m_ref_hwc.back()[i].begin(); it != m_ref_hwc.back()[i].end(); it++) {
        totals[i] += it->second;
      }
    }
    m_ref_lengths.push_back(totals);
  }
  TRACE_ERR(endl);

}
예제 #2
0
void MainWindow::editHWConnection()
{
    DCAutomaton *automaton = m_automatonWidget->currentAutomaton();

    if(automaton) {
        HWConnections hwc(m_hw, automaton);
        hwc.exec();
    }
}