This class contain the same data structure for the Suggestion object in Java ACP. It is used for to convert between JSON and object. Author: Loke Yan Hao
예제 #1
0
        public void chooseSuggestion(Suggestion suggestion)
        {
            List<Object> parameters = new List<Object>();
            parameters.Add(suggestion);
            Operation operation = new Operation("chooseSuggestion", parameters);

            OperationResult result = invokeRemote(operation);
        }
예제 #2
0
        public void setupExtensionMode(Suggestion suggestion)
        {
            // Turn on extension mode
            extensionMode = true;
            extensions = new List<Suggestion>();
            paragraphPos = new List<int>();

            // Add suggestion to extensions
            extensions.Add(suggestion);
            extensionPos = 0;
        }
예제 #3
0
        public void insertSuggestion(Suggestion suggestion)
        {
            // for User Testing
            endReqSuggTime = DateTime.Now;
            appendReqSuggTimeString();

            Word.Range range = currentSelection.Range;

            int characterCount = 0;

            switch (suggestion.type)
            {
                case Suggestion.SENTENCE:
                    // Find out the number of words before last sentence
                    characterCount = getWordsBeforeLastSentence().TrimStart().Count();
                    break;
                case Suggestion.ENTITY:
                    // Replace the last few word(s)
                    characterCount = checkEntityWords((Entity)suggestion);
                    break;
            }

            // Replace the text before last sentence with the choosen suggestion
            range = currentSelection.Range;
            extMode.setExtensionRange(range);
            range.MoveStart(Word.WdUnits.wdCharacter, -characterCount);
            switch (suggestion.type)
            {
                case Suggestion.SENTENCE:
                    range.Text = ((Sentence)suggestion).content + ExtensionMode.extraSpace;
                    break;
                case Suggestion.ENTITY:
                    range.Text = ((Entity)suggestion).content;
                    break;
            }

            // Reposition the cursor to the end of the sentence that is just pasted
            int position = range.End;
            currentSelection.SetRange(position, position);

            // Hide the form
            autoCompleteForm.Hide();

            if (suggestion.type == Suggestion.SENTENCE)
            {
                ExtensionMode.highlight(range);
                extMode.setupExtensionMode(suggestion);

                extendSuggestionForm.updateLocation(applicationLocation, applicationSize);
                extendSuggestionForm.ShowForm();
            }

            // Inform ACP the suggestion that was selected for Ranking purpose.
            logic.chooseSuggestion(suggestion);
        }