Ejemplo n.º 1
0
void EditorSession::setUnit(Unit *unit)
{
    if (m_unit == unit) {
        return;
    }
    m_unit = unit;
    // different than above, do not directly enter phrases
    // but first show editing information for units
    setPhrase(nullptr);
    return unitChanged();
}
// initialize this token array with the string, "s" of length, "len".
bool Phrases::set( Words    *words, 
		   Bits     *bits ,
		   bool      useStopWords , 
		   bool      useStems     ,
		   int32_t      titleRecVersion,
		   int32_t      niceness) {
	// reset in case being re-used
	reset();
	// always reset this
	//m_phraseScores = NULL;
	m_phraseSpam   = NULL;
	//m_phraseIds    = NULL;
	// now we never use stop words and we just index two-word phrases
	// so that a search for "get a" in quotes will match a doc that has
	// the phrase "get a clue". it might impact performance, but it should
	// be insignificant... but we need to have this level of precision.
	// ok -- but what about 'kick a ball'. we might not have that phrase
	// in the results for "kick a" AND "a ball"!! so we really need to
	// index "kick a ball" as well as "kick a" and "a ball". i don't think
	// that will cause too much bloat.
	//useStopWords = false;
	// ensure we have words
	if ( ! words ) return true;
	// set the words' scores array, m_wordScores
	//if ( scores ) m_wordScores = scores->m_scores;
	//else          m_wordScores = NULL;
	// . we have one phrase per word
	// . a phrase #n is "empty" if spam[n] == PSKIP
	m_numPhrases = words->getNumWords();

	// replaces scores
	//m_sections    = m_sections;
	//m_sectionPtrs = NULL;
	//if ( m_sections ) m_sectionPtrs = m_sections->m_sectionPtrs;

	// how much mem do we need?
	//int32_t need = (18+1+(3+8*3)) * m_numPhrases;
	int32_t need = m_numPhrases * (8+8+1+1+1);
	//if ( m_wordScores ) need += 4 * m_numPhrases;

	// alloc if we need to
	if ( need > PHRASE_BUF_SIZE ) 
		m_buf = (char *)mmalloc ( need , "Phrases" );
	else
		m_buf = m_localBuf;

	if ( ! m_buf ) 
		return log("query: Phrases::set: %s",mstrerror(g_errno));
	m_bufSize = need;
	// set up arrays
	char *p = m_buf;
	//m_phraseIds      = (int64_t *)p ; p += m_numPhrases * 8;
	// phrase not using stop words
	m_phraseIds2     = (int64_t *)p ; p += m_numPhrases * 8;
	m_phraseIds3     = (int64_t *)p ; p += m_numPhrases * 8;
	//m_phraseIds4     = (int64_t *)p ; p += m_numPhrases * 8;
	//m_phraseIds5     = (int64_t *)p ; p += m_numPhrases * 8;
	//m_stripPhraseIds = (int64_t *)p ; p += m_numPhrases * 8;
	//if ( m_wordScores ) {
	//	m_phraseScores  = (int32_t  *)p ;
	//	p += m_numPhrases * 4;
	//}
	m_phraseSpam    = (unsigned char *)p ; p += m_numPhrases * 1;
	//m_numWordsTotal = (unsigned char *)p ; p += m_numPhrases * 1;
	m_numWordsTotal2= (unsigned char *)p ; p += m_numPhrases * 1;
	m_numWordsTotal3= (unsigned char *)p ; p += m_numPhrases * 1;
	//m_numWordsTotal4= (unsigned char *)p ; p += m_numPhrases * 1;
	//m_numWordsTotal5= (unsigned char *)p ; p += m_numPhrases * 1;

	// sanity
	if ( p != m_buf + need ) { char *xx=NULL;*xx=0; }

	// clear this
	//memset ( m_numWordsTotal , 0 , m_numPhrases );

	memset ( m_numWordsTotal2 , 0 , m_numPhrases );
	memset ( m_numWordsTotal3 , 0 , m_numPhrases );
	//memset ( m_numWordsTotal4 , 0 , m_numPhrases );
	//memset ( m_numWordsTotal5 , 0 , m_numPhrases );
	
	// point to this info while we parse
	m_words        = words;
	m_wptrs        = words->getWords();
	m_wlens        = words->getWordLens();
	m_wids         = words->getWordIds();
	m_bits         = bits;
	m_useStopWords = useStopWords;
	m_useStems     = useStems;
	// we now are dependent on this
	m_titleRecVersion = titleRecVersion;
	// . set the phrases
	// . sets m_phraseIds [i]
	// . sets m_phraseSpam[i] to PSKIP if NO phrase exists
	for ( int32_t i = 0 ; i < words->getNumWords() ; i++ ) {
		if ( ! m_wids[i] ) continue;
		setPhrase ( i , niceness);
	}
	// success
	return true;
}
Ejemplo n.º 3
0
//TODO: This isn't getting a randomWord
Hangman::Hangman(){
    RandomWord randomWord;
    setPhrase(randomWord.getWord());
}
Ejemplo n.º 4
0
PhraseLVI::PhraseLVI( PhraseLV *parent, const Phrase& phrase, int accelKey )
    : QListViewItem( parent ),
      akey( accelKey )
{
    setPhrase( phrase );
}
Ejemplo n.º 5
0
void EditorSession::switchToNextPhrase()
{
    setPhrase(nextPhrase());
}
Ejemplo n.º 6
0
void EditorSession::switchToPreviousPhrase()
{
    setPhrase(previousPhrase());
}