Estimated time is coded up.
This commit is contained in:
parent
ab6669703d
commit
64ee5ee459
10 changed files with 38 additions and 51 deletions
|
|
@ -247,7 +247,6 @@ public class WordCountAnalyzerService : IWordCountAnalyzerService
|
|||
_unitOfWork.MangaFileRepository.Update(file);
|
||||
}
|
||||
|
||||
|
||||
private async Task<int> GetWordCountFromHtml(EpubLocalTextContentFileRef bookFile, string filePath)
|
||||
{
|
||||
try
|
||||
|
|
@ -256,7 +255,8 @@ public class WordCountAnalyzerService : IWordCountAnalyzerService
|
|||
doc.LoadHtml(await bookFile.ReadContentAsync());
|
||||
|
||||
var textNodes = doc.DocumentNode.SelectNodes("//body//text()[not(parent::script)]");
|
||||
return textNodes?.Sum(node => node.InnerText.Count(char.IsLetter)) / AverageCharactersPerWord ?? 0;
|
||||
var characterCount = textNodes?.Sum(node => node.InnerText.Count(char.IsLetter)) ?? 0;
|
||||
return GetWordCount(characterCount);
|
||||
}
|
||||
catch (EpubContentException ex)
|
||||
{
|
||||
|
|
@ -267,4 +267,10 @@ public class WordCountAnalyzerService : IWordCountAnalyzerService
|
|||
}
|
||||
}
|
||||
|
||||
public static int GetWordCount(int characterCount)
|
||||
{
|
||||
if (characterCount == 0) return 0;
|
||||
return characterCount / AverageCharactersPerWord;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue