Class SegmentationRules
A collection of segmentation rules.
Inheritance
Implements
Inherited Members
Namespace: Sdl.LanguagePlatform.Core.Segmentation
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
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 |
---|---|---|
Sdl.Core.Globalization.CultureCode | culture | The culture for which to apply this segmentation rule set. This culture is also used to retrieve additional language resources, if required. |
System.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 |
---|---|---|
System.String | cultureName | The culture for which to apply this segmentation rule set. This culture is also used to retrieve additional language resources, if required. |
System.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 |
---|---|
System.Int32 |
Culture
Gets the culture for which to apply this segmentation rule set.
Declaration
[Obsolete("Use CultureName")]
public CultureInfo Culture { get; }
Property Value
Type | Description |
---|---|
System.Globalization.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
public string CultureName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Description
Gets or sets the description of this rule set.
Declaration
public LocalizedString Description { get; set; }
Property Value
Type | Description |
---|---|
LocalizedString |
Item[Int32]
Gets the segmentation rule at the specified zero-based position.
Declaration
public SegmentationRule this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | 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 |
---|---|
System.Boolean |
Rules
Gets or sets the rules for this rule set.
Declaration
public List<SegmentationRule> Rules { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<SegmentationRule> |
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 |
---|---|---|
System.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 |
---|---|
System.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 |
---|---|
System.Collections.Generic.IEnumerator<SegmentationRule> | An enumerator |
Load(Stream, CultureCode, IResourceDataAccessor)
Declaration
[Obsolete("Use LoadAsync")]
public static SegmentationRules Load(Stream reader, CultureCode cultureOverride, IResourceDataAccessor accessor)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | reader | |
Sdl.Core.Globalization.CultureCode | cultureOverride | |
IResourceDataAccessor | accessor |
Returns
Type | Description |
---|---|
SegmentationRules |
Load(Stream, CultureCode, IResourceDataAccessor, Boolean)
Declaration
[Obsolete("Use LoadAsync")]
public static SegmentationRules Load(Stream reader, CultureCode cultureOverride, IResourceDataAccessor accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | reader | |
Sdl.Core.Globalization.CultureCode | cultureOverride | |
IResourceDataAccessor | accessor | |
System.Boolean | 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 |
---|---|---|
System.IO.Stream | reader | |
System.String | cultureOverride | |
IResourceDataAccessor | accessor |
Returns
Type | Description |
---|---|
SegmentationRules |
Load(Stream, String, IResourceDataAccessor, Boolean)
Declaration
[Obsolete("Use LoadAsync")]
public static SegmentationRules Load(Stream reader, string cultureOverride, IResourceDataAccessor accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | reader | |
System.String | cultureOverride | |
IResourceDataAccessor | accessor | |
System.Boolean | 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 |
---|---|---|
System.String | fileName | |
Sdl.Core.Globalization.CultureCode | cultureOverride | |
IResourceDataAccessor | accessor |
Returns
Type | Description |
---|---|
SegmentationRules |
Load(String, CultureCode, IResourceDataAccessor, Boolean)
Declaration
[Obsolete("Use LoadAsync")]
public static SegmentationRules Load(string fileName, CultureCode cultureOverride, IResourceDataAccessor accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | |
Sdl.Core.Globalization.CultureCode | cultureOverride | |
IResourceDataAccessor | accessor | |
System.Boolean | 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 |
---|---|---|
System.String | fileName | |
System.String | cultureOverride | |
IResourceDataAccessor | accessor |
Returns
Type | Description |
---|---|
SegmentationRules |
Load(String, String, IResourceDataAccessor, Boolean)
Declaration
[Obsolete("Use LoadAsync")]
public static SegmentationRules Load(string fileName, string cultureOverride, IResourceDataAccessor accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | |
System.String | cultureOverride | |
IResourceDataAccessor | accessor | |
System.Boolean | 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 |
---|---|---|
System.IO.Stream | reader | The stream to load the rules from |
Sdl.Core.Globalization.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 |
---|---|
System.Threading.Tasks.Task<SegmentationRules> | A fully initialized SegmentationRules object |
LoadAsync(Stream, CultureCode, IResourceDataAccessorAsync, Boolean)
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 |
---|---|---|
System.IO.Stream | reader | The stream to load the rules from |
Sdl.Core.Globalization.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 |
System.Boolean | 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 |
---|---|
System.Threading.Tasks.Task<SegmentationRules> | 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 |
---|---|---|
System.IO.Stream | reader | The stream to load the rules from |
System.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 |
---|---|
System.Threading.Tasks.Task<SegmentationRules> | A fully initialized SegmentationRules object |
LoadAsync(Stream, String, IResourceDataAccessorAsync, Boolean)
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 |
---|---|---|
System.IO.Stream | reader | The stream to load the rules from |
System.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 |
System.Boolean | 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 |
---|---|
System.Threading.Tasks.Task<SegmentationRules> | 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 |
---|---|---|
System.String | fileName | The name of the file to load the rules from |
Sdl.Core.Globalization.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 |
---|---|
System.Threading.Tasks.Task<SegmentationRules> | A fully initialized SegmentationRules object |
LoadAsync(String, CultureCode, IResourceDataAccessorAsync, Boolean)
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 |
---|---|---|
System.String | fileName | The name of the file to load the rules from |
Sdl.Core.Globalization.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 |
System.Boolean | 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 |
---|---|
System.Threading.Tasks.Task<SegmentationRules> | 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 |
---|---|---|
System.String | fileName | The name of the file to load the rules from |
System.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 |
---|---|
System.Threading.Tasks.Task<SegmentationRules> | A fully initialized SegmentationRules object |
LoadAsync(String, String, IResourceDataAccessorAsync, Boolean)
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 |
---|---|---|
System.String | fileName | The name of the file to load the rules from |
System.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 |
System.Boolean | 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 |
---|---|
System.Threading.Tasks.Task<SegmentationRules> | A fully initialized SegmentationRules object |
LoadRaw(Stream, CultureCode, Boolean)
Equivalent to LoadAsync(Stream, CultureCode, IResourceDataAccessorAsync, Boolean) 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 |
---|---|---|
System.IO.Stream | reader | |
Sdl.Core.Globalization.CultureCode | cultureOverride | |
System.Boolean | useDataContractSerializer |
Returns
Type | Description |
---|---|
SegmentationRules |
LoadUsingDataContractSerializer(Stream, CultureCode, IResourceDataAccessor, Boolean)
Declaration
[Obsolete("Use LoadUsingDataContractSerializerAsync")]
public static SegmentationRules LoadUsingDataContractSerializer(Stream reader, CultureCode cultureOverride, IResourceDataAccessor accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | reader | |
Sdl.Core.Globalization.CultureCode | cultureOverride | |
IResourceDataAccessor | accessor | |
System.Boolean | keepListReferences |
Returns
Type | Description |
---|---|
SegmentationRules |
LoadUsingDataContractSerializer(Stream, String, IResourceDataAccessor, Boolean)
Declaration
[Obsolete("Use LoadUsingDataContractSerializerAsync")]
public static SegmentationRules LoadUsingDataContractSerializer(Stream reader, string cultureOverride, IResourceDataAccessor accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | reader | |
System.String | cultureOverride | |
IResourceDataAccessor | accessor | |
System.Boolean | keepListReferences |
Returns
Type | Description |
---|---|
SegmentationRules |
LoadUsingDataContractSerializerAsync(Stream, CultureCode, IResourceDataAccessorAsync, Boolean)
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 System.Runtime.Serialization.DataContractSerializer.
Declaration
public static Task<SegmentationRules> LoadUsingDataContractSerializerAsync(Stream reader, CultureCode cultureOverride, IResourceDataAccessorAsync accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | reader | The stream to load the rules from |
Sdl.Core.Globalization.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 |
System.Boolean | 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 |
---|---|
System.Threading.Tasks.Task<SegmentationRules> | A fully initialized SegmentationRules object |
LoadUsingDataContractSerializerAsync(Stream, String, IResourceDataAccessorAsync, Boolean)
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 System.Runtime.Serialization.DataContractSerializer.
Declaration
public static Task<SegmentationRules> LoadUsingDataContractSerializerAsync(Stream reader, string cultureOverride, IResourceDataAccessorAsync accessor, bool keepListReferences)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | reader | The stream to load the rules from |
System.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 |
System.Boolean | 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 |
---|---|
System.Threading.Tasks.Task<SegmentationRules> | 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 | |
System.IO.Stream | writer |
Save(Stream)
Saves a segmentation rules object to a stream.
Declaration
public void Save(Stream writer)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | writer |
Save(String)
Saves a segmentation rules object to a file.
Declaration
public void Save(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName |
SaveUsingDataContractSerializer(Stream)
Saves a segmentation rules object to a stream, using a System.Runtime.Serialization.DataContractSerializer.
Declaration
public void SaveUsingDataContractSerializer(Stream writer)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | writer |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string representation of the object, for display purposes. |