public void RunMacro_Click(object sender, RoutedEventArgs e)
        {
            HumanMacroData.Separator separator = HumanMacroData.Separator.Sentence;
            if (separatorBox.SelectedItem == item2)
            {
                separator = HumanMacroData.Separator.Sentence;
            }
            else if (separatorBox.SelectedItem == item1)
            {
                separator = HumanMacroData.Separator.Paragraph;
            }

            double reward; int redundancy; string localtitle; string localsubtitle; string localinstructions;

            /*
             * if (Soylent.DEBUG == true)
             * {
             *  reward = 0.05;
             *  redundancy = 2;
             *  localtitle = "\"Make my novel present tense\"";
             *  localsubtitle = "\"I need to change some prose from past to present tense\"";
             *  localinstructions = "'I am changing this section of my novel from the past tense to the present tense. Please read and fix to make everything present tense, e.g., \"Susan swerved and aimed the gun at her assailant. The man recoiled, realizing that his prey had now caught on to the scheme.\" becomes \"Susan swerves and aims the gun at her assailant. The man recoils, realizing that his prey had now caught on to the scheme.\"'";
             * }
             * else
             * {
             */
            reward            = payment;
            redundancy        = numRepetitions;
            localtitle        = title;
            localsubtitle     = subtitle;
            localinstructions = instructions;
            //}

            HumanMacroData.ReturnType type = HumanMacroData.ReturnType.Comment;
            if (returnTypeBox.SelectedItem == returnAsComments)
            {
                type = HumanMacroData.ReturnType.Comment;
            }
            else if (returnTypeBox.SelectedItem == returnAsInline)
            {
                type = HumanMacroData.ReturnType.SmartTag;
            }


            //Debug.WriteLine("########################");
            //Debug.WriteLine("Reward: " + reward + " || Redundancy: "+redundancy+" || Title: "+localtitle+" || Subtitle: "+localsubtitle+" || Instructions: "+localinstructions);
            //Debug.WriteLine(separatorBox.SelectedValue.ToString() + " 1 " + (item2 == separatorBox.SelectedValue) + " 2 " + (item2 == separatorBox.SelectionBoxItem) + " 3 " + (item2 == separatorBox.SelectedItem) + " 4 " + (item2.Content == separatorBox.SelectedValuePath));

            //HumanMacroData data = new HumanMacroData(text, jobNumber, separator, reward, redundancy, localtitle, localsubtitle, localinstructions, type, HumanMacroData.TestOrReal.Real);

            //HumanMacroJob job = new HumanMacroJob(data, jobNumber);
            HumanMacroJob job = new HumanMacroJob(text, jobNumber, separator, reward, redundancy, localtitle, localsubtitle, localinstructions, type, HumanMacroData.TestOrReal.Real);

            HwndSource source = (HwndSource)PresentationSource.FromVisual(sender as Button);

            System.Windows.Forms.Control ctl = System.Windows.Forms.Control.FromChildHandle(source.Handle);
            ctl.FindForm().Close();
        }
Example #2
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 void insertTrackChanges()
        {
            data.prepareRanges();
            HumanMacroData.ReturnType type = data.type;
            Globals.Soylent.Application.ActiveDocument.TrackRevisions = true;
            Globals.Soylent.Application.ActiveDocument.ShowRevisions  = true;

            Microsoft.Office.Core.DocumentProperties properties;

            properties = (Microsoft.Office.Core.DocumentProperties)Globals.Soylent.Application.ActiveDocument.BuiltInDocumentProperties;

            string defaultAuthor = properties["Author"].Value as string;

            /*
             * if (defaultAuthor == turkerName)
             * {
             *  turkerName = turkerName + "B";
             * }*/

            foreach (Patch patch in data.patches)
            {
                string comment = "";
                foreach (string suggestion in patch.replacements)
                {
                    if (patch.replacements.IndexOf(suggestion) == 0)
                    {
                        if (type == HumanMacroData.ReturnType.Comment)
                        {
                            comment += suggestion;
                            if (patch.replacements.Count > 1)
                            {
                                comment += "\n\nOther Suggestions:";
                            }
                        }
                        else
                        {
                            if (patch.replacements.Count > 1)
                            {
                                comment += "Other Suggestions:";
                            }
                        }
                    }
                    else
                    {
                        comment += "\n - ";
                        comment += suggestion;
                    }
                }
                object commentText = comment;
                if (comment != "")
                {
                    Microsoft.Office.Interop.Word.Comment c = Globals.Soylent.Application.ActiveDocument.Comments.Add(patch.range, commentText);
                    c.Author = jobTurkerName;
                }

                if (type == HumanMacroData.ReturnType.SmartTag)
                {
                    Globals.Soylent.Application.UserName = jobTurkerName;
                    if (patch.replacements.Count > 0)
                    {
                        patch.range.Text = patch.replacements[0];
                    }
                    Globals.Soylent.Application.UserName = defaultAuthor;
                }
            }

            /*
             * foreach (Microsoft.Office.Interop.Word.Comment c in Globals.Soylent.Application.ActiveDocument.Comments)
             * {
             *  c.Author = jobTurkerName;
             *  c.Initial = jobTurkerName;
             * }
             */

            //this.AcceptRevisions.IsEnabled = true;
            //this.stages.Children.Remove(CrowdproofButton);
            //this.stages.Children.Add(buttons);
            AcceptRevisions.IsEnabled  = true;
            RejectRevisions.IsEnabled  = true;
            HumanMacroButton.IsEnabled = false;

            stub.AcceptRevisions.IsEnabled  = true;
            stub.RejectRevisions.IsEnabled  = true;
            stub.CrowdproofButton.IsEnabled = false;

            Globals.Soylent.Application.ActiveDocument.TrackRevisions = false;
        }
Example #3
0
        /// <summary>
        /// The Model for a Crowdproof job.  This creates the View elements for this task
        /// </summary>
        /// <param name="data">The CrowdproofData instance for this job</param>
        /// <param name="jobNumber">The unique job number</param>
        //public HumanMacroJob(HumanMacroData data, int jobNumber)
        //public HumanMacroJob(int jobNumber, Microsoft.Office.Interop.Word.Range range)
        public HumanMacroJob(Microsoft.Office.Interop.Word.Range toShorten, int job, HumanMacroData.Separator separator, double reward, int redundancy, string title, string subtitle, string instructions, HumanMacroData.ReturnType type, HumanMacroData.TestOrReal test)
        {
            //this.data = data;
            this.jobNumber = job;

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

            this.data = new HumanMacroData(toShorten, job, separator, reward, redundancy, title, subtitle, instructions, type, test);

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

            hit.addStage(1, HITData.ResultType.Macro, data.macroStageData, "Running Macro", 10, 0.10, jobNumber);
            //hit.addStage(2, HITData.ResultType.Fix, "Fix Errors", 5, 0.05);
            //hit.addStage(3, HITData.ResultType.Verify, "Quality Control", 5, 0.05);

            data.startTask();
        }