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
otherSongFromInternetThe 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
Properties
ArtistC
Gets or sets the artist name in convention format.
public string ArtistC { get; set; }
Property Value
IdInDb
Gets or sets the database ID for this song.
public int IdInDb { get; set; }
Property Value
IsBreakInCalculateSimilarity
Gets or sets whether to break in debugger during similarity calculation (for debugging purposes).
public static bool IsBreakInCalculateSimilarity { get; set; }
Property Value
RemixC
Gets or sets the remix info in convention format.
public string RemixC { get; set; }
Property Value
TitleC
Gets or sets the title in convention format.
public string TitleC { get; set; }
Property Value
YtCode
Gets or sets the YouTube video code associated with this song.
public string? YtCode { get; set; }
Property Value
Methods
AlternateArtists()
Returns a list of alternate artist names extracted from featuring annotations in the remix.
public List<string> AlternateArtists()
Returns
Artist()
Returns the artist name as a space-joined string of artist words.
public string Artist()
Returns
ArtistInConvention()
Returns the artist name formatted in convention (each word capitalized).
public string ArtistInConvention()
Returns
CalculateSimilarity(SongFromInternet, bool)
Calculates the similarity score between this song and another SongFromInternet instance.
public float CalculateSimilarity(SongFromInternet other, bool isWithoutDiacritic)
Parameters
otherSongFromInternetThe other song to compare against.
isWithoutDiacriticboolIf true, comparison ignores diacritics.
Returns
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
sameCountintThe count of matching words.
differentCountintThe count of non-matching words (sum from both collections).
newWordsList<string>The new word list to compare.
originalWordsList<string>The original word list to compare against.
Returns
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
textstringThe song text to compare against.
Returns
CalculateSimilarityAll(SongFromInternet, bool, float)
Calculates overall similarity considering alternate artists from featuring annotations.
public float CalculateSimilarityAll(SongFromInternet other, bool isWithoutDiacritic, float minimal)
Parameters
otherSongFromInternetThe other song to compare against.
isWithoutDiacriticboolWhether to compare without diacritics.
minimalfloatThe minimum similarity threshold to stop searching.
Returns
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
firstobjectThe first object to compare (must be SongFromInternet).
secondobjectThe second object to compare (must be SongFromInternet).
Returns
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
firstListList<string>The first word list to compare.
secondListList<string>The second word list to compare.
sameCountintThe count of words found in both lists.
differentCountintThe 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
otherSongFromInternetThe other song to compare with.
Returns
Equals(object?)
Determines whether this instance equals the specified object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with.
Returns
GetHashCode()
Returns a hash code based on the string representation of this song.
public override int GetHashCode()
Returns
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
Returns
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
Returns
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
Returns
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
Returns
Remix()
Returns the remix as a space-joined string of remix words.
public string Remix()
Returns
RemixInConvention()
Returns the remix formatted in convention (each word capitalized).
public string RemixInConvention()
Returns
RemixOnlyContent()
Returns the remix content without featuring annotations.
public string RemixOnlyContent()
Returns
SetArtist(string)
Sets the artist name by splitting and normalizing the given text.
public void SetArtist(string text)
Parameters
textstringThe artist name text to parse.
Title()
Returns the title as a space-joined string of title words.
public string Title()
Returns
TitleAndRemixInConvention()
Returns the title and remix formatted in convention, with remix in square brackets.
public string TitleAndRemixInConvention()
Returns
TitleInConvention()
Returns the title formatted in convention (each word capitalized).
public string TitleInConvention()
Returns
ToConventionString()
Returns a convention-formatted string of artist, title, and optionally remix.
public string ToConventionString()
Returns
ToString()
Returns a string representation of artist, title, and optionally remix.
public override string ToString()