blob: 963fb35aafa1770ad7f0aace95ead4cdcae15b7e [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_mojoms.sh to help
// replicate Chrome OS-side changes over to Chromium.
module chromeos.machine_learning.mojom;
// Defines a grammar check query.
[Stable]
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;
};
// A span with suggested corrections.
[Stable]
struct GrammarCorrectionFragment {
// The start offset in the original text.
uint32 offset;
// The length of the fragment in the original text.
uint32 length;
// The replacement string.
string replacement;
};
// One possible candidate returned from the grammar checker model.
[Stable]
struct GrammarCheckerCandidate {
// Corrected text.
string text;
// Score of the text. Log of conditional probability.
float score;
// The list of individual corrections.
array<GrammarCorrectionFragment> fragments;
};
// The grammar check response.
[Stable]
struct GrammarCheckerResult {
// Status of the response.
[Stable, Extensible]
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.
// Next ordinal: 1
[Stable]
interface GrammarChecker {
// Performs grammar check on a piece of text, and returns a set of
// candidates of corrected text and their scores.
Check@0(GrammarCheckerQuery query) => (GrammarCheckerResult result);
};