Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33ff200c authored by Abodunrinwa Toki's avatar Abodunrinwa Toki
Browse files

Update TextClassifier Javadoc.

Bug: 65112496
Test: none
Change-Id: Id3732a2c8ed372be0f717346e6aa92b9e614ad04
parent 58488631
Loading
Loading
Loading
Loading
+46 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,52 @@ import java.util.List;


/**
/**
 * Information for generating a widget to handle classified text.
 * Information for generating a widget to handle classified text.
 *
 * <p>A TextClassification object contains icons, labels, onClickListeners and intents that may
 * be used to build a widget that can be used to act on classified text.
 *
 * <p>e.g. building a view that, when clicked, shares the classified text with the preferred app:
 *
 * <pre>{@code
 *   // Called preferably outside the UiThread.
 *   TextClassification classification = textClassifier.classifyText(allText, 10, 25, null);
 *
 *   // Called on the UiThread.
 *   Button button = new Button(context);
 *   button.setCompoundDrawablesWithIntrinsicBounds(classification.getIcon(), null, null, null);
 *   button.setText(classification.getLabel());
 *   button.setOnClickListener(classification.getOnClickListener());
 * }</pre>
 *
 * <p>e.g. starting an action mode with menu items that can handle the classified text:
 *
 * <pre>{@code
 *   // Called preferably outside the UiThread.
 *   final TextClassification classification = textClassifier.classifyText(allText, 10, 25, null);
 *
 *   // Called on the UiThread.
 *   view.startActionMode(new ActionMode.Callback() {
 *
 *       public boolean onCreateActionMode(ActionMode mode, Menu menu) {
 *           for (int i = 0; i < classification.getActionCount(); i++) {
 *               if (thisAppHasPermissionToInvokeIntent(classification.getIntent(i))) {
 *                   menu.add(Menu.NONE, i, 20, classification.getLabel(i))
 *                      .setIcon(classification.getIcon(i))
 *                      .setIntent(classification.getIntent(i));
 *               }
 *           }
 *           return true;
 *       }
 *
 *       public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
 *           context.startActivity(item.getIntent());
 *           return true;
 *       }
 *
 *       ...
 *   });
 * }</pre>
 *
 */
 */
public final class TextClassification {
public final class TextClassification {


+4 −4
Original line number Original line Diff line number Diff line
@@ -29,8 +29,8 @@ import java.lang.annotation.RetentionPolicy;
/**
/**
 * Interface for providing text classification related features.
 * Interface for providing text classification related features.
 *
 *
 * <p>Unless otherwise stated, methods of this interface are blocking operations and you should
 * <p>Unless otherwise stated, methods of this interface are blocking operations.
 * avoid calling them on the UI thread.
 * Avoid calling them on the UI thread.
 */
 */
public interface TextClassifier {
public interface TextClassifier {


@@ -75,8 +75,8 @@ public interface TextClassifier {
    };
    };


    /**
    /**
     * Returns suggested text selection indices, recognized types and their associated confidence
     * Returns suggested text selection start and end indices, recognized entity types, and their
     * scores. The selections are ordered from highest to lowest scoring.
     * associated confidence scores. The entity types are ordered from highest to lowest scoring.
     *
     *
     * @param text text providing context for the selected text (which is specified
     * @param text text providing context for the selected text (which is specified
     *      by the sub sequence starting at selectionStartIndex and ending at selectionEndIndex)
     *      by the sub sequence starting at selectionStartIndex and ending at selectionEndIndex)