Speech2TextPrototype/Repositories/LookupTableRepository.cs
/// <summary>
/// Search for single-word tokens as measures, aggregates, date or any other db-related filter
/// </summary>
/// <param name="tokens">Array of single-word tokens from the python script</param>
/// <returns>void - passing by erence</returns>
Search for single-word tokens as measures, aggregates, date or any other db-related filter
Search for single - word tokens as measures aggregates date or any other db - related filter
private void TokenLookup(string[] tokens)
        {
            int tokenIndex = 0;
            foreach (string token in tokens)
            {
                if (token == "between")
                {
                    isBetween = true;
                    continue;
                }
                if (token == "last" || token == "past")
                {
                    if (int.TryParse(tokens[tokenIndex + 1], out int number))
                    {
                        timeNum = (int.Parse(tokens[tokenIndex + 1]) - 1).ToString();
                        timeType = tokens[tokenIndex + 2];
                    }
                    else
                    {
                        timeType = tokens[tokenIndex + 1];
                    }
                    continue;
                }
                if (token == "top")
                {
                    isTop = true;
                    if (int.TryParse(tokens[tokenIndex + 1], out int number))
                    {
                        topNum = tokens[tokenIndex + 1];
                    }
                }
                for (int i = 0; i < aggregates.Length; i++)
                {
                    if (aggregates[i] == token || aggAlternatives[i] == token)
                    {
                        aggregateFunction = aggregates[i];
                        break;
                    }
                }
                LookupTable lookupValues = _context.lookupvalues.Where(row => row.Value == token).FirstOrDefault();
                if (lookupValues != null)
                {
                    if (lookupValues.Type == "Measure")
                    {
                        listMeasures.Add(lookupValues.WhereStmt);
                    }
                    else if (lookupValues.Type == "Date")
                    {
                        listDates.Add(lookupValues.WhereStmt);
                    }
                    else
                    {
                        string statement = lookupValues.WhereStmt + " = " + "'" + lookupValues.Value + "'";
                        listWhereStatements.Add(statement);
                    }
                }
                tokenIndex++;
            }
        }
private void TokenLookup ( string [ ] tokens ) { int tokenIndex = 0 ; foreach ( string token in tokens ) { if ( token == " " ) { isBetween = true ; continue ; } if ( token == " " || token == " " ) { if ( int . TryParse ( tokens [ tokenIndex + 1 ] , out int number ) ) { timeNum = ( int . Parse ( tokens [ tokenIndex + 1 ] ) - 1 ) . ToString ( ) ; timeType = tokens [ tokenIndex + 2 ] ; } else { timeType = tokens [ tokenIndex + 1 ] ; } continue ; } if ( token == " " ) { isTop = true ; if ( int . TryParse ( tokens [ tokenIndex + 1 ] , out int number ) ) { topNum = tokens [ tokenIndex + 1 ] ; } } for ( int i = 0 ; i < aggregates . Length ; i ++ ) { if ( aggregates [ i ] == token || aggAlternatives [ i ] == token ) { aggregateFunction = aggregates [ i ] ; break ; } } LookupTable lookupValues = _context . lookupvalues . Where ( row => row . Value == token ) . FirstOrDefault ( ) ; if ( lookupValues != null ) { if ( lookupValues . Type == " " ) { listMeasures . Add ( lookupValues . WhereStmt ) ; } else if ( lookupValues . Type == " " ) { listDates . Add ( lookupValues . WhereStmt ) ; } else { string statement = lookupValues . WhereStmt + " " + " " + lookupValues . Value + " " ; listWhereStatements . Add ( statement ) ; } } tokenIndex ++ ; } }
Search for single-word tokens as measures, aggregates, date or any other db-related filter
Search for single - word tokens as measures aggregates date or any other db - related filter
// Lookup Tokens // Find Between Keyword // Check for aggregates // Find Measurables // Find Dates // Find other "where" statements
passing by erence
passing by erence
tokens
string[]
Array of single-word tokens from the python script
Array of single - word tokens from the python script