Table of Contents

Class SongFromInternet

Namespace
SunamoShared.Entity
Assembly
SunamoShared.dll

Represents a song parsed from the internet, with artist, title, and remix information. Supports similarity comparison between songs.

public class SongFromInternet : IEquatable<SongFromInternet>
Inheritance
SongFromInternet
Implements
Inherited Members
Extension Methods

Constructors

SongFromInternet()

Initializes a new empty instance of the SongFromInternet class.

public SongFromInternet()

SongFromInternet(SongFromInternet)

Initializes a new instance by copying data from another SongFromInternet instance.

public SongFromInternet(SongFromInternet other)

Parameters

other SongFromInternet

The source instance to copy from.

SongFromInternet(string, string?)

Initializes a new instance by parsing a song string into artist, title, and remix.

public SongFromInternet(string song, string? ytCode = null)

Parameters

song string

The formatted song string to parse.

ytCode string

Optional YouTube video code.

Properties

ArtistC

Gets or sets the artist name in convention format.

public string ArtistC { get; set; }

Property Value

string

IdInDb

Gets or sets the database ID for this song.

public int IdInDb { get; set; }

Property Value

int

IsBreakInCalculateSimilarity

Gets or sets whether to break in debugger during similarity calculation (for debugging purposes).

public static bool IsBreakInCalculateSimilarity { get; set; }

Property Value

bool

RemixC

Gets or sets the remix info in convention format.

public string RemixC { get; set; }

Property Value

string

TitleC

Gets or sets the title in convention format.

public string TitleC { get; set; }

Property Value

string

YtCode

Gets or sets the YouTube video code associated with this song.

public string? YtCode { get; set; }

Property Value

string

Methods

AlternateArtists()

Returns a list of alternate artist names extracted from featuring annotations in the remix.

public List<string> AlternateArtists()

Returns

List<string>

Artist()

Returns the artist name as a space-joined string of artist words.

public string Artist()

Returns

string

ArtistInConvention()

Returns the artist name formatted in convention (each word capitalized).

public string ArtistInConvention()

Returns

string

CalculateSimilarity(SongFromInternet, bool)

Calculates the similarity score between this song and another SongFromInternet instance.

public float CalculateSimilarity(SongFromInternet other, bool isWithoutDiacritic)

Parameters

other SongFromInternet

The other song to compare against.

isWithoutDiacritic bool

If true, comparison ignores diacritics.

Returns

float

CalculateSimilarity(int, int, List<string>, List<string>)

Calculates similarity score based on same/different word counts and two word lists. Returns a value between 0 and 1 where 1 means identical.

public static float CalculateSimilarity(int sameCount, int differentCount, List<string> newWords, List<string> originalWords)

Parameters

sameCount int

The count of matching words.

differentCount int

The count of non-matching words (sum from both collections).

newWords List<string>

The new word list to compare.

originalWords List<string>

The original word list to compare against.

Returns

float

CalculateSimilarity(string)

Calculates the similarity score between this song and a song parsed from the given text. Comparison is diacritic-sensitive.

public float CalculateSimilarity(string text)

Parameters

text string

The song text to compare against.

Returns

float

CalculateSimilarityAll(SongFromInternet, bool, float)

Calculates overall similarity considering alternate artists from featuring annotations.

public float CalculateSimilarityAll(SongFromInternet other, bool isWithoutDiacritic, float minimal)

Parameters

other SongFromInternet

The other song to compare against.

isWithoutDiacritic bool

Whether to compare without diacritics.

minimal float

The minimum similarity threshold to stop searching.

Returns

float

Compare(object, object)

Compares two SongFromInternet instances by their similarity score. Returns 1 if similar (above threshold), 0 otherwise.

public int Compare(object first, object second)

Parameters

first object

The first object to compare (must be SongFromInternet).

second object

The second object to compare (must be SongFromInternet).

Returns

int

CountSameAndDifferent(List<string>, List<string>, out int, out int)

Counts matching and non-matching words between two lists. Matching words are removed from both working copies; the remaining counts are summed as different.

public static void CountSameAndDifferent(List<string> firstList, List<string> secondList, out int sameCount, out int differentCount)

Parameters

firstList List<string>

The first word list to compare.

secondList List<string>

The second word list to compare.

sameCount int

The count of words found in both lists.

differentCount int

The sum of remaining words in both lists after removing matches.

Equals(SongFromInternet?)

Determines whether this instance equals another SongFromInternet.

public bool Equals(SongFromInternet? other)

Parameters

other SongFromInternet

The other song to compare with.

Returns

bool

Equals(object?)

Determines whether this instance equals the specified object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with.

Returns

bool

GetHashCode()

Returns a hash code based on the string representation of this song.

public override int GetHashCode()

Returns

int

Init(string, string, string)

Initializes the song data from separate artist, title, and remix strings.

public SongFromInternet Init(string artist, string title, string remix)

Parameters

artist string

The artist name.

title string

The song title.

remix string

The remix information.

Returns

SongFromInternet

Init(Tuple<string, string, string>)

Initializes the song data from a tuple of artist, title, and remix strings.

public SongFromInternet Init(Tuple<string, string, string> tuple)

Parameters

tuple Tuple<string, string, string>

A tuple containing artist, title, and remix.

Returns

SongFromInternet

IsSimilar(List<string>, string)

Determines whether a title word list is similar to a given name. All strings in both collections must be lowercase for correct comparison.

public static bool IsSimilar(List<string> titleArray, string name)

Parameters

titleArray List<string>

The title words to compare.

name string

The name to compare against.

Returns

bool

IsSimilar(string[], string)

Determines whether a title array is similar to a given name. All strings in both collections must be lowercase for correct comparison.

public static bool IsSimilar(string[] titleArray, string name)

Parameters

titleArray string[]

The title words array to compare.

name string

The name to compare against.

Returns

bool

Remix()

Returns the remix as a space-joined string of remix words.

public string Remix()

Returns

string

RemixInConvention()

Returns the remix formatted in convention (each word capitalized).

public string RemixInConvention()

Returns

string

RemixOnlyContent()

Returns the remix content without featuring annotations.

public string RemixOnlyContent()

Returns

string

SetArtist(string)

Sets the artist name by splitting and normalizing the given text.

public void SetArtist(string text)

Parameters

text string

The artist name text to parse.

Title()

Returns the title as a space-joined string of title words.

public string Title()

Returns

string

TitleAndRemixInConvention()

Returns the title and remix formatted in convention, with remix in square brackets.

public string TitleAndRemixInConvention()

Returns

string

TitleInConvention()

Returns the title formatted in convention (each word capitalized).

public string TitleInConvention()

Returns

string

ToConventionString()

Returns a convention-formatted string of artist, title, and optionally remix.

public string ToConventionString()

Returns

string

ToString()

Returns a string representation of artist, title, and optionally remix.

public override string ToString()

Returns

string