예제 #1
0
 /*
  *      public static void removeWBL(Text text, int length, Letter[] checkLetters) {
  *          LinkedList<Sentens> sentenses = new LinkedList<Sentens>(text.Sentenses);
  *          for (LinkedListNode<Sentens> sentens=sentenses.First;sentens.Next!=null;sentens=sentens.Next ) {
  *              LinkedList<Word> words = new LinkedList<Word>(sentens.Words);
  *              LinkedList<PunctuationSymbol> punctSymbols = new LinkedList<Word>(sentens.PunctuationSymbols);
  *
  *              LinkedListNode<PunctuationSymbol> punctSymbol =punctSymbols.First;
  *              LinkedListNode<Word> word =words.First;
  *              for(;word.Next!=null;word=word.Next){
  *                  IEnumerator ieS=word.Value.Symbols.GetEnumerator();
  *                  ieS.MoveNext();
  *                  bool isSameLetter=false;
  *                  for(int i=0;i<checkLetters.Length;i++){
  *                      if(checkLetters[i].Value==((Symbol)ieS.Current).Value){
  *                          isCorrectLetter=true;
  *                          break;
  *                      }
  *                  }
  *                  if(word.Value.Symbols.Count==length && isCorrectLetter){
  *                      sentens.Remove(word);
  *
  *                  }
  *              }
  *
  *          }
  *          text.Sentenses=new List<Sentens>(sentenses);
  *
  *      }
  *      public stataic LinkedList<T> addFromListToLinked<T> (List<T> list){
  *          return null;
  *      }
  *      public stataic List<T> addFromListToLinked<T>(LinkedList<T> linked){
  *          return null;
  *      }
  *
  */
 public static Sentens[] getSortedBySentensLength(Text txt)
 {
     Sentens[] sen = txt.Sentenses.ToArray();
     for (int i = 0; i < sen.Length; i++)
     {
         for (int j = i; j < sen.Length; j++)
         {
             if (sen[i].Words.Count > sen[j].Words.Count)
             {
                 Sentens buf = sen[i];
                 sen[i] = sen[j];
                 sen[j] = buf;
             }
         }
     }
     return(sen);
 }
예제 #2
0
        public static Sentens replaceWordInSentens(Sentens sentens, int wordLength, string substring)
        {
            int        wordCounter    = -1;
            List <int> wordCountArray = new List <int>();

            foreach (Word word in sentens.Words)
            {
                wordCounter++;
                if (word.Symbols.Count == wordLength)
                {
                    wordCountArray.Add(wordCounter);
                }
            }
            foreach (int i in wordCountArray)
            {
                sentens.Words.RemoveAt(i);
                sentens.Words.Insert(i, new Word(substring));
            }
            return(new Sentens(sentens.Value));
        }