Speech2TextPrototype/Repositories/LookupTableRepository.cs
/// <summary>
/// Delete Tokens identified as known bigrams
/// </summary>
/// <param name="tokens">Array of single-word tokens from the python script</param>
/// <returns>Updated tokens array</returns>
Delete Tokens identified as known bigrams
Delete Tokens identified as known bigrams
private string[] DeleteKnownTokens(string[] tokens)
        {
            var listTokens = new List<string>(tokens);
            bool tokenDeleted = false;
            if (listMeasures.Any() || listDates.Any())
            {
                for (int i = listTokens.Count - 1; i >= 0; i--)
                {
                    foreach (string measure in listMeasureValues)
                    {
                        if (measure.Contains(listTokens[i], StringComparison.OrdinalIgnoreCase))
                        {
                            listTokens.RemoveAt(i);
                            tokenDeleted = true;
                            break;
                        }
                    }
                    if (!tokenDeleted) 
                    {
                        foreach (string date in listDateValues)
                        {
                            if (date.Contains(listTokens[i], StringComparison.OrdinalIgnoreCase))
                            {
                                listTokens.RemoveAt(i);
                                break;
                            }
                        }
                    }
                    tokenDeleted = false;
                }
                tokens = listTokens.ToArray();
            }
            return tokens;
        }
private string [ ] DeleteKnownTokens ( string [ ] tokens ) { var listTokens = new List < string > ( tokens ) ; bool tokenDeleted = false ; if ( listMeasures . Any ( ) || listDates . Any ( ) ) { for ( int i = listTokens . Count - 1 ; i >= 0 ; i -- ) { foreach ( string measure in listMeasureValues ) { if ( measure . Contains ( listTokens [ i ] , StringComparison . OrdinalIgnoreCase ) ) { listTokens . RemoveAt ( i ) ; tokenDeleted = true ; break ; } } if ( ! tokenDeleted ) { foreach ( string date in listDateValues ) { if ( date . Contains ( listTokens [ i ] , StringComparison . OrdinalIgnoreCase ) ) { listTokens . RemoveAt ( i ) ; break ; } } } tokenDeleted = false ; } tokens = listTokens . ToArray ( ) ; } return tokens ; }
Delete Tokens identified as known bigrams
Delete Tokens identified as known bigrams
// Delete measures - tokens // Delete dates - tokens // Hotfix: Crashed because listTokens[i] was already deleted
Updated tokens array
Updated tokens array
tokens
string[]
Array of single-word tokens from the python script
Array of single - word tokens from the python script