public PatternUnit(PatternMatchingMode mode, bool optional, bool caseSensitive, PatternUnitType type, PartOfSpeech[] pos, string suffix, string prefix, string shape, string token, HashSet <string> set, string entityType, HashSet <ulong> setHashes, ulong tokenHash, PatternUnit leftSide, PatternUnit rightSide) { Mode = mode; Optional = optional; CaseSensitive = caseSensitive; Type = type; POS = pos; Suffix = suffix; Prefix = prefix; Shape = shape?.AsSpan().Shape(false); Token = token; Set = set; EntityType = entityType; SetHashes = setHashes ?? (set is null ? null : new HashSet <ulong>(set.Select(tk => CaseSensitive ? PatternUnitPrototype.Hash64(tk.AsSpan()) : PatternUnitPrototype.IgnoreCaseHash64(tk.AsSpan())))); TokenHash = tokenHash; LeftSide = leftSide; RightSide = rightSide; }
public PatternUnit(PatternMatchingMode mode, bool optional, bool caseSensitive, PatternUnitType type, PartOfSpeech[] pos, string suffix, string prefix, string shape, string token, HashSet <string> set, string entityType, HashSet <ulong> setHashes, ulong tokenHash, PatternUnit leftSide, PatternUnit rightSide) { Mode = mode; Optional = optional; CaseSensitive = caseSensitive; Type = type; POS = pos; Suffix = suffix; Prefix = prefix; Shape = shape?.AsSpan().Shape(false); Token = token; Set = set; EntityType = entityType; SetHashes = setHashes ?? (set is null ? null : new HashSet <ulong>(set.Select(tk => CaseSensitive ? PatternUnitPrototype.Hash64(tk.AsSpan()) : PatternUnitPrototype.IgnoreCaseHash64(tk.AsSpan())))); TokenHash = tokenHash; LeftSide = leftSide; RightSide = rightSide; _splitSuffix = Suffix?.Split(splitCharWithWhitespaces, StringSplitOptions.RemoveEmptyEntries)?.Distinct()?.ToArray(); _splitPrefix = Prefix?.Split(splitCharWithWhitespaces, StringSplitOptions.RemoveEmptyEntries)?.Distinct()?.ToArray(); _splitEntityType = EntityType is object?new HashSet <string>(EntityType.Split(splitChar, StringSplitOptions.RemoveEmptyEntries)) : null; _splitShape = Shape is object?new HashSet <string>(Shape.Split(splitCharWithWhitespaces, StringSplitOptions.RemoveEmptyEntries)) : null; }
public PatternUnit(IPatternUnit prototype) { var p = (PatternUnitPrototype)prototype; Mode = p.Mode; Optional = p.Optional; CaseSensitive = p.CaseSensitive; Type = p.Type; POS = p.POS; Suffix = p.Suffix; Prefix = p.Prefix; Shape = p.Shape; Token = p.Token; Set = p.Set; EntityType = p.EntityType; SetHashes = p.SetHashes ?? (p.Set is null ? null : new HashSet <ulong>(p.Set.Select(token => p.CaseSensitive ? PatternUnitPrototype.Hash64(token.AsSpan()) : PatternUnitPrototype.IgnoreCaseHash64(token.AsSpan())))); TokenHash = p.TokenHash; LeftSide = p.LeftSide is object?new PatternUnit(p.LeftSide) : null; RightSide = p.RightSide is object?new PatternUnit(p.RightSide) : null; ValidChars = p.ValidChars; MinLength = p.MinLength; MaxLength = p.MaxLength; }