Ejemplo n.º 1
0
 void FrenchStemmer::deleteButSuffixFromElseReplace(const String& source, Collection<String> search, const String& prefix, bool without, const String& from, const String& replace)
 {
     if (!source.empty())
     {
         for (int32_t i = 0; i < search.size(); ++i)
         {
             if (boost::ends_with(source, prefix + search[i]))
             {
                 stringBuffer.resize(stringBuffer.length() - (prefix.length() + search[i].length()));
                 modified = true;
                 setStrings();
                 break;
             }
             else if (!from.empty() && boost::ends_with(from, prefix + search[i]))
             {
                 stringBuffer.resize(stringBuffer.length() - (prefix.length() + search[i].length()));
                 stringBuffer += replace;
                 modified = true;
                 setStrings();
                 break;
             }
             else if (without && boost::ends_with(source, search[i]))
             {
                 stringBuffer.resize(stringBuffer.length() - search[i].length());
                 modified = true;
                 setStrings();
                 break;
             }
         }
     }
 }
Ejemplo n.º 2
0
 bool JID::setServer( const std::string& serv )
 {
   m_serverRaw = serv;
   m_valid = prep::nameprep( m_serverRaw, m_server );
   setStrings();
   return m_valid;
 }
Ejemplo n.º 3
0
  bool JID::setJID( const std::string& jid )
  {
    if ( jid.empty() )
    {
      m_bare = m_full = m_server = m_username = m_serverRaw = m_resource = EmptyString;
      m_valid = false;
      return false;
    }

    const std::string::size_type at = jid.find( '@' );
    const std::string::size_type slash = jid.find( '/', at == std::string::npos ? 0 : at );

    if( at != std::string::npos && !( m_valid = prep::nodeprep( jid.substr( 0, at ), m_username ) ) )
      return false;

    m_serverRaw = jid.substr( at == std::string::npos ? 0 : at + 1, slash - at - 1 );
    if( !( m_valid = prep::nameprep( m_serverRaw, m_server ) ) )
      return false;

    if( slash != std::string::npos
         && !( m_valid = prep::resourceprep( jid.substr( slash + 1 ), m_resource ) ) )
      return false;

    setStrings();

    return m_valid;
  }
Ejemplo n.º 4
0
 bool FrenchStemmer::deleteFromIfTestVowelBeforeIn(const String& source, Collection<String> search, bool vowel, const String& from)
 {
     bool found = false;
     if (!source.empty() && !from.empty())
     {
         for (int32_t i = 0; i < search.size(); ++i)
         {
             if (boost::ends_with(source, search[i]))
             {
                 if ((search[i].length() + 1) <= from.length())
                 {
                     bool test = isVowel(stringBuffer[stringBuffer.length() - (search[i].length() + 1)]);
                     if (test == vowel)
                     {
                         stringBuffer.resize(stringBuffer.length() - search[i].length());
                         modified = true;
                         found = true;
                         setStrings();
                         break;
                     }
                 }
             }
         }
     }
     return found;
 }
Ejemplo n.º 5
0
 void FrenchStemmer::step3()
 {
     if (!stringBuffer.empty())
     {
         wchar_t ch = stringBuffer[stringBuffer.length() - 1];
         if (ch == L'Y')
         {
             stringBuffer[stringBuffer.length() - 1] = L'i';
             setStrings();
         }
         else if (ch == L'\x00e7')
         {
             stringBuffer[stringBuffer.length() - 1] = L'c';
             setStrings();
         }
     }
 }
