mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 20:52:44 +01:00
Added "Total words" to statistics - thx Barbara :)
This commit is contained in:
parent
fea74b1fa3
commit
084c91d962
@ -6,7 +6,8 @@
|
||||
* New ...
|
||||
* IMPROVED:
|
||||
* Updated Chinese translation - thx Leon
|
||||
* Import plain text now also supports input as HTML
|
||||
* Import plain text now also supports input as HTML
|
||||
* Added "Total words" to statistics - thx Barbara
|
||||
* FIXED:
|
||||
* Fixed original file name bug in "Undo" - thx darnn
|
||||
* Fixed non default timecode scales in MKV - thx mkver
|
||||
|
@ -2048,6 +2048,7 @@ can edit in same subtitle file (collaboration)</Information>
|
||||
<LengthInFormatXinCharactersY>Number of characters as {0}: {1:#,###,##0}</LengthInFormatXinCharactersY>
|
||||
<NumberOfCharactersInTextOnly>Number of characters in text only: {0:#,###,##0}</NumberOfCharactersInTextOnly>
|
||||
<TotalCharsPerSecond>Total characters/second: {0:0.0} seconds</TotalCharsPerSecond>
|
||||
<TotalWords>Total words in subtitle: {0}</TotalWords>
|
||||
<NumberOfItalicTags>Number of italic tags: {0}</NumberOfItalicTags>
|
||||
<NumberOfBoldTags>Number of bold tags: {0}</NumberOfBoldTags>
|
||||
<NumberOfUnderlineTags>Number of underline tags: {0}</NumberOfUnderlineTags>
|
||||
|
@ -2351,6 +2351,7 @@ can edit in same subtitle file (collaboration)",
|
||||
NumberOfCharactersInTextOnly = "Number of characters in text only: {0:#,###,##0}",
|
||||
NumberOfItalicTags = "Number of italic tags: {0}",
|
||||
TotalCharsPerSecond = "Total characters/second: {0:0.0} seconds",
|
||||
TotalWords = "Total words in subtitle: {0}",
|
||||
NumberOfBoldTags = "Number of bold tags: {0}",
|
||||
NumberOfUnderlineTags = "Number of underline tags: {0}",
|
||||
NumberOfFontTags = "Number of font tags: {0}",
|
||||
|
@ -5533,6 +5533,9 @@ namespace Nikse.SubtitleEdit.Core
|
||||
case "Statistics/TotalCharsPerSecond":
|
||||
language.Statistics.TotalCharsPerSecond = reader.Value;
|
||||
break;
|
||||
case "Statistics/TotalWords":
|
||||
language.Statistics.TotalWords = reader.Value;
|
||||
break;
|
||||
case "Statistics/NumberOfItalicTags":
|
||||
language.Statistics.NumberOfItalicTags = reader.Value;
|
||||
break;
|
||||
|
@ -2230,6 +2230,7 @@
|
||||
public string LengthInFormatXinCharactersY { get; set; }
|
||||
public string NumberOfCharactersInTextOnly { get; set; }
|
||||
public string TotalCharsPerSecond { get; set; }
|
||||
public string TotalWords { get; set; }
|
||||
public string NumberOfItalicTags { get; set; }
|
||||
public string NumberOfBoldTags { get; set; }
|
||||
public string NumberOfUnderlineTags { get; set; }
|
||||
|
@ -15,6 +15,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private readonly LanguageStructure.Statistics _l;
|
||||
private string _mostUsedLines;
|
||||
private string _general;
|
||||
private int _totalWords;
|
||||
private string _mostUsedWords;
|
||||
private const string WriteFormat = @"File generated by: Subtitle Edit
|
||||
http://www.nikse.dk/subtitleedit/
|
||||
@ -45,21 +46,16 @@ https://github.com/SubtitleEdit/subtitleedit
|
||||
buttonOK.Text = Configuration.Settings.Language.General.Ok;
|
||||
UiUtil.FixLargeFonts(this, buttonOK);
|
||||
|
||||
CalculateWordStatistics();
|
||||
CalculateGeneralStatistics();
|
||||
{
|
||||
textBoxGeneral.Text = _general;
|
||||
textBoxGeneral.SelectionStart = 0;
|
||||
textBoxGeneral.SelectionLength = 0;
|
||||
textBoxGeneral.ScrollToCaret();
|
||||
}
|
||||
CalculateMostUsedWords();
|
||||
{
|
||||
textBoxMostUsedWords.Text = _mostUsedWords;
|
||||
}
|
||||
textBoxGeneral.Text = _general;
|
||||
textBoxGeneral.SelectionStart = 0;
|
||||
textBoxGeneral.SelectionLength = 0;
|
||||
textBoxGeneral.ScrollToCaret();
|
||||
textBoxMostUsedWords.Text = _mostUsedWords;
|
||||
|
||||
CalculateMostUsedLines();
|
||||
{
|
||||
textBoxMostUsedLines.Text = _mostUsedLines;
|
||||
}
|
||||
textBoxMostUsedLines.Text = _mostUsedLines;
|
||||
}
|
||||
|
||||
private void CalculateGeneralStatistics()
|
||||
@ -121,6 +117,7 @@ https://github.com/SubtitleEdit/subtitleedit
|
||||
sb.AppendLine(string.Format(_l.LengthInFormatXinCharactersY, _format.FriendlyName, sourceLength));
|
||||
sb.AppendLine(string.Format(_l.NumberOfCharactersInTextOnly, allText.Length));
|
||||
sb.AppendLine(string.Format(_l.TotalCharsPerSecond, HtmlUtil.RemoveHtmlTags(allText.ToString()).Length / (totalDuration / TimeCode.BaseUnit)));
|
||||
sb.AppendLine(string.Format(_l.TotalWords, _totalWords));
|
||||
sb.AppendLine(string.Format(_l.NumberOfItalicTags, Utilities.CountTagInText(allTextToLower, "<i>")));
|
||||
sb.AppendLine(string.Format(_l.NumberOfBoldTags, Utilities.CountTagInText(allTextToLower, "<b>")));
|
||||
sb.AppendLine(string.Format(_l.NumberOfUnderlineTags, Utilities.CountTagInText(allTextToLower, "<u>")));
|
||||
@ -155,7 +152,7 @@ https://github.com/SubtitleEdit/subtitleedit
|
||||
Clipboard.SetText(string.Format(WriteFormat, _general, _mostUsedWords, _mostUsedLines), TextDataFormat.UnicodeText);
|
||||
}
|
||||
|
||||
private static void MostUsedWordsAdd(Dictionary<string, int> hashtable, string text)
|
||||
private void MostUsedWordsAdd(Dictionary<string, int> hashtable, string text)
|
||||
{
|
||||
if (text.Contains("< "))
|
||||
text = HtmlUtil.FixInvalidItalicTags(text);
|
||||
@ -182,6 +179,7 @@ https://github.com/SubtitleEdit/subtitleedit
|
||||
foreach (string word in text.Split(ExpectedChars, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
var s = word.Trim();
|
||||
_totalWords++;
|
||||
if (s.Length > 1 && hashtable.ContainsKey(s))
|
||||
{
|
||||
hashtable[s]++;
|
||||
@ -240,7 +238,7 @@ https://github.com/SubtitleEdit/subtitleedit
|
||||
return text;
|
||||
}
|
||||
|
||||
private void CalculateMostUsedWords()
|
||||
private void CalculateWordStatistics()
|
||||
{
|
||||
var hashtable = new Dictionary<string, int>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user