blob: ab89c236b0709175d49524e875f5378215e85685 [file] [log] [blame]
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Datatypes and interfaces of grammar checker API.
// NOTE: This mojom exists in two places and must be kept in sync:
// Chromium: //chromeos/services/machine_learning/public/mojom/
// Chrome OS: src/platform2/ml/mojom/
// Note: Other repos downstream of Chromium might also use this mojom.
// Example: A backwards-compatible mojom change (and corresponding
// implementation change) can be made in Chrome OS first, then replicated to the
// clients (Chromium, other downstream repos) later.
// Use //chromeos/services/machine_learning/public/mojom/roll_mojom.sh to help
// replicate Chrome OS-side changes over to Chromium.
module chromeos.machine_learning.mojom;
// Defines a grammar check query.
struct GrammarCheckerQuery {
// Required: Text to be checked. This is expected to be a full sentence.
string text;
// Required: Language of the text to be checked, in BCP-47 format.
string language;
};
// One possible candidate returned from the grammar checker model.
struct GrammarCheckerCandidate {
// Corrected text.
string text;
// Score of the text. Log of conditional probability.
float score;
};
// The grammar check response.
struct GrammarCheckerResult {
// Status of the response.
enum Status {
// Grammar check succeeded.
OK = 0,
// Grammar check failed. In this case, candidates will be empty.
ERROR = 1,
};
Status status;
// Candidates of corrected text and their scores, sorted by higher score
// first.
array<GrammarCheckerCandidate> candidates;
};
// The mojom interface for performing the grammar check.
interface GrammarChecker {
// Performs grammar check on a piece of text, and returns a set of
// candidates of corrected text and their scores.
Check(GrammarCheckerQuery query) => (GrammarCheckerResult result);
};