-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
EdgeNGramTokenFilter.cs
130 lines (110 loc) · 4.34 KB
/
EdgeNGramTokenFilter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.Text.Json;
using Azure.Core;
namespace Azure.Search.Documents.Indexes.Models
{
[CodeGenModel("EdgeNGramTokenFilterV2")]
[CodeGenSuppress(nameof(EdgeNGramTokenFilter), typeof(string), typeof(string), typeof(int?), typeof(int?), typeof(EdgeNGramTokenFilterSide?))]
public partial class EdgeNGramTokenFilter : IUtf8JsonSerializable
{
/// <summary> Initializes a new instance of EdgeNGramTokenFilter. </summary>
/// <param name="name"> The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. </param>
public EdgeNGramTokenFilter(string name) : base(name)
{
Argument.AssertNotNull(name, nameof(name));
ODataType = "#Microsoft.Azure.Search.EdgeNGramTokenFilterV2";
}
/// <summary>
/// The minimum n-gram length. Default is 1. Must be less than the value of maxGram.
/// </summary>
public int? MinGram { get; set; }
/// <summary>
/// The maximum n-gram length. Default is 2.
/// </summary>
public int? MaxGram { get; set; }
/// <summary>
/// Specifies which side of the input the n-gram should be generated from. Default is <see cref="EdgeNGramTokenFilterSide.Front"/>.
/// </summary>
public EdgeNGramTokenFilterSide? Side { get; set; }
void global::Azure.Core.IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
writer.WritePropertyName("@odata.type");
writer.WriteStringValue(ODataType);
writer.WritePropertyName("name");
writer.WriteStringValue(Name);
if (MinGram != null)
{
writer.WritePropertyName("minGram");
writer.WriteNumberValue(MinGram.Value);
}
if (MaxGram != null)
{
writer.WritePropertyName("maxGram");
writer.WriteNumberValue(MaxGram.Value);
}
if (Side != null)
{
writer.WritePropertyName("side");
writer.WriteStringValue(Side.Value.ToSerialString());
}
writer.WriteEndObject();
}
internal static EdgeNGramTokenFilter DeserializeEdgeNGramTokenFilter(JsonElement element)
{
int? minGram = default;
int? maxGram = default;
EdgeNGramTokenFilterSide? side = default;
string odataType = default;
string name = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("@odata.type"))
{
odataType = property.Value.GetString();
continue;
}
if (property.NameEquals("name"))
{
name = property.Value.GetString();
continue;
}
if (property.NameEquals("minGram"))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
minGram = property.Value.GetInt32();
continue;
}
if (property.NameEquals("maxGram"))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
maxGram = property.Value.GetInt32();
continue;
}
if (property.NameEquals("side"))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
side = property.Value.GetString().ToEdgeNGramTokenFilterSide();
continue;
}
}
return new EdgeNGramTokenFilter(name)
{
ODataType = odataType,
MinGram = minGram,
MaxGram = maxGram,
Side = side,
};
}
}
}