Ejemplo n.º 1
0
bool SemanticCorpusReader::AddWord(const Document_Sentence_Word& word,
                                   int sentence, const IntIntMap& vocab,
                                   const set<int>& pos,
                                   const IntIntMap& synsets, BaseDoc* doc) {
  // If this corpus has pos information *and* we filter on pos
  // *and* this pos isn't there, then skip this word
  if (word.has_pos() && pos.size() > 0 && pos.find(word.pos()) == pos.end())
    return false;

  int token = word.token();
  int normalized_synset = -1;
  if (word.has_synset()) {
    int synset = word.synset();
    assert(synsets.find(synset) != synsets.end());
    normalized_synset = synsets.find(synset)->second;
  }
  if (use_lemma_ && word.has_lemma()) token = word.lemma();
  if (vocab.find(token) == vocab.end()) return false;
  int normalized_token = vocab.find(token)->second;

  static_cast<SemMlSeqDoc*>(doc)->
    AddWord(sentence, normalized_token, normalized_synset);
  static_cast<SemMlSeqDoc*>(doc)->Addtfidf(sentence, word.tfidf());
  return true;
}
Ejemplo n.º 2
0
TransferFunctionAlphaWidget::AlphaPoint TransferFunctionAlphaWidget::selectPoint(QPoint pos)
{
	std::map<int, QRect>::iterator it = mPointRects.begin();
	for(;it != mPointRects.end(); ++it)
	{
		if (it->second.contains(pos))
		{
			AlphaPoint retval;
			retval.position = it->first;
			IntIntMap opactiyMap = mImageTF->getOpacityMap();
			if (opactiyMap.find(retval.position) != opactiyMap.end())
				retval.value = opactiyMap.find(retval.position)->second;
			return retval;
		}
	}

	return AlphaPoint();
}
Ejemplo n.º 3
0
bool CorpusReader::AddWord(const Document_Sentence_Word& word,
                           int sentence, const IntIntMap& vocab,
                           const set<int>& pos, const IntIntMap& synsets,
                           BaseDoc* doc) {
  // If this corpus has pos information *and* we filter on pos
  // *and* this pos isn't there, then skip this word
  if (word.has_pos() && pos.size() > 0 && pos.find(word.pos()) == pos.end())
    return false;

  int token = word.token();
  if (use_lemma_ && word.has_lemma()) token = word.lemma();
  if (use_bigram_) {
    if (word.bigram() == -1) return false;
    else
      token = word.bigram();
  }
  if (vocab.find(token) == vocab.end()) return false;
  int normalized_token = vocab.find(token)->second;

  doc->AddWord(sentence, normalized_token);
  doc->Addtfidf(sentence, word.tfidf());
  return true;
}
Ejemplo n.º 4
0
std::pair<int,int> TransferFunctionAlphaWidget::findAllowedMoveRangeAroundAlphaPoint(int selectedPointIntensity)
{
	// constrain new point intensity between the two neigbours
	IntIntMap opacityMap = mImageTF->getOpacityMap();
	IntIntMap::iterator pointIterator = opacityMap.find(selectedPointIntensity);

	std::pair<int,int> range(mImage->getMin(), mImage->getMax());
	if (pointIterator!=opacityMap.begin())
	{
		IntIntMap::iterator prevPointIterator = pointIterator;
		--prevPointIterator;
		range.first = std::max(range.first, prevPointIterator->first + 1);
	}

	IntIntMap::iterator nextPointIterator = pointIterator;
	++nextPointIterator;
	if (nextPointIterator!=opacityMap.end())
	{
		range.second = std::min(range.second, nextPointIterator->first - 1);
	}

	return range;
}