diff --git a/EditTools/Ribbon1.Designer.cs b/EditTools/Ribbon1.Designer.cs index c1ccc53..144c190 100644 --- a/EditTools/Ribbon1.Designer.cs +++ b/EditTools/Ribbon1.Designer.cs @@ -51,6 +51,7 @@ private void InitializeComponent() this.group4 = this.Factory.CreateRibbonGroup(); this.dd_Boilerplate = this.Factory.CreateRibbonDropDown(); this.btn_ApplyBoilerplate = this.Factory.CreateRibbonButton(); + this.btn_WordFreq = this.Factory.CreateRibbonButton(); this.EditingTools.SuspendLayout(); this.group1.SuspendLayout(); this.group2.SuspendLayout(); @@ -81,24 +82,29 @@ private void InitializeComponent() // this.btn_Settings.Label = "Settings"; this.btn_Settings.Name = "btn_Settings"; + this.btn_Settings.ScreenTip = "Add/remove/edit boilerplate and configure the edit distance for the proper noun c" + + "hecker"; this.btn_Settings.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btn_Settings_Click); // // btn_Export // this.btn_Export.Label = "Export"; this.btn_Export.Name = "btn_Export"; + this.btn_Export.ScreenTip = "Save your boilerplate to an XML file you can back up or share"; this.btn_Export.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btn_Export_Click); // // btn_Import // this.btn_Import.Label = "Import"; this.btn_Import.Name = "btn_Import"; + this.btn_Import.ScreenTip = "Import a boilerplate XML file"; this.btn_Import.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button1_Click); // // group2 // this.group2.Items.Add(this.dd_Langs); this.group2.Items.Add(this.btn_FixLang); + this.group2.Items.Add(this.btn_SingData); this.group2.Label = "Editing"; this.group2.Name = "group2"; // @@ -106,6 +112,8 @@ private void InitializeComponent() // this.dd_Langs.Label = "Languages"; this.dd_Langs.Name = "dd_Langs"; + this.dd_Langs.ScreenTip = "Apply selected language to the entire document, including notes, headers and foo" + + "ters"; this.dd_Langs.ShowLabel = false; this.dd_Langs.SizeString = "WWWWWWWWWWWWWWW"; // @@ -113,13 +121,15 @@ private void InitializeComponent() // this.btn_FixLang.Label = "Apply Language"; this.btn_FixLang.Name = "btn_FixLang"; + this.btn_FixLang.ScreenTip = "Apply selected language to the entire document, including notes, headers and foo" + + "ters"; this.btn_FixLang.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btn_FixLang_Click); // // group3 // this.group3.Items.Add(this.btn_WordList); + this.group3.Items.Add(this.btn_WordFreq); this.group3.Items.Add(this.btn_ProperNouns); - this.group3.Items.Add(this.btn_SingData); this.group3.Label = "Proofing"; this.group3.Name = "group3"; // @@ -127,18 +137,22 @@ private void InitializeComponent() // this.btn_WordList.Label = "Word List"; this.btn_WordList.Name = "btn_WordList"; + this.btn_WordList.ScreenTip = "Generate a list of all the unique words in the document"; this.btn_WordList.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btn_WordList_Click); // // btn_ProperNouns // - this.btn_ProperNouns.Label = "ProperNounAlyze"; + this.btn_ProperNouns.Label = "Check Proper Nouns"; this.btn_ProperNouns.Name = "btn_ProperNouns"; + this.btn_ProperNouns.ScreenTip = "Find proper nouns that sound alike or that differ by a configurable edit distance" + + ""; this.btn_ProperNouns.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btn_ProperNouns_Click); // // btn_SingData // this.btn_SingData.Label = "Find Singular Data"; this.btn_SingData.Name = "btn_SingData"; + this.btn_SingData.ScreenTip = "Find \"data\" used as a singular noun"; this.btn_SingData.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btn_SingData_Click); // // grp_Finishing @@ -164,6 +178,7 @@ private void InitializeComponent() // this.dd_Boilerplate.Label = "Comments"; this.dd_Boilerplate.Name = "dd_Boilerplate"; + this.dd_Boilerplate.ScreenTip = "Use the \"Settings\" button to add/remove/edit boilerplate"; this.dd_Boilerplate.ShowLabel = false; this.dd_Boilerplate.SizeString = "WWWWWWWWWWWWWWW"; // @@ -171,8 +186,16 @@ private void InitializeComponent() // this.btn_ApplyBoilerplate.Label = "Apply Comment"; this.btn_ApplyBoilerplate.Name = "btn_ApplyBoilerplate"; + this.btn_ApplyBoilerplate.ScreenTip = "Click to apply selected comment to the selected text; Use the \"Settings\" button t" + + "o add/remove/edit boilerplate"; this.btn_ApplyBoilerplate.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btn_ApplyBoilerplate_Click); // + // btn_WordFreq + // + this.btn_WordFreq.Label = "Word Frequency List"; + this.btn_WordFreq.Name = "btn_WordFreq"; + this.btn_WordFreq.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btn_WordFreq_Click); + // // Ribbon1 // this.Name = "Ribbon1"; @@ -214,6 +237,7 @@ private void InitializeComponent() internal Microsoft.Office.Tools.Ribbon.RibbonButton btn_SingData; internal Microsoft.Office.Tools.Ribbon.RibbonGroup grp_Finishing; internal Microsoft.Office.Tools.Ribbon.RibbonButton btn_AcceptFormatting; + internal Microsoft.Office.Tools.Ribbon.RibbonButton btn_WordFreq; } partial class ThisRibbonCollection diff --git a/EditTools/Ribbon1.cs b/EditTools/Ribbon1.cs index 1898ec9..d6e048c 100644 --- a/EditTools/Ribbon1.cs +++ b/EditTools/Ribbon1.cs @@ -554,5 +554,71 @@ private void btn_AcceptFormatting_Click(object sender, RibbonControlEventArgs e) view.ShowInsertionsAndDeletions = true; MessageBox.Show("Formatting changes have been accepted."); } + + private void btn_WordFreq_Click(object sender, RibbonControlEventArgs e) + { + Word.Document doc = Globals.ThisAddIn.Application.ActiveDocument; + Dictionary wordlist = new Dictionary(); + Regex re_allnums = new Regex(@"^\d+$"); + + foreach (Word.Range rng in TextHelpers.GetText(doc)) + { + string txt = rng.Text; + + //strip punctuation + txt = TextHelpers.StripPunctuation(txt); + + + string[] substrs = Regex.Split(txt, @"\s+"); + foreach (string word in substrs) + { + Match m = re_allnums.Match(word); + if (!m.Success) + { + if (wordlist.ContainsKey(word)) { + wordlist[word]++; + } else + { + wordlist.Add(word, 1); + } + } + + } + } + + //Create new document + Word.Document newdoc = Globals.ThisAddIn.Application.Documents.Add(); + Word.Paragraph pgraph; + + //Intro text + pgraph = newdoc.Content.Paragraphs.Add(); + pgraph.set_Style(newdoc.Styles["Heading 1"]); + pgraph.Range.Text = "Word Frequency List\n"; + pgraph = newdoc.Content.Paragraphs.Add(); + pgraph.set_Style(newdoc.Styles["Normal"]); + pgraph.Range.Text = "Capitalization is retained as is. That means that words that appear at the beginning of a sentence will appear capitalized. Don't forget that you can sort the table!\n"; + + pgraph = newdoc.Content.Paragraphs.Add(); + pgraph.Range.InsertBreak(Word.WdBreakType.wdSectionBreakContinuous); + Word.Section sec = newdoc.Sections[2]; + sec.PageSetup.TextColumns.SetCount(3); + + var words = wordlist.ToList(); + words.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value)); + newdoc.Tables.Add(pgraph.Range, words.Count, 2); + int row = 1; + foreach (var pair in words) + { + Word.Cell cell = newdoc.Tables[1].Cell(row, 1); + cell.Range.Text = pair.Key; + cell = newdoc.Tables[1].Cell(row, 2); + cell.Range.Text = pair.Value.ToString(); + row++; + } + + pgraph = newdoc.Content.Paragraphs.Add(); + pgraph.Range.InsertBreak(Word.WdBreakType.wdSectionBreakContinuous); + newdoc.GrammarChecked = true; + } } } diff --git a/README.md b/README.md index 2bc41ed..b858af6 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,11 @@ These are just a couple tools I coded for use where I work. Features include a * one-click language applicator, -* one-click "accept formatting changes," -* proper noun discrepancy checker, +* "singular data" finder, * word list generator, -* "singular data" finder, and +* word frequency generator, +* proper noun discrepancy checker, +* one-click "accept formatting changes," and * comment boilerplate manager. The language applicator applies the language to *all* text, including notes, headers, and footers. Text boxes and frames may be skipped. I haven't done extensive testing around those. diff --git a/deploy/make-installer.iss b/deploy/make-installer.iss index cea06a4..f2ffac2 100644 --- a/deploy/make-installer.iss +++ b/deploy/make-installer.iss @@ -34,10 +34,10 @@ ; The version number. It is suggested to use the semantic versionin ; scheme (http://semver.org), but this is not a must. This version ; information may contain text. -#define SEMANTIC_VERSION "1.1.0" +#define SEMANTIC_VERSION "1.2.0" ; The version in four-number format -#define FOUR_NUMBER_VERSION "1.1.0.0" +#define FOUR_NUMBER_VERSION "1.2.0.0" ; The year(s) of publication (e.g., "2014-2017") #define PUB_YEARS "2017" diff --git a/screen-capture.jpg b/screen-capture.jpg index ea1571f..2d3b4a6 100644 Binary files a/screen-capture.jpg and b/screen-capture.jpg differ