Esempio n. 1
0
 private void ProcessAuthorsArray(string[] authors)
 {
     foreach (string authorStr in authors)
     {
         if (!string.IsNullOrEmpty(authorStr))
         {
             string normalizedAuthor = authorStr.Replace(",", " ").Trim();
             normalizedAuthor = TextNormalization.NormalizeAuthor(normalizedAuthor);
             if ((TextNormalization.RusCoeff(normalizedAuthor) <= 1 && TextNormalization.RusCoeff(normalizedAuthor) >= 0.6))
             {
                 if (!DatabaseContainsAuthor(normalizedAuthor.ToLowerInvariant()))
                 {
                     AddAuthorToDatabase(normalizedAuthor);
                 }
                 else
                 {
                     Author author = context.Authors.FirstOrDefault(x => x.Name == normalizedAuthor);
                     if (author != null)
                     {
                         Guid authorId = author.AuthorId;
                         if (this.authors == null)
                         {
                             this.authors = new List <Author>();
                         }
                         this.authors.Add(author);
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
0
 private static string ProcessAuthorName(string authorName)
 {
     return(TextNormalization.NormalizeAuthor(authorName));
 }