Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. -- Husk at lave databasen "fakenews_scrape" først og køre jupyter notebooken før du kører dette.
  2. -- Åben postgres og sørg for at connecte til fakenewscorpus databasen først. Kør så denne query.
  3. create extension if not exists pg_trgm;
  4. create extension if not exists dblink;
  5.  
  6. drop VIEW IF EXISTS scraped cascade;
  7. SET pg_trgm.similarity_threshold = 0.1;
  8. CREATE VIEW scraped AS
  9. select * FROM dblink('dbname=fakenews_scrape user=postgres password=postgres','select article_id, title from article') AS our_scraped(article_id integer, title character varying(512));
  10.  
  11. drop view if exists similarity_table;
  12. create view similarity_table as
  13. select
  14. article.article_id as "Corpus article_id",
  15. article.title as "Corpus title",
  16. scraped.article_id as "Scraped aricle_id",
  17. scraped.title as "Scraped title",
  18. word_similarity(scraped.title, article.title) as sim_word
  19. from article,
  20. where article.title is not null and scraped.title is not null
  21. ;
  22.  
  23. select * from similarity_table
  24. order by sim_word desc
  25. fetch first 10 rows only;
  26.  
  27.  
  28. ARTIKEL 1 (The Sea Level Around Florida is Rising Six Times Faster Than Average)
  29.  
  30. -- find al information om artiklen i FakeNewsCorpus (kør i fakenews_100k database)
  31. select * from article inner join typ on article.type_id = typ.type_id
  32. where article_id = 33425
  33.  
  34. -- find al information om artiklen i fakenews_scrape (kør i fakenews_scrape)
  35. select * from article
  36. inner join has_types on article.article_id = has_types.article_id
  37. inner join typ on has_types.type_id = typ.type_id
  38. where article.article_id = 34
  39.  
  40. ARTIKEL 2 (Only A Century Away From An "Uninhabitable Earth?")
  41. -- find al information om artiklen i FakeNewsCorpus (kør i fakenews_100k database)
  42. select * from article inner join typ on article.type_id = typ.type_id
  43. where article_id = 84114
  44.  
  45. -- find al information om artiklen i fakenews_scrape (kør i fakenews_scrape)
  46. select * from article
  47. inner join has_types on article.article_id = has_types.article_id
  48. inner join typ on has_types.type_id = typ.type_id
  49. where article.article_id = 50
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement