Class SegmentationRules
A collection of segmentation rules.
Implements
Inherited Members
Namespace: SdlSdl.LanguagePlatformCoreSegmentation
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
[DataContract]
public class SegmentationRules : ICloneable
Constructors
SegmentationRules()
Initializes a new instance with default values. This constructor is required for XML deserialization and should not be used directly.
Declaration
public SegmentationRules()
SegmentationRules(CultureCode, string)
Initializes a new instance with the specified values.
Declaration
public SegmentationRules(CultureCode culture, string description)
Parameters
Type | Name | Description |
---|---|---|
CultureCode | culture | The culture for which to apply this segmentation rule set. This culture is also used to retrieve additional language resources, if required. |
string | description | A description for this segmentation rules set. |
SegmentationRules(SegmentationRules)
Initializes a new instance with the values of another instance, creating a deep copy.
Declaration
public SegmentationRules(SegmentationRules other)
Parameters
Type | Name | Description |
---|---|---|
SegmentationRules | other | The other instance |
SegmentationRules(string, string)
Initializes a new instance with the specified values.
Declaration
public SegmentationRules(string cultureName, string description)
Parameters
Type | Name | Description |
---|---|---|
string | cultureName | The culture for which to apply this segmentation rule set. This culture is also used to retrieve additional language resources, if required. |
string | description | A description for this segmentation rules set. |
Properties
Count
Gets the number of rules in this rule set.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
Culture
Gets the culture for which to apply this segmentation rule set.
Declaration
[Obsolete("Use CultureName")]
public CultureInfo Culture { get; }
Property Value
Type | Description |
---|---|
CultureInfo |
CultureName
Gets or sets the name of the culture to which to apply this segmentation rules. This property is primarily intended for XML deserialization and should not be used directly.
Declaration
[DataMember]
public string CultureName { get; set; }
Property Value
Type | Description |
---|---|
string |
Description
Gets or sets the description of this rule set.
Declaration
[DataMember]
public LocalizedString Description { get; set; }
Property Value
Type | Description |
---|---|
LocalizedString |
this[int]
Gets the segmentation rule at the specified zero-based position.
Declaration
public SegmentationRule this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based index |
Property Value
Type | Description |
---|---|
SegmentationRule |
ListReferencesResolved
Returns a flag which indicates whether references to externally stored word lists (abbreviations, ordinal followers, ...) have been resolved during Load or not. If not, the rule set should not be used for segmentation, only for display, editing, serialization, or copying across resource containers.
Note that if the rule set does not refer to external lists, this flag will still be set to true if the resolution has been attempted.
Declaration
public bool ListReferencesResolved { get; }
Property Value
Type | Description |
---|---|
bool |
Rules
Gets or sets the rules for this rule set.
Declaration
[DataMember]
public List<SegmentationRule> Rules { get; set; }
Property Value
Type | Description |
---|---|
ListSegmentationRule |
Methods
Add(object)
Adds the specified object, which must be a non-null SegmentationRule, to the list of rules. This method is for XML deserialization only and should not be used.
Declaration
public void Add(object o)
Parameters
Type | Name | Description |
---|---|---|
object | o |
AddRule(SegmentationRule)
Adds the specified rule to the rule set (non-null).
Declaration
public void AddRule(SegmentationRule r)
Parameters
Type | Name | Description |
---|---|---|
SegmentationRule | r |
Clone()
Declaration
public object Clone()
Returns
Type | Description |
---|---|
object | A new object that is a deep copy of this instance. |
GetEnumerator()
Returns an enumerator which can be used to iterate through the segmentation rules.
Declaration
public IEnumerator<SegmentationRule> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumeratorSegmentationRule | An enumerator |
Load(Stream, CultureCode, IResourceDataAccessor)
Declaration
[Obsolete("Use LoadAsync")]
public static SegmentationRules Load(Stream reader, CultureCode cultureOverride, IResourceDataAccessor accessor)
Parameters
Type | Name | Description |
---|---|---|
Stream | reader | |
CultureCode | cultureOverride | |
IResourceDataAccessor | accessor |
Returns
Type | Description |
---|---|
SegmentationRules |
Load(Stream, CultureCode, IResourceDataAccessor, bool)
Declaration
[Obsolete("Use LoadAsync")]
public static SegmentationRules Load(Stream reader, CultureCode cultureOverride, IResourceDataAccessor accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
Stream | reader | |
CultureCode | cultureOverride | |
IResourceDataAccessor | accessor | |
bool | keepListReferences |
Returns
Type | Description |
---|---|
SegmentationRules |
Load(Stream, string, IResourceDataAccessor)
Declaration
[Obsolete("Use LoadAsync")]
public static SegmentationRules Load(Stream reader, string cultureOverride, IResourceDataAccessor accessor)
Parameters
Type | Name | Description |
---|---|---|
Stream | reader | |
string | cultureOverride | |
IResourceDataAccessor | accessor |
Returns
Type | Description |
---|---|
SegmentationRules |
Load(Stream, string, IResourceDataAccessor, bool)
Declaration
[Obsolete("Use LoadAsync")]
public static SegmentationRules Load(Stream reader, string cultureOverride, IResourceDataAccessor accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
Stream | reader | |
string | cultureOverride | |
IResourceDataAccessor | accessor | |
bool | keepListReferences |
Returns
Type | Description |
---|---|
SegmentationRules |
Load(string, CultureCode, IResourceDataAccessor)
Declaration
[Obsolete("Use LoadAsync")]
public static SegmentationRules Load(string fileName, CultureCode cultureOverride, IResourceDataAccessor accessor)
Parameters
Type | Name | Description |
---|---|---|
string | fileName | |
CultureCode | cultureOverride | |
IResourceDataAccessor | accessor |
Returns
Type | Description |
---|---|
SegmentationRules |
Load(string, CultureCode, IResourceDataAccessor, bool)
Declaration
[Obsolete("Use LoadAsync")]
public static SegmentationRules Load(string fileName, CultureCode cultureOverride, IResourceDataAccessor accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
string | fileName | |
CultureCode | cultureOverride | |
IResourceDataAccessor | accessor | |
bool | keepListReferences |
Returns
Type | Description |
---|---|
SegmentationRules |
Load(string, string, IResourceDataAccessor)
Declaration
[Obsolete("Use LoadAsync")]
public static SegmentationRules Load(string fileName, string cultureOverride, IResourceDataAccessor accessor)
Parameters
Type | Name | Description |
---|---|---|
string | fileName | |
string | cultureOverride | |
IResourceDataAccessor | accessor |
Returns
Type | Description |
---|---|
SegmentationRules |
Load(string, string, IResourceDataAccessor, bool)
Declaration
[Obsolete("Use LoadAsync")]
public static SegmentationRules Load(string fileName, string cultureOverride, IResourceDataAccessor accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
string | fileName | |
string | cultureOverride | |
IResourceDataAccessor | accessor | |
bool | keepListReferences |
Returns
Type | Description |
---|---|
SegmentationRules |
LoadAsync(Stream, CultureCode, IResourceDataAccessorAsync)
Load segmentation rules from a stream. The resource data accessor is used to resolve any variable references which may be present in the rules.
Declaration
public static Task<SegmentationRules> LoadAsync(Stream reader, CultureCode cultureOverride, IResourceDataAccessorAsync accessor)
Parameters
Type | Name | Description |
---|---|---|
Stream | reader | The stream to load the rules from |
CultureCode | cultureOverride | If provided, the specified culture will be used to retrieve any missing language resources and will be put into the result object. |
IResourceDataAccessorAsync | accessor | The resource data accessor to use to resolve variable references |
Returns
Type | Description |
---|---|
TaskSegmentationRules | A fully initialized SegmentationRules object |
LoadAsync(Stream, CultureCode, IResourceDataAccessorAsync, bool)
Load segmentation rules from a stream. The resource data accessor is used to resolve any variable references which may be present in the rules.
Declaration
public static Task<SegmentationRules> LoadAsync(Stream reader, CultureCode cultureOverride, IResourceDataAccessorAsync accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
Stream | reader | The stream to load the rules from |
CultureCode | cultureOverride | If provided, the specified culture will be used to retrieve any missing language resources and will be put into the result object. |
IResourceDataAccessorAsync | accessor | The resource data accessor to use to resolve variable references |
bool | keepListReferences | If true, list references will not be resolved. The resulting rule set will not be functional and should not be used for segmentation, only for editing, display, or copying between resource containers. |
Returns
Type | Description |
---|---|
TaskSegmentationRules | A fully initialized SegmentationRules object |
LoadAsync(Stream, string, IResourceDataAccessorAsync)
Load segmentation rules from a stream. The resource data accessor is used to resolve any variable references which may be present in the rules.
Declaration
public static Task<SegmentationRules> LoadAsync(Stream reader, string cultureOverride, IResourceDataAccessorAsync accessor)
Parameters
Type | Name | Description |
---|---|---|
Stream | reader | The stream to load the rules from |
string | cultureOverride | If provided, the specified culture will be used to retrieve any missing language resources and will be put into the result object. |
IResourceDataAccessorAsync | accessor | The resource data accessor to use to resolve variable references |
Returns
Type | Description |
---|---|
TaskSegmentationRules | A fully initialized SegmentationRules object |
LoadAsync(Stream, string, IResourceDataAccessorAsync, bool)
Load segmentation rules from a stream. The resource data accessor is used to resolve any variable references which may be present in the rules.
Declaration
public static Task<SegmentationRules> LoadAsync(Stream reader, string cultureOverride, IResourceDataAccessorAsync accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
Stream | reader | The stream to load the rules from |
string | cultureOverride | If provided, the specified culture will be used to retrieve any missing language resources and will be put into the result object. |
IResourceDataAccessorAsync | accessor | The resource data accessor to use to resolve variable references |
bool | keepListReferences | If true, list references will not be resolved. The resulting rule set will not be functional and should not be used for segmentation, only for editing, display, or copying between resource containers. |
Returns
Type | Description |
---|---|
TaskSegmentationRules | A fully initialized SegmentationRules object |
LoadAsync(string, CultureCode, IResourceDataAccessorAsync)
Load segmentation rules from a file. The resource data accessor is used to resolve any variable references which may be present in the rules.
Declaration
public static Task<SegmentationRules> LoadAsync(string fileName, CultureCode cultureOverride, IResourceDataAccessorAsync accessor)
Parameters
Type | Name | Description |
---|---|---|
string | fileName | The name of the file to load the rules from |
CultureCode | cultureOverride | If provided, the specified culture will be used to retrieve any missing language resources and will be put into the result object. |
IResourceDataAccessorAsync | accessor | The resource data accessor to use to resolve variable references |
Returns
Type | Description |
---|---|
TaskSegmentationRules | A fully initialized SegmentationRules object |
LoadAsync(string, CultureCode, IResourceDataAccessorAsync, bool)
Load segmentation rules from a file. The resource data accessor is used to resolve any variable references which may be present in the rules.
Declaration
public static Task<SegmentationRules> LoadAsync(string fileName, CultureCode cultureOverride, IResourceDataAccessorAsync accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
string | fileName | The name of the file to load the rules from |
CultureCode | cultureOverride | If provided, the specified culture will be used to retrieve any missing language resources and will be put into the result object. |
IResourceDataAccessorAsync | accessor | The resource data accessor to use to resolve variable references |
bool | keepListReferences | If true, list references will not be resolved. The resulting rule set will not be functional and should not be used for segmentation, only for editing, display, or copying between resource containers. |
Returns
Type | Description |
---|---|
TaskSegmentationRules | A fully initialized SegmentationRules object |
LoadAsync(string, string, IResourceDataAccessorAsync)
Load segmentation rules from a file. The resource data accessor is used to resolve any variable references which may be present in the rules.
Declaration
public static Task<SegmentationRules> LoadAsync(string fileName, string cultureOverride, IResourceDataAccessorAsync accessor)
Parameters
Type | Name | Description |
---|---|---|
string | fileName | The name of the file to load the rules from |
string | cultureOverride | If provided, the specified culture will be used to retrieve any missing language resources and will be put into the result object. |
IResourceDataAccessorAsync | accessor | The resource data accessor to use to resolve variable references |
Returns
Type | Description |
---|---|
TaskSegmentationRules | A fully initialized SegmentationRules object |
LoadAsync(string, string, IResourceDataAccessorAsync, bool)
Load segmentation rules from a file. The resource data accessor is used to resolve any variable references which may be present in the rules.
Declaration
public static Task<SegmentationRules> LoadAsync(string fileName, string cultureOverride, IResourceDataAccessorAsync accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
string | fileName | The name of the file to load the rules from |
string | cultureOverride | If provided, the specified culture will be used to retrieve any missing language resources and will be put into the result object. |
IResourceDataAccessorAsync | accessor | The resource data accessor to use to resolve variable references |
bool | keepListReferences | If true, list references will not be resolved. The resulting rule set will not be functional and should not be used for segmentation, only for editing, display, or copying between resource containers. |
Returns
Type | Description |
---|---|
TaskSegmentationRules | A fully initialized SegmentationRules object |
LoadRaw(Stream, CultureCode, bool)
Equivalent to LoadAsync(Stream, CultureCode, IResourceDataAccessorAsync, bool) where keepListReferences is true and no accessor is provided, i.e. loads the rules from XML without resolving any references and/or removing any unresolved rules.
Declaration
public static SegmentationRules LoadRaw(Stream reader, CultureCode cultureOverride, bool useDataContractSerializer)
Parameters
Type | Name | Description |
---|---|---|
Stream | reader | |
CultureCode | cultureOverride | |
bool | useDataContractSerializer |
Returns
Type | Description |
---|---|
SegmentationRules |
LoadUsingDataContractSerializer(Stream, CultureCode, IResourceDataAccessor, bool)
Declaration
[Obsolete("Use LoadUsingDataContractSerializerAsync")]
public static SegmentationRules LoadUsingDataContractSerializer(Stream reader, CultureCode cultureOverride, IResourceDataAccessor accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
Stream | reader | |
CultureCode | cultureOverride | |
IResourceDataAccessor | accessor | |
bool | keepListReferences |
Returns
Type | Description |
---|---|
SegmentationRules |
LoadUsingDataContractSerializer(Stream, string, IResourceDataAccessor, bool)
Declaration
[Obsolete("Use LoadUsingDataContractSerializerAsync")]
public static SegmentationRules LoadUsingDataContractSerializer(Stream reader, string cultureOverride, IResourceDataAccessor accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
Stream | reader | |
string | cultureOverride | |
IResourceDataAccessor | accessor | |
bool | keepListReferences |
Returns
Type | Description |
---|---|
SegmentationRules |
LoadUsingDataContractSerializerAsync(Stream, CultureCode, IResourceDataAccessorAsync, bool)
Load segmentation rules from a stream. The resource data accessor is used to resolve any variable references which may be present in the rules. The data is assumed to be serialized by a DataContractSerializer.
Declaration
public static Task<SegmentationRules> LoadUsingDataContractSerializerAsync(Stream reader, CultureCode cultureOverride, IResourceDataAccessorAsync accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
Stream | reader | The stream to load the rules from |
CultureCode | cultureOverride | If provided, the specified culture will be used to retrieve any missing language resources and will be put into the result object. |
IResourceDataAccessorAsync | accessor | The resource data accessor to use to resolve variable references |
bool | keepListReferences | If true, list references will not be resolved. The resulting rule set will not be functional and should not be used for segmentation, only for editing, display, or copying between resource containers. |
Returns
Type | Description |
---|---|
TaskSegmentationRules | A fully initialized SegmentationRules object |
LoadUsingDataContractSerializerAsync(Stream, string, IResourceDataAccessorAsync, bool)
Load segmentation rules from a stream. The resource data accessor is used to resolve any variable references which may be present in the rules. The data is assumed to be serialized by a DataContractSerializer.
Declaration
public static Task<SegmentationRules> LoadUsingDataContractSerializerAsync(Stream reader, string cultureOverride, IResourceDataAccessorAsync accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
Stream | reader | The stream to load the rules from |
string | cultureOverride | If provided, the specified culture will be used to retrieve any missing language resources and will be put into the result object. |
IResourceDataAccessorAsync | accessor | The resource data accessor to use to resolve variable references |
bool | keepListReferences | If true, list references will not be resolved. The resulting rule set will not be functional and should not be used for segmentation, only for editing, display, or copying between resource containers. |
Returns
Type | Description |
---|---|
TaskSegmentationRules | A fully initialized SegmentationRules object |
Save(SegmentationRules, Stream)
Saves the rules to a stream.
Declaration
public static void Save(SegmentationRules rules, Stream writer)
Parameters
Type | Name | Description |
---|---|---|
SegmentationRules | rules | |
Stream | writer |
Save(Stream)
Saves a segmentation rules object to a stream.
Declaration
public void Save(Stream writer)
Parameters
Type | Name | Description |
---|---|---|
Stream | writer |
Save(string)
Saves a segmentation rules object to a file.
Declaration
public void Save(string fileName)
Parameters
Type | Name | Description |
---|---|---|
string | fileName |
SaveUsingDataContractSerializer(Stream)
Saves a segmentation rules object to a stream, using a DataContractSerializer.
Declaration
public void SaveUsingDataContractSerializer(Stream writer)
Parameters
Type | Name | Description |
---|---|---|
Stream | writer |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string representation of the object, for display purposes. |