/** Returns default text. */
 virtual QString defaultText() const /* override */
 {
     return m_data.m_fIsUsable ?
            tr("%1, %2: %3, %4", "col.2 text, col.3 name: col.3 text, col.1 name")
              .arg(text(1))
              .arg(parentTree()->headerItem()->text(2)).arg(text(2))
              .arg(parentTree()->headerItem()->text(0)) :
            tr("%1, %2: %3",     "col.2 text, col.3 name: col.3 text")
              .arg(text(1))
              .arg(parentTree()->headerItem()->text(2)).arg(text(2));
 }
Ejemplo n.º 2
0
float
logLikely(FeatureTree* ft)
{
  //cerr << "LL " << *ft << endl;
  int ftc = ft->count;
  assert(ftc > 0);
  FeatureTree* ftp = parentTree(ft);
  assert(ftp);
  int ftpc = ftp->count;
  assert(ftpc > 0);
  FeatMap::iterator fmi = ft->feats.begin();
  float ans = 0;
  /* we compute the sum for each feature f on ft of
     |f|(log(p(f|ft))-log(p(f|ftb)))  = logLcomp(fc, ftc, fpc, ftpc) */
  
  for( ; fmi != ft->feats.end() ; fmi++)
    {
      Feat* f = &((*fmi).second);
      Feat* fp = parentFeat(f);
      assert(fp);
      int fc = f->cnt();
      int fpc = fp->cnt();
      float val = logLcomp(fc, ftc, fpc, ftpc);
      //cerr << "lcomp " << *f << " = " << val << endl;
      ans += val;
    }
  return ans;
}
QModelIndex QITreeViewItem::modelIndex() const
{
    /* Acquire model: */
    const QAbstractItemModel *pModel = parentTree()->model();
    /* Check whether we have proxy model set or source one otherwise: */
    const QSortFilterProxyModel *pProxyModel = qobject_cast<const QSortFilterProxyModel*>(pModel);

    /* Acquire root model-index: */
    const QModelIndex rootIndex = parentTree()->rootIndex();
    /* Acquire source root model-index, which can be the same as root model-index: */
    const QModelIndex sourceRootModelIndex = pProxyModel ? pProxyModel->mapToSource(rootIndex) : rootIndex;

    /* Check whether we have root model-index here: */
    if (   sourceRootModelIndex.internalPointer()
        && sourceRootModelIndex.internalPointer() == this)
        return rootIndex;

    /* Determine our parent model-index: */
    const QModelIndex parentIndex = parentItem() ? parentItem()->modelIndex() : rootIndex;

    /* Determine our position inside parent: */
    int iPositionInParent = -1;
    for (int i = 0; i < pModel->rowCount(parentIndex); ++i)
    {
        /* Acquire child model-index: */
        const QModelIndex childIndex = parentIndex.child(i, 0);
        /* Acquire source child model-index, which can be the same as child model-index: */
        const QModelIndex sourceChildModelIndex = pProxyModel ? pProxyModel->mapToSource(childIndex) : childIndex;

        /* Check whether we have child model-index here: */
        if (   sourceChildModelIndex.internalPointer()
            && sourceChildModelIndex.internalPointer() == this)
        {
            iPositionInParent = i;
            break;
        }
    }
    /* Make sure we found something: */
    if (iPositionInParent == -1)
        return QModelIndex();

    /* Return model-index as child of parent model-index: */
    return parentIndex.child(iPositionInParent, 0);
}
Ejemplo n.º 4
0
void
doRanking()
{
  FeatureTree* root = FeatureTree::roots(whichInt);
  assert(root);
  FeatTreeIter fi(root);
  FeatureTree* f;
  for( ; fi.alive() ; fi.next() )
    {
      f = fi.curr;
      //cerr << "Looking at " << *f << endl;
      /* features at level 1 are automatically used */
      FeatureTree* parFt = parentTree(f);
      assert(parFt);
      assert(parFt->ind != AUXIND);
      if(parFt->ind == ROOTIND) markFeat(f, 1);
      else
	{
	  float ll = logLikely(f);
	  pair<const float, FeatureTree*> ipair(ll, f);
	  if(ll > 0) featRank.insert(ipair);
	}
      /*
	int cnt = f->cnt();
	if(cnt >= 20) markFeat(f, 1);
	else if(!parFt) markFeat(f, 1);
	else
	{
	  float ll = logLikely(f);
	  if(cnt >= 10 && ll > 0.1) markFeat(f,1);
	  else if(cnt >= 5 && ll > 2.0) markFeat(f,1);
	  else if(cnt >= 3 && ll > 8.0) markFeat(f, 1);
	}
	*/

      totStates++;
    }
}
QRect QITreeViewItem::rect() const
{
    /* Redirect call to parent-tree: */
    return parentTree() ? parentTree()->visualRect(modelIndex()) : QRect();
}