Skip to content

Commit

Permalink
[TTS] Delete ContextualSearchEntityHeuristic.java
Browse files Browse the repository at this point in the history
Delete ContextualSearchEntityHeuristic.java and the metrics it records.
  Search.ContextualSearchEntitySeen

Bug:1325102

Change-Id: I33c96ba3862fbc9121d80382012cb090504646be
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3642731
Commit-Queue: Gang Wu <gangwu@chromium.org>
Reviewed-by: Donn Denman <donnd@chromium.org>
Reviewed-by: Tomasz Wiszkowski <ender@google.com>
Cr-Commit-Position: refs/heads/main@{#1002909}
  • Loading branch information
Gang Wu authored and Chromium LUCI CQ committed May 12, 2022
1 parent 9d2ffeb commit da3ebdd
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 576 deletions.
1 change: 0 additions & 1 deletion chrome/android/chrome_java_sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/contextmenu/ContextMenuUtils.java",
"java/src/org/chromium/chrome/browser/contextmenu/LensChipDelegate.java",
"java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchContext.java",
"java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchEntityHeuristic.java",
"java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchFieldTrial.java",
"java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchHeuristic.java",
"java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchHeuristics.java",
Expand Down
1 change: 0 additions & 1 deletion chrome/android/chrome_junit_test_java_sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ chrome_junit_test_java_sources = [
"junit/src/org/chromium/chrome/browser/contextmenu/ContextMenuCoordinatorTest.java",
"junit/src/org/chromium/chrome/browser/contextmenu/ContextMenuHeaderMediatorTest.java",
"junit/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchContextTest.java",
"junit/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchEntityHeuristicTest.java",
"junit/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchInternalStateTest.java",
"junit/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchSelectionControllerTest.java",
"junit/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTranslationImplTest.java",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ public abstract class ContextualSearchContext {
private int mSelectionStartOffset = INVALID_OFFSET;
private int mSelectionEndOffset = INVALID_OFFSET;

// The home country, or an empty string if not set.
@NonNull
private String mHomeCountry = "";

// The detected language of the context, or {@code null} if not yet detected, and empty if
// it cannot be reliably determined.
private String mDetectedLanguage;
Expand All @@ -67,12 +63,6 @@ public abstract class ContextualSearchContext {
// The offset of the tap within the tapped word, or {@code INVALID_OFFSET} if not yet analyzed.
private int mTapWithinWordOffset = INVALID_OFFSET;

// The words before and after the tapped word, and their offsets.
private String mWordPreviousToTap;
private int mWordPreviousToTapOffset = INVALID_OFFSET;
private String mWordFollowingTap;
private int mWordFollowingTapOffset = INVALID_OFFSET;

// Data about the previous user interactions and the event-ID from the server that will log it.
private long mPreviousEventId;
private int mPreviousUserInteractions;
Expand Down Expand Up @@ -112,7 +102,6 @@ void setResolveProperties(@NonNull String homeCountry, boolean doSendBasePageUrl
@NonNull String fluentLanguages) {
// TODO(donnd): consider making this a constructor variation.
mHasSetResolveProperties = true;
mHomeCountry = homeCountry;
mPreviousEventId = previousEventId;
mPreviousUserInteractions = previousUserInteractions;
ContextualSearchContextJni.get().setResolveProperties(getNativePointer(), this, homeCountry,
Expand Down Expand Up @@ -223,13 +212,6 @@ String getEncoding() {
return mEncoding;
}

/**
* @return The home country, or an empty string if none set.
*/
String getHomeCountry() {
return mHomeCountry;
}

/**
* @return The selection being resolved, or {@code null} if no resolve has been
* requested.
Expand Down Expand Up @@ -391,15 +373,6 @@ String getWordTapped() {
return mWordTapped;
}

/**
* @return The offset of the start of the tapped word, or {@code INVALID_OFFSET} if the tapped
* word cannot be identified by the current parsing capability.
* @see #analyzeTap(int)
*/
int getWordTappedOffset() {
return mWordTappedStartOffset;
}

/**
* @return The offset of the tap within the tapped word, or {@code INVALID_OFFSET} if the tapped
* word cannot be identified by the current parsing capability.
Expand All @@ -409,36 +382,6 @@ int getTapOffsetWithinTappedWord() {
return mTapWithinWordOffset;
}

/**
* @return The word previous to the word that was tapped, or {@code null} if not available.
*/
String getWordPreviousToTap() {
return mWordPreviousToTap;
}

/**
* @return The offset of the first character of the word previous to the word that was tapped,
* or {@code INVALID_OFFSET} if not available.
*/
int getWordPreviousToTapOffset() {
return mWordPreviousToTapOffset;
}

/**
* @return The word following the word that was tapped, or {@code null} if not available.
*/
String getWordFollowingTap() {
return mWordFollowingTap;
}

/**
* @return The offset of the first character of the word following the word that was tapped,
* or {@code INVALID_OFFSET} if not available.
*/
int getWordFollowingTapOffset() {
return mWordFollowingTapOffset;
}

/**
* Finds the words around the initial Tap offset by expanding and looking for word-breaks.
* This mimics the Blink word-segmentation invoked by SelectWordAroundCaret and similar
Expand All @@ -457,50 +400,8 @@ private void analyzeTap(int tapOffset) {
int wordEndOffset = findWordEndOffset(mTapOffset);
if (wordStartOffset == INVALID_OFFSET || wordEndOffset == INVALID_OFFSET) return;

mWordTappedStartOffset = wordStartOffset;
mWordTapped = mSurroundingText.substring(wordStartOffset, wordEndOffset);
mTapWithinWordOffset = mTapOffset - wordStartOffset;

findPreviousWord();
findFollowingWord();
}

/**
* Finds the word previous to the word tapped.
*/
private void findPreviousWord() {
// Scan past word-break characters preceding the tapped word.
int previousWordEndOffset = mWordTappedStartOffset;
while (previousWordEndOffset >= 1 && isWordBreakAtIndex(previousWordEndOffset - 1)) {
--previousWordEndOffset;
}
if (previousWordEndOffset == 0) return;

mWordPreviousToTapOffset = findWordStartOffset(previousWordEndOffset);
if (mWordPreviousToTapOffset == INVALID_OFFSET) return;

mWordPreviousToTap =
mSurroundingText.substring(mWordPreviousToTapOffset, previousWordEndOffset);
}

/**
* Finds the word following the word tapped.
*/
private void findFollowingWord() {
int tappedWordOffset = getWordTappedOffset();
int followingWordStartOffset = tappedWordOffset + mWordTapped.length() + 1;
while (followingWordStartOffset < mSurroundingText.length()
&& isWordBreakAtIndex(followingWordStartOffset)) {
++followingWordStartOffset;
}
if (followingWordStartOffset == mSurroundingText.length()) return;

int wordFollowingTapEndOffset = findWordEndOffset(followingWordStartOffset);
if (wordFollowingTapEndOffset == INVALID_OFFSET) return;

mWordFollowingTapOffset = followingWordStartOffset;
mWordFollowingTap =
mSurroundingText.substring(mWordFollowingTapOffset, wordFollowingTapEndOffset);
}

/**
Expand Down

0 comments on commit da3ebdd

Please sign in to comment.