Ejemplo n.º 6
0
void FretDiagram::init(StringData* stringData, Chord* chord)
      {
      if (!stringData)
            setStrings(6);
      else
            setStrings(stringData->strings());
      if (stringData) {
            for (int string = 0; string < _strings; ++string)
                  _marker[string] = 'X';
            foreach(const Note* note, chord->notes()) {
                  int string;
                  int fret;
                  if (stringData->convertPitch(note->pitch(), chord->staff(), chord->segment()->tick(), &string, &fret))
                        setDot(string, fret);
                  }
            _maxFrets = stringData->frets();
            }
      else
Ejemplo n.º 7
0
void FretDiagram::init(Tablature* tab, Chord* chord)
      {
      if (tab == 0)
            setStrings(6);
      else
            setStrings(tab->strings());
      if (tab) {
            for (int string = 0; string < _strings; ++string)
                  _marker[string] = 'X';
            foreach(const Note* note, chord->notes()) {
                  int string;
                  int fret;
                  if (tab->convertPitch(note->ppitch(), &string, &fret))
                        setDot(string, fret);
                  }
            _maxFrets = tab->frets();
            }
      else
Ejemplo n.º 8
0
 void FrenchStemmer::step5()
 {
     if (!R0.empty())
     {
         if (boost::ends_with(R0, L"enn") || boost::ends_with(R0, L"onn") || 
             boost::ends_with(R0, L"ett") || boost::ends_with(R0, L"ell") || boost::ends_with(R0, L"eill"))
         {
             stringBuffer.resize(stringBuffer.length() - 1);
             setStrings();
         }
     }
 }
Ejemplo n.º 9
0
void addShader(glslang::TProgram& program, std::string& hlslText, EShLanguage stage, std::string entryPointName)
{
    auto shader = new glslang::TShader(stage);

    const char * text = hlslText.c_str();
    shader->setStrings(&text, 1);
    shader->setEntryPoint(entryPointName.c_str());

    program.addShader(shader);

    if (!shader->parse(&DefaultResources, defaultVersion, false, messagesType))
    {
        throw std::exception(shader->getInfoLog());
    }
}
Ejemplo n.º 10
0
 void FrenchStemmer::deleteFrom(const String& source, Collection<String> suffix)
 {
     if (!source.empty())
     {
         for (int32_t i = 0; i < suffix.size(); ++i)
         {
             if (boost::ends_with(source, suffix[i]))
             {
                 stringBuffer.resize(stringBuffer.length() - suffix[i].length());
                 modified = true;
                 setStrings();
                 break;
             }
         }
     }
 }
Ejemplo n.º 11
0
 bool FrenchStemmer::replaceFrom(const String& source, Collection<String> search, const String& replace)
 {
     bool found = false;
     if (!source.empty())
     {
         for (int32_t i = 0; i < search.size(); ++i)
         {
             if (boost::ends_with(source, search[i]))
             {
                 stringBuffer.resize(stringBuffer.length() - search[i].length());
                 stringBuffer += replace;
                 modified = true;
                 found = true;
                 setStrings();
                 break;
             }
         }
     }
     return found;
 }
Ejemplo n.º 12
0
 bool FrenchStemmer::deleteFromIfPrecededIn(const String& source, Collection<String> search, const String& from, const String& prefix)
 {
     bool found = false;
     if (!source.empty())
     {
         for (int32_t i = 0; i < search.size(); ++i)
         {
             if (boost::ends_with(source, search[i]))
             {
                 if (!from.empty() && boost::ends_with(from, prefix + search[i]))
                 {
                     stringBuffer.resize(stringBuffer.length() - search[i].length());
                     found = true;
                     setStrings();
                     break;
                 }
             }
         }
     }
     return found;
 }
Ejemplo n.º 13
0
    String FrenchStemmer::stem(const String& term)
    {
        if (!isStemmable(term))
            return term;
        
        // Use lowercase for medium stemming.
        stringBuffer = StringUtils::toLower(term);

        // reset the booleans
        modified = false;
        suite = false;

        treatVowels(stringBuffer);

        setStrings();

        step1();

        if (!modified || suite)
        {
            if (!RV.empty())
            {
                suite = step2a();
                if (!suite)
                    step2b();
            }
        }

        if (modified || suite)
            step3();
        else
            step4();

        step5();

        step6();

        return stringBuffer;
    }
Ejemplo n.º 14
0
    void FrenchStemmer::step4()
    {
        if (stringBuffer.length() > 1)
        {
            wchar_t ch = stringBuffer[stringBuffer.length() - 1];
            if (ch == L's')
            {
                wchar_t b = stringBuffer[stringBuffer.length() - 2];
                if (b != L'a' && b != L'i' && b != L'o' && b != L'u' && b != L'\x00e8' && b != L's')
                {
                    stringBuffer.resize(stringBuffer.length() - 1);
                    setStrings();
                }
            }
        }
        if (!deleteFromIfPrecededIn(R2, newCollection<String>(L"ion"), RV, L"s"))
            deleteFromIfPrecededIn(R2, newCollection<String>(L"ion"), RV, L"t");

        replaceFrom(RV, newCollection<String>(L"I\x00e8re", L"i\x00e8re", L"Ier", L"ier"), L"i");
        deleteFrom(RV, newCollection<String>(L"e"));
        deleteFromIfPrecededIn(RV, newCollection<String>(L"\x00eb"), R0, L"gu");
    }
Ejemplo n.º 15
0
 bool JID::setUsername( const std::string& uname )
 {
   m_valid = prep::nodeprep( uname, m_username );
   setStrings();
   return m_valid;
 }