Ejemplo 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);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 private static string ProcessAuthorName(string authorName)
 {
     return(TextNormalization.NormalizeAuthor(authorName));
 }