Exemplo n.º 1
0
        /// <summary>
        /// Open the Shortn dialog window.  Used internally after the Shortn button is pressed, and by Ribbon for the debugging
        /// </summary>
        /// <param name="data"></param>
        public static void openShortnDialog(ShortnData data)
        {
            System.Windows.Forms.Form newForm = new System.Windows.Forms.Form();
            newForm.Width = 1200;
            newForm.Height = int.MaxValue;
            newForm.BackColor = System.Drawing.Color.White;

            // Create the ElementHost control for hosting the
            // WPF UserControl.
            ElementHost host = new ElementHost();
            host.Dock = System.Windows.Forms.DockStyle.Fill;

            // Create the WPF UserControl.
            ShortnDialog sd = new ShortnDialog(data);

            // Assign the WPF UserControl to the ElementHost control's
            // Child property.
            host.Child = sd;

            newForm.Visible = false;
            // Add the ElementHost control to the form's
            // collection of child controls.
            newForm.Controls.Add(host);
            newForm.Show();

            // set the form's height based on what the textbox wants to be
            int dialogHeight = (int)sd.grid.DesiredSize.Height;
            newForm.Height = (int)(sd.DesiredSize.Height + newForm.Padding.Vertical + System.Windows.Forms.SystemInformation.CaptionHeight + System.Windows.SystemParameters.ScrollWidth);
            sd.grid.Height = sd.grid.DesiredSize.Height;
            newForm.Width = 1200;
            host.MaximumSize = new System.Drawing.Size(1200, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
            newForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;

            newForm.Visible = true;
        }
Exemplo n.º 2
0
 /// <summary>
 /// The dialog window that opens when a user wants to interact with returned Shortn data.
 /// </summary>
 /// <param name="data">The Model for this Shortn job</param>
 public ShortnDialog(ShortnData data)
 {
     InitializeComponent();
     this.data = data;
     updateParagraphs(1);
     initSliderTicks();
 }
Exemplo n.º 3
0
        /// <summary>
        /// This constructor used only when recreating a job from XML saved with a document
        /// </summary>
        /// <param name="data"></param>
        /// <param name="jobNumber"></param>
        public ShortnJob(ShortnData data, int jobNumber, bool startTurk)
        {
            this.data = data;
            this.jobNumber = jobNumber;

            ShortnView hit = Globals.Soylent.soylentMap[Globals.Soylent.Application.ActiveDocument].addHIT(HIT_TYPE, data, jobNumber) as ShortnView;
            hit.addStage(1, HITData.ResultType.Find, data.findStageData, "Find Verbose Text", 10, 0.10, jobNumber);
            hit.addStage(2, HITData.ResultType.Fix, data.fixStageData, "Shorten Verbose Text", 5, 0.05, jobNumber);
            hit.addStage(3, HITData.ResultType.Verify, data.verifyStageData, "Quality Control", 5, 0.05, jobNumber);

            if (startTurk)
            {
                data.startTask();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// This constructor used only when recreating a job from XML saved with a document
        /// </summary>
        /// <param name="data"></param>
        /// <param name="jobNumber"></param>
        public ShortnJob(ShortnData data, int jobNumber, bool startTurk)
        {
            this.data      = data;
            this.jobNumber = jobNumber;

            ShortnView hit = Globals.Soylent.soylentMap[Globals.Soylent.Application.ActiveDocument].addHIT(HIT_TYPE, data, jobNumber) as ShortnView;

            hit.addStage(1, HITData.ResultType.Find, data.findStageData, "Find Verbose Text", 10, 0.10, jobNumber);
            hit.addStage(2, HITData.ResultType.Fix, data.fixStageData, "Shorten Verbose Text", 5, 0.05, jobNumber);
            hit.addStage(3, HITData.ResultType.Verify, data.verifyStageData, "Quality Control", 5, 0.05, jobNumber);

            if (startTurk)
            {
                data.startTask();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// The Model for a Shortn job.  This creates the View elements for this task
        /// </summary>
        /// <param name="data">The ShortnData instance for this job</param>
        /// <param name="jobNumber">The unique job number</param>
        //public ShortnJob(ShortnData data, int jobNumber)
        public ShortnJob(int jobNumber, Word.Range range)
        {
            //this.data = data;
            this.jobNumber = jobNumber;

            Globals.Soylent.jobToDoc[jobNumber] = Globals.Soylent.Application.ActiveDocument;

            this.data = new ShortnData(range, jobNumber);

            ShortnView hit = Globals.Soylent.soylentMap[Globals.Soylent.Application.ActiveDocument].addHIT(HIT_TYPE, data, jobNumber) as ShortnView;
            hit.addStage(1, HITData.ResultType.Find, data.findStageData, "Find Verbose Text", 10, 0.10, jobNumber);
            hit.addStage(2, HITData.ResultType.Fix, data.fixStageData, "Shorten Verbose Text", 5, 0.05, jobNumber);
            hit.addStage(3, HITData.ResultType.Verify, data.verifyStageData, "Quality Control", 5, 0.05, jobNumber);

            data.startTask();
        }
Exemplo n.º 6
0
        /// <summary>
        /// The Model for a Shortn job.  This creates the View elements for this task
        /// </summary>
        /// <param name="data">The ShortnData instance for this job</param>
        /// <param name="jobNumber">The unique job number</param>
        //public ShortnJob(ShortnData data, int jobNumber)
        public ShortnJob(int jobNumber, Word.Range range)
        {
            //this.data = data;
            this.jobNumber = jobNumber;

            Globals.Soylent.jobToDoc[jobNumber] = Globals.Soylent.Application.ActiveDocument;

            this.data = new ShortnData(range, jobNumber);

            ShortnView hit = Globals.Soylent.soylentMap[Globals.Soylent.Application.ActiveDocument].addHIT(HIT_TYPE, data, jobNumber) as ShortnView;

            hit.addStage(1, HITData.ResultType.Find, data.findStageData, "Find Verbose Text", 10, 0.10, jobNumber);
            hit.addStage(2, HITData.ResultType.Fix, data.fixStageData, "Shorten Verbose Text", 5, 0.05, jobNumber);
            hit.addStage(3, HITData.ResultType.Verify, data.verifyStageData, "Quality Control", 5, 0.05, jobNumber);

            data.startTask();
        }
Exemplo n.º 7
0
        /// <summary>
        /// HITView subclass specific to Shortn tasks.  This adds the Shortn button and additional necessary functionality.
        /// </summary>
        /// <param name="workType"></param>
        /// <param name="data"></param>
        public ShortnView(string workType, ShortnData data, int job)
            : base(workType, data, job)
        {
            //Globals.Soylent.soylent.Controls.Add(new System.Windows.Forms.Button());
            ShortnButton = new Button();
            ShortnButton.Content = "Shortn";
            ShortnButton.Name = "Shortn";
            ShortnButton.Height = 23;
            //ShortnButton.Width = 80;
            ShortnButton.IsEnabled = false;
            ShortnButton.Click += new RoutedEventHandler(Shortn_Clicked);

            data.register(this);
            //ShortnButton.
            //ShortnButton.Click = Shortn_Clicked;
            //stages.Children.Add(ShortnButton);
            StackPanel buttonPanel = new StackPanel();
            buttonPanel.Margin = new Thickness(5.0, 0.0, 5.0, 0.0);

            buttonPanel.Children.Add(ShortnButton);

            stages.Children.Add(buttonPanel);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Gets canned data for testing purposes
        /// </summary>
        /// <returns></returns>
        public static ShortnData getCannedData()
        {
            // insert text
            //Globals.Soylent.Application.Selection.Range.InsertAfter("Automatic clustering generally helps separate different kinds of records that need to be edited differently, but it isn't perfect. Sometimes it creates more clusters than needed, because the differences in structure aren't important to the user's particular editing task.  For example, if the user only needs to edit near the end of each line, then differences at the start of the line are largely irrelevant, and it isn't necessary to split based on those differences.  Conversely, sometimes the clustering isn't fine enough, leaving heterogeneous clusters that must be edited one line at a time.  One solution to this problem would be to let the user rearrange the clustering manually, perhaps using drag-and-drop to merge and split clusters.  Clustering and selection generalization would also be improved by recognizing common text structure like URLs, filenames, email addresses, dates, times, etc.  ");
            // select it
            Word.Range canned_range = Globals.Soylent.Application.ActiveDocument.Paragraphs[1].Range;


            List <ShortnPatch> canned_patches = new List <ShortnPatch>();

            foreach (Word.Range r in canned_range.Sentences)
            {
                List <string> options = new List <string>();
                //options.Add(r.Text);

                string textToMatch = null;
                bool   found       = false;

                if (r.Text.Contains(textToMatch = "because the differences in structure aren't important to the user's particular editing task"))
                {
                    found = true;
                    options.Add("because the differences in structure aren't relevant to a specific task");
                    options.Add("as structure differences aren't important to the editing task");
                    options.Add("because the structural differences aren't important to the user's editing task");
                }
                else if (r.Text.Contains(textToMatch = "For example, if the user only needs to edit near the end of each line, then differences at the start of the line are largely irrelevant, and it isn't necessary to split based on those differences.  "))
                {
                    found = true;
                    options.Add("For example, if the user only needs to edit near the end of each line, then differences at the start of the line are largely irrelevant.  ");
                    options.Add("");
                }
                else if (r.Text.Contains(textToMatch = "One solution to this problem would be to let the user rearrange the clustering manually, perhaps using drag-and-drop to merge and split clusters.  "))
                {
                    found = true;
                    options.Add("One solution to this problem would be to let the user rearrange the clustering manually.  ");
                    options.Add("One solution to this problem would be to let the user rearrange the clustering manually using drag-and-drop edits.  ");
                    options.Add("The user could solve this problem by merging and splitting clusters manually.  ");
                    options.Add("");
                }

                if (found)
                {
                    int start = r.Start + r.Text.IndexOf(textToMatch);
                    int end   = start + textToMatch.Length;

                    if (start - r.Start > 0)
                    {
                        Word.Range dummy1 = Globals.Soylent.Application.ActiveDocument.Range(r.Start, start);
                        canned_patches.Add(new DummyPatch(dummy1));
                    }

                    Word.Range newRange = Globals.Soylent.Application.ActiveDocument.Range(start, end);
                    options.Add(newRange.Text);
                    canned_patches.Add(new ShortnPatch(newRange, options));

                    if (r.End - end > 0)
                    {
                        Word.Range dummy2 = Globals.Soylent.Application.ActiveDocument.Range(end, r.End);
                        canned_patches.Add(new DummyPatch(dummy2));
                    }
                }
                else
                {
                    canned_patches.Add(new DummyPatch(r));
                }
            }

            ShortnData sd = new ShortnData(canned_range, Globals.Soylent.jobManager.generateJobNumber());

            sd.patches = canned_patches;
            return(sd);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets canned data for testing purposes
        /// </summary>
        /// <returns></returns>
        public static ShortnData getCannedData()
        {
            // insert text
            //Globals.Soylent.Application.Selection.Range.InsertAfter("Automatic clustering generally helps separate different kinds of records that need to be edited differently, but it isn't perfect. Sometimes it creates more clusters than needed, because the differences in structure aren't important to the user's particular editing task.  For example, if the user only needs to edit near the end of each line, then differences at the start of the line are largely irrelevant, and it isn't necessary to split based on those differences.  Conversely, sometimes the clustering isn't fine enough, leaving heterogeneous clusters that must be edited one line at a time.  One solution to this problem would be to let the user rearrange the clustering manually, perhaps using drag-and-drop to merge and split clusters.  Clustering and selection generalization would also be improved by recognizing common text structure like URLs, filenames, email addresses, dates, times, etc.  ");
            // select it
            Word.Range canned_range = Globals.Soylent.Application.ActiveDocument.Paragraphs[1].Range;

            List<ShortnPatch> canned_patches = new List<ShortnPatch>();
            foreach (Word.Range r in canned_range.Sentences)
            {
                List<string> options = new List<string>();
                //options.Add(r.Text);

                string textToMatch = null;
                bool found = false;

                if (r.Text.Contains(textToMatch = "because the differences in structure aren't important to the user's particular editing task"))
                {
                    found = true;
                    options.Add("because the differences in structure aren't relevant to a specific task");
                    options.Add("as structure differences aren't important to the editing task");
                    options.Add("because the structural differences aren't important to the user's editing task");
                }
                else if (r.Text.Contains(textToMatch = "For example, if the user only needs to edit near the end of each line, then differences at the start of the line are largely irrelevant, and it isn't necessary to split based on those differences.  "))
                {
                    found = true;
                    options.Add("For example, if the user only needs to edit near the end of each line, then differences at the start of the line are largely irrelevant.  ");
                    options.Add("");
                }
                else if (r.Text.Contains(textToMatch = "One solution to this problem would be to let the user rearrange the clustering manually, perhaps using drag-and-drop to merge and split clusters.  "))
                {
                    found = true;
                    options.Add("One solution to this problem would be to let the user rearrange the clustering manually.  ");
                    options.Add("One solution to this problem would be to let the user rearrange the clustering manually using drag-and-drop edits.  ");
                    options.Add("The user could solve this problem by merging and splitting clusters manually.  ");
                    options.Add("");
                }

                if (found)
                {
                    int start = r.Start + r.Text.IndexOf(textToMatch);
                    int end = start + textToMatch.Length;

                    if (start - r.Start > 0)
                    {
                        Word.Range dummy1 = Globals.Soylent.Application.ActiveDocument.Range(r.Start, start);
                        canned_patches.Add(new DummyPatch(dummy1));
                    }

                    Word.Range newRange = Globals.Soylent.Application.ActiveDocument.Range(start, end);
                    options.Add(newRange.Text);
                    canned_patches.Add(new ShortnPatch(newRange, options));

                    if (r.End - end > 0)
                    {
                        Word.Range dummy2 = Globals.Soylent.Application.ActiveDocument.Range(end, r.End);
                        canned_patches.Add(new DummyPatch(dummy2));
                    }
                }
                else
                {
                    canned_patches.Add(new DummyPatch(r));
                }
            }

            ShortnData sd = new ShortnData(canned_range, Globals.Soylent.jobManager.generateJobNumber());
            sd.patches = canned_patches;
            return sd;
        }