annotated_string.proto 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. syntax = "proto3";
  15. package google.cloud.dataqna.v1alpha;
  16. option csharp_namespace = "Google.Cloud.DataQnA.V1Alpha";
  17. option go_package = "google.golang.org/genproto/googleapis/cloud/dataqna/v1alpha;dataqna";
  18. option java_multiple_files = true;
  19. option java_outer_classname = "AnnotatedStringProto";
  20. option java_package = "com.google.cloud.dataqna.v1alpha";
  21. option php_namespace = "Google\\Cloud\\DataQnA\\V1alpha";
  22. option ruby_package = "Google::Cloud::DataQnA::V1alpha";
  23. // Describes string annotation from both semantic and formatting perspectives.
  24. // Example:
  25. //
  26. // User Query:
  27. //
  28. // top countries by population in Africa
  29. //
  30. // 0 4 14 17 28 31 37
  31. //
  32. // Table Data:
  33. //
  34. // + "country" - dimension
  35. // + "population" - metric
  36. // + "Africa" - value in the "continent" column
  37. //
  38. // text_formatted = `"top countries by population in Africa"`
  39. //
  40. // html_formatted =
  41. // `"top <b>countries</b> by <b>population</b> in <i>Africa</i>"`
  42. //
  43. // ```
  44. // markups = [
  45. // {DIMENSION, 4, 12}, // 'countries'
  46. // {METRIC, 17, 26}, // 'population'
  47. // {FILTER, 31, 36} // 'Africa'
  48. // ]
  49. // ```
  50. //
  51. // Note that html formattings for 'DIMENSION' and 'METRIC' are the same, while
  52. // semantic markups are different.
  53. message AnnotatedString {
  54. // Semantic markup denotes a substring (by index and length) with markup
  55. // information.
  56. message SemanticMarkup {
  57. // The semantic type of the markup substring.
  58. SemanticMarkupType type = 1;
  59. // Unicode character index of the query.
  60. int32 start_char_index = 2;
  61. // The length (number of unicode characters) of the markup substring.
  62. int32 length = 3;
  63. }
  64. // Semantic markup types.
  65. enum SemanticMarkupType {
  66. // No markup type was specified.
  67. MARKUP_TYPE_UNSPECIFIED = 0;
  68. // Markup for a substring denoting a metric.
  69. METRIC = 1;
  70. // Markup for a substring denoting a dimension.
  71. DIMENSION = 2;
  72. // Markup for a substring denoting a filter.
  73. FILTER = 3;
  74. // Markup for an unused substring.
  75. UNUSED = 4;
  76. // Markup for a substring containing blocked phrases.
  77. BLOCKED = 5;
  78. // Markup for a substring that contains terms for row.
  79. ROW = 6;
  80. }
  81. // Text version of the string.
  82. string text_formatted = 1;
  83. // HTML version of the string annotation.
  84. string html_formatted = 2;
  85. // Semantic version of the string annotation.
  86. repeated SemanticMarkup markups = 3;
  87. }