Pip-Services-Commons-Dotnet
Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
PipServices3.Commons.Data.TagsProcessor Class Reference

Helper class to extract and process search tags from objects. The search tags can be kept individually or embedded as hash tags inside text like "This text has #hash_tag that can be used for search." More...

Static Public Member Functions

static string NormalizeTag (string tag)
 Normalizes a tag by replacing special symbols like '_' and '#' with spaces. When tags are normalized then can be presented to user in similar shape and form. More...
 
static string CompressTag (string tag)
 Compress a tag by removing special symbols like spaces, '_' and '#' and converting the tag to lower case. When tags are compressed they can be matched in search queries. More...
 
static bool EqualTags (string tag1, string tag2)
 Compares two tags using their compressed form. More...
 
static string [] NormalizeTags (string[] tags)
 Normalizes a list of tags. More...
 
static string [] NormalizeTagList (string tagList)
 Normalizes a comma-separated list of tags. More...
 
static List< T > Splice< T > (this List< T > source, int index, int count)
 
static string [] CompressTags (string[] tags)
 Compresses a list of tags. More...
 
static string [] CompressTagList (string tagList)
 Compresses a comma-separated list of tags. More...
 
static string [] ExtractHashTags (string text)
 Extracts hash tags from a text. More...
 
static string [] ExtractHashTagsFromValue (dynamic obj, params string[] searchFields)
 Extracts hash tags from selected fields in an object. More...
 

Static Private Member Functions

static string ExtractString (dynamic field)
 

Private Attributes

const string NORMALIZE_REGEX = "(_|#)+"
 
const string COMPRESS_REGEX = "( |_|#)+"
 
const string SPLIT_REGEX = "(,|;)+"
 
const string HASHTAG_REGEX = "#\\w+"
 

Detailed Description

Helper class to extract and process search tags from objects. The search tags can be kept individually or embedded as hash tags inside text like "This text has #hash_tag that can be used for search."

Member Function Documentation

◆ CompressTag()

static string PipServices3.Commons.Data.TagsProcessor.CompressTag ( string  tag)
static

Compress a tag by removing special symbols like spaces, '_' and '#' and converting the tag to lower case. When tags are compressed they can be matched in search queries.

Parameters
tagthe tag to compress.
Returns
a compressed tag.

◆ CompressTagList()

static string [] PipServices3.Commons.Data.TagsProcessor.CompressTagList ( string  tagList)
static

Compresses a comma-separated list of tags.

Parameters
tagLista comma-separated list of tags to compress.
Returns
a list with compressed tags.

◆ CompressTags()

static string [] PipServices3.Commons.Data.TagsProcessor.CompressTags ( string []  tags)
static

Compresses a list of tags.

Parameters
tagsthe tags to compress.
Returns
a list with normalized tags.

◆ EqualTags()

static bool PipServices3.Commons.Data.TagsProcessor.EqualTags ( string  tag1,
string  tag2 
)
static

Compares two tags using their compressed form.

Parameters
tag1the first tag.
tag2the second tag.
Returns
true if the tags are equal and false otherwise.

◆ ExtractHashTags()

static string [] PipServices3.Commons.Data.TagsProcessor.ExtractHashTags ( string  text)
static

Extracts hash tags from a text.

Parameters
texta text that contains hash tags
Returns
a list with extracted and compressed tags.

◆ ExtractHashTagsFromValue()

static string [] PipServices3.Commons.Data.TagsProcessor.ExtractHashTagsFromValue ( dynamic  obj,
params string []  searchFields 
)
static

Extracts hash tags from selected fields in an object.

Parameters
objan object which contains hash tags.
searchFieldsa list of fields in the objects where to extract tags
Returns
a list of extracted and compressed tags.

◆ NormalizeTag()

static string PipServices3.Commons.Data.TagsProcessor.NormalizeTag ( string  tag)
static

Normalizes a tag by replacing special symbols like '_' and '#' with spaces. When tags are normalized then can be presented to user in similar shape and form.

Parameters
tagthe tag to normalize.
Returns
a normalized tag.

◆ NormalizeTagList()

static string [] PipServices3.Commons.Data.TagsProcessor.NormalizeTagList ( string  tagList)
static

Normalizes a comma-separated list of tags.

Parameters
tagLista comma-separated list of tags to normalize.
Returns
a list with normalized tags.

◆ NormalizeTags()

static string [] PipServices3.Commons.Data.TagsProcessor.NormalizeTags ( string []  tags)
static

Normalizes a list of tags.

Parameters
tagsthe tags to normalize.
Returns
a list with normalized tags.

The documentation for this class was generated from the following file: