Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WITH
- current_paas AS (
- SELECT
- DISTINCT(paa_text)
- FROM `project.dataset.paa_text_table` -- edit this
- ),
- nozzle_paa_results AS (
- SELECT
- DISTINCT(related_phrase) AS paa_text
- FROM `nozzle.client_ranking_data.locomotive_locomotive` -- edit this
- WHERE result_type = 'PAA'
- AND related_phrase IS NOT NULL
- AND keyword_group = "brand" -- edit this
- AND related_phrase NOT IN (SELECT paa_text FROM current_paas)
- AND date(requested) > DATE_SUB(current_date(), INTERVAL 150 DAY)
- ORDER BY related_phrase
- LIMIT 50
- ),
- predictions AS (
- SELECT
- paa_text,
- ROUND(classifier[OFFSET(1)], 3) as score
- FROM ML.PREDICT(MODEL `project.bigquery_ml.sentiment`,(SELECT REGEXP_REPLACE(paa_text, '[^\\w\\s]+', '') AS text FROM nozzle_paa_results))
- JOIN (SELECT paa_text, REGEXP_REPLACE(paa_text, '[^\\w\\s]+', '') AS text FROM nozzle_paa_results) USING (text)
- ORDER BY score ASC
- )
- SELECT * FROM predictions;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement