xref: /aosp_15_r20/external/googleapis/google/cloud/dataqna/v1alpha/annotated_string.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2020 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.cloud.dataqna.v1alpha;
18
19option csharp_namespace = "Google.Cloud.DataQnA.V1Alpha";
20option go_package = "cloud.google.com/go/dataqna/apiv1alpha/dataqnapb;dataqnapb";
21option java_multiple_files = true;
22option java_outer_classname = "AnnotatedStringProto";
23option java_package = "com.google.cloud.dataqna.v1alpha";
24option php_namespace = "Google\\Cloud\\DataQnA\\V1alpha";
25option ruby_package = "Google::Cloud::DataQnA::V1alpha";
26
27// Describes string annotation from both semantic and formatting perspectives.
28// Example:
29//
30// User Query:
31//
32//   top countries by population in Africa
33//
34//   0   4         14 17         28 31    37
35//
36// Table Data:
37//
38// + "country" - dimension
39// + "population" - metric
40// + "Africa" - value in the "continent" column
41//
42// text_formatted = `"top countries by population in Africa"`
43//
44// html_formatted =
45//   `"top <b>countries</b> by <b>population</b> in <i>Africa</i>"`
46//
47// ```
48// markups = [
49//   {DIMENSION, 4, 12}, // 'countries'
50//   {METRIC, 17, 26}, // 'population'
51//   {FILTER, 31, 36}  // 'Africa'
52// ]
53// ```
54//
55// Note that html formattings for 'DIMENSION' and 'METRIC' are the same, while
56// semantic markups are different.
57message AnnotatedString {
58  // Semantic markup denotes a substring (by index and length) with markup
59  // information.
60  message SemanticMarkup {
61    // The semantic type of the markup substring.
62    SemanticMarkupType type = 1;
63
64    // Unicode character index of the query.
65    int32 start_char_index = 2;
66
67    // The length (number of unicode characters) of the markup substring.
68    int32 length = 3;
69  }
70
71  // Semantic markup types.
72  enum SemanticMarkupType {
73    // No markup type was specified.
74    MARKUP_TYPE_UNSPECIFIED = 0;
75
76    // Markup for a substring denoting a metric.
77    METRIC = 1;
78
79    // Markup for a substring denoting a dimension.
80    DIMENSION = 2;
81
82    // Markup for a substring denoting a filter.
83    FILTER = 3;
84
85    // Markup for an unused substring.
86    UNUSED = 4;
87
88    // Markup for a substring containing blocked phrases.
89    BLOCKED = 5;
90
91    // Markup for a substring that contains terms for row.
92    ROW = 6;
93  }
94
95  // Text version of the string.
96  string text_formatted = 1;
97
98  // HTML version of the string annotation.
99  string html_formatted = 2;
100
101  // Semantic version of the string annotation.
102  repeated SemanticMarkup markups = 3;
103}
104