예제 #1
0
 public RemoveFileWord(RemoveFileWord other)
 {
     this.SeparatorBefore = other.SeparatorBefore;
     this.SeparatorAfter = other.SeparatorAfter;
     this.Word = other.Word;
     this.Type = other.Type;
     this.RemoveFollowingEndWord = other.RemoveFollowingEndWord;
     this.RemoveEverythingAfter = other.RemoveEverythingAfter;
 }
예제 #2
0
 public RemoveFileWord(RemoveFileWord other)
 {
     this.SeparatorBefore        = other.SeparatorBefore;
     this.SeparatorAfter         = other.SeparatorAfter;
     this.Word                   = other.Word;
     this.Type                   = other.Type;
     this.RemoveFollowingEndWord = other.RemoveFollowingEndWord;
     this.RemoveEverythingAfter  = other.RemoveEverythingAfter;
 }
예제 #3
0
        /// <summary>
        /// Removes word from string with extra options.
        /// </summary>
        /// <param name="disableRemAfter">Disable removing of words that follow defined words to remove</param>
        /// <param name="input">Input string to remove words from</param>
        /// <param name="removeFileWords">List of removed words from string to add to when removing more</param>
        /// <param name="remWord">Word to be removed</param>
        /// <param name="removed">Whether word was found and removed from input</param>
        /// <returns>string with word removed</returns>
        private static string RemoveWord(bool disableRemAfter, string input, Dictionary <FileWordType, List <string> > removeFileWords, RemoveFileWord remWord, out bool removed)
        {
            RemoveFileWord remWordClone = new RemoveFileWord(remWord);

            // Disable remove after if needed
            if (disableRemAfter)
            {
                remWordClone.RemoveEverythingAfter  = false;
                remWordClone.RemoveFollowingEndWord = false;
            }

            // Perform word remove
            removed = remWordClone.RemoveWord(ref input, removeFileWords);

            // Return results with removed word
            return(input);
        }
예제 #4
0
        /// <summary>
        /// Simplifies a file name string for easier matching against database results.
        /// </summary>
        /// <param name="fileName">File name to simplify</param>
        /// <param name="removeYear">Whether to remove year or not</param>
        /// <returns>The simplified file name string</returns>
        public static string BasicSimplify(string fileName, bool removeYear)
        {
            // All lowercase
            string simplifiedName = fileName.ToLower();

            // Remove unneeded characters: ',!,?,(,),:
            simplifiedName = Regex.Replace(simplifiedName, @"[']+", "");
            simplifiedName = Regex.Replace(simplifiedName, @"[!\?\u0028\u0029\:\]\[]+", " ");

            // Replace seperators with spaces
            simplifiedName = Regex.Replace(simplifiedName, @"\W+|_", " ");

            if (removeYear)
            {
                RemoveFileWord remYear = new RemoveFileWord(Separator.Nonnumeric, Separator.Nonnumeric, @"(?:19|20)\d{2}", FileWordType.Year, false, false);
                remYear.RemoveWord(ref simplifiedName, new Dictionary <FileWordType, List <string> >());
            }

            return(simplifiedName);
        }
예제 #5
0
        /// <summary>
        /// Removes word from string with extra options.
        /// </summary>
        /// <param name="disableRemAfter">Disable removing of words that follow defined words to remove</param>
        /// <param name="input">Input string to remove words from</param>
        /// <param name="removeFileWords">List of removed words from string to add to when removing more</param>
        /// <param name="remWord">Word to be removed</param>
        /// <returns>string with word removed</returns>
        private static string RemoveWord(bool disableRemAfter, string input, Dictionary <FileWordType, List <string> > removeFileWords, RemoveFileWord remWord)
        {
            bool dummy;

            return(RemoveWord(disableRemAfter, input, removeFileWords, remWord, out dummy));
        }
예제 #6
0
        /// <summary>
        /// Removes word from string with extra options.
        /// </summary>
        /// <param name="disableRemAfter">Disable removing of words that follow defined words to remove</param>
        /// <param name="input">Input string to remove words from</param>
        /// <param name="removeFileWords">List of removed words from string to add to when removing more</param>
        /// <param name="remWord">Word to be removed</param>
        /// <param name="removed">Whether word was found and removed from input</param>
        /// <returns>string with word removed</returns>
        private static string RemoveWord(bool disableRemAfter, string input, Dictionary<FileWordType, List<string>> removeFileWords, RemoveFileWord remWord, out bool removed)
        {
            RemoveFileWord remWordClone = new RemoveFileWord(remWord);

            // Disable remove after if needed
            if (disableRemAfter)
            {
                remWordClone.RemoveEverythingAfter = false;
                remWordClone.RemoveFollowingEndWord = false;
            }

            // Perform word remove
            removed = remWordClone.RemoveWord(ref input, removeFileWords);

            // Return results with removed word
            return input;
        }
예제 #7
0
 /// <summary>
 /// Removes word from string with extra options.
 /// </summary>
 /// <param name="disableRemAfter">Disable removing of words that follow defined words to remove</param>
 /// <param name="input">Input string to remove words from</param>
 /// <param name="removeFileWords">List of removed words from string to add to when removing more</param>
 /// <param name="remWord">Word to be removed</param>
 /// <returns>string with word removed</returns>
 private static string RemoveWord(bool disableRemAfter, string input, Dictionary<FileWordType, List<string>> removeFileWords, RemoveFileWord remWord)
 {
     bool dummy;
     return RemoveWord(disableRemAfter, input, removeFileWords, remWord, out dummy);
 }
예제 #8
0
        /// <summary>
        /// Simplifies a file name string for easier matching against database results.
        /// </summary>
        /// <param name="fileName">File name to simplify</param>
        /// <param name="removeYear">Whether to remove year or not</param>
        /// <returns>The simplified file name string</returns>
        public static string BasicSimplify(string fileName, bool removeYear)
        {
            // All lowercase
            string simplifiedName = fileName.ToLower();

            // Remove unneeded characters: ',!,?,(,),:
            simplifiedName = Regex.Replace(simplifiedName, @"[']+", "");
            simplifiedName = Regex.Replace(simplifiedName, @"[!\?\u0028\u0029\:\]\[]+", " ");

            // Replace seperators with spaces
            simplifiedName = Regex.Replace(simplifiedName, @"\W+|_", " ");

            if (removeYear)
            {
                RemoveFileWord remYear = new RemoveFileWord(Separator.Nonnumeric, Separator.Nonnumeric, @"(?:19|20)\d{2}", FileWordType.Year, false, false);
                remYear.RemoveWord(ref simplifiedName, new Dictionary<FileWordType, List<string>>());
            }

            return simplifiedName;
        }