bool LA_PhoneticCondictor::Can_Subst( const UCString &lex ) const
{
 if( context.length() > lex.length() )
  return false;

 switch( loc )
 {
  case PREFIX:
   // Начало слова lex должно содержать condictor
   return !memcmp(
                  lex.c_str(),
                  context.c_str(),
                  context.length()*sizeof(*lex.c_str())
                 );

  case AFFIX:
   // Конец слова lex должен содержать condictor
   return !memcmp(
                  lex.c_str()+lex.length()-context.length(),
                  context.c_str(),
                  context.length()*sizeof(*lex.c_str())
                 );

  case UNLOCATED: LEM_STOPIT;
 }

 return false;
}
Exemple #2
0
/****************************************************************************
  Возвращается строка, состоящая из символов строки-аргумента s, начина
  с первого (индекс 0) и длиной nch. Если длина исходной строки недостаточна,
  то результат будет содержать соответственно меньшее количество символов.
*****************************************************************************/
const UCString lem::left( const UCString &s, int NCH )
{
 LEM_CHECKIT_Z(NCH>=0);

 const int l=s.length();

 if( l==NCH )
  {
   return s;
  }
 else if( NCH<=0 )
  {
   return UCString();
  }
 else
  {
   UCString res;
   const int nch = NCH>l ? l : NCH;

   for( int i=0; i<nch; i++ )
    res.set_dir( i, s[i] );

   res.set_dir( nch, '\0' );
   res.calc_hash();
   return res;
  }
}
Exemple #3
0
/****************************************************************
 Если каждому символу слова можно поставить в соответствие
 статью графической грамматики, то слово считаем корректной
 словоформой.
*****************************************************************/
bool LexicalAutomat::IsCorrectWord( const UCString& word ) const
{
 for( UCString::size_type i=0; i<word.length(); i++ )
  if( GG->FindSymbol(word[i]).GetEntry()==UNKNOWN )
   return false;

 return true;
}
Exemple #4
0
// **************************************************************************
// Из строки, начиная с позиции i0, вырезается nch символов и возвращаются
// как строка. Если i0<0, то подразумевается i0=0. Если (i0+nch) больше,
// чем длина строки s, что в результатную строку будет занесено
// соответственно меньше символов.
// **************************************************************************
const UCString lem::mid( const UCString& s, int i0, int nch )
{
 LEM_CHECKIT_Z(nch>=0);

 if( nch<=0 || i0<0 || i0>=s.length() )
  return lem::UCString();

 wchar_t res[ LEM_CSTRING_LEN + 1 ];

 const int I0 = i0<0 ? 0 : i0;

 const int l=s.length();
 if( I0>=l )
  return UCString(res);

 const int NCH = nch>(l-I0) ? l-I0 : nch;

 lem_strncpy( res, s.c_str()+I0, NCH );

 res[NCH]=0;
 return UCString(res);
}
Exemple #5
0
bool SG_Stemmer::Stem( const UCString &org, UCString &stem ) const
{
 if( hStemmer==NULL || org.length()<3 )
  return false;

 stem = org;
 if( sol_Stem( hStemmer, (wchar_t*)stem.c_str() )==0 )
  {
   stem.calc_hash(); 
   return true;
  }

 return false;
}
Exemple #6
0
/*****************************************************************************
  Возвращается строка, состоящая из последних nch символов строки-аргумента s.
  Если длина исходной строки недостаточна, то результат будет содержать
  соответственно меньшее количество символов.
******************************************************************************/
const UCString lem::right( const UCString &s, int NCH )
{
 LEM_CHECKIT_Z(NCH>=0);
 UCString res;

 if( NCH<=0 )
  return res;

 const int l=s.length();
 const int nch = NCH>l ? l : NCH;

 int i0=l-nch;
 for( int i=0; i<nch; i++ )
  res.set_dir( i, s[i+i0] );

 res.set_dir( nch, '\0' );
 res.calc_hash();
 return res;
}