In [2]:
from pyspark import SparkContext
sc = SparkContext()
In [20]:
from rake import *
from np_extractor import *
import json
rake = Rake('../data/MergedStopList.txt')
In [4]:
nas = sc.textFile("NAS_200.txt")
In [14]:
pre_kw = nas.map(lambda x: rake.run(x))
In [15]:
pre_kw.take(2)
Out[15]:
[[(u'500 gb hitachi deskstar drives', 16.0),
(u'stopped posting firmware updates', 14.5),
(u'hardware installation instructions', 9.0),
(u'hard drive removed', 9.0),
(u'assorted digital detritus', 9.0),
(u'playing hot potato', 9.0),
(u'linkstation quad defaults', 7.6),
(u'purchase buffalo products', 7.25),
(u'buffalo products', 4.25),
(u'greatly diminished', 4.0),
(u'media server', 4.0),
(u'web interface', 4.0),
(u'tech support', 4.0),
(u'usb devices', 4.0),
(u'started noticing', 4.0),
(u'copied directly', 4.0),
(u'rock-solid reliable', 4.0),
(u'perfectly sized', 4.0),
(u'real shame', 4.0),
(u'default position', 4.0),
(u'web browser', 4.0),
(u'stream videos', 3.5),
(u'unexplainable reason', 3.5),
(u'manually configure', 3.5),
(u'fit comfortably', 3.5),
(u'home server', 3.5),
(u'software firewall', 3.25),
(u'linkstation appears', 3.1),
(u'samsung television', 3.0),
(u'firmware', 2.5),
(u'buffalo', 1.75),
(u'linkstation', 1.6),
(u'fit', 1.5),
(u'home', 1.5),
(u'reason', 1.5),
(u'appears', 1.5),
(u'configure', 1.5),
(u'television', 1.5),
(u'videos', 1.5),
(u'samsung', 1.5),
(u'software', 1.25),
(u'raid 5', 1.0),
(u'fine', 1.0),
(u'issues', 1.0),
(u'source', 1.0),
(u'won', 1.0),
(u'return', 1.0),
(u'straightforward', 1.0),
(u'auto', 1.0),
(u'notes', 1.0),
(u'didn', 1.0),
(u'steps', 1.0),
(u'found', 1.0),
(u'wrote', 1.0),
(u'dealing', 1.0),
(u'blurred', 1.0),
(u'unexpectedly', 1.0),
(u'living', 1.0),
(u'network', 1.0),
(u'/', 1.0),
(u'label', 1.0),
(u'access', 1.0),
(u'unable', 1.0),
(u'issue', 1.0),
(u'correct', 1.0),
(u'bought', 1.0),
(u'power', 1.0),
(u'built-', 1.0),
(u'box', 1.0),
(u'experience', 1.0),
(u'compatible', 1.0),
(u'dissatisfaction', 1.0),
(u'satisfaction', 1.0),
(u'accumulated', 1.0),
(u'pc', 1.0),
(u'assumed', 1.0),
(u'noticed', 1.0),
(u'music', 1.0),
(u'buggy', 1.0),
(u'photos', 1.0),
(u'manual/auto', 1.0),
(u'bookshelf', 1.0),
(u'copy', 1.0),
(u'disabling', 1.0),
(u'buying', 1.0),
(u'past', 1.0),
(u'bother', 1.0),
(u'future', 1.0),
(u'install', 1.0),
(u'purchased', 1.0),
(u'mine', 1.0),
(u'file', 1.0),
(u'ready', 1.0),
(u'annoying', 1.0),
(u'-', 1.0),
(u'build', 1.0),
(u'copying', 1.0),
(u'product', 1.0),
(u'update', 1.0),
(u'rolling', 1.0),
(u'mood', 1.0),
(u'attempt', 1.0),
(u'filetypes', 1.0),
(u'switch', 1.0),
(u'time', 1.0)],
[(u'web-accessible management options', 9.0),
(u'expect lightning speed', 8.0),
(u'low-priced consumer nas', 8.0),
(u'product support involving', 8.0),
(u'self-supportive technically', 4.0),
(u'raid 0/1/5/10', 4.0),
(u'adding 8 tb', 4.0),
(u'flexible design', 4.0),
(u'hands functioning', 4.0),
(u'takes forever', 4.0),
(u'streaming videos', 4.0),
(u'storage size', 4.0),
(u'excellent concept', 4.0),
(u'design marred', 4.0),
(u'feature set', 4.0),
(u'completely hamstrung', 4.0),
(u'consumer-grade nas', 4.0),
(u'box shuts', 3.5),
(u'drives prone', 3.5),
(u'error message', 3.5),
(u'speed', 2.0),
(u'nas', 2.0),
(u'product', 2.0),
(u'drives', 1.5),
(u'box', 1.5),
(u'error', 1.5),
(u'cons', 1.0),
(u'home', 1.0),
(u'question', 1.0),
(u'cheap', 1.0),
(u'unexpectedly', 1.0),
(u'tons', 1.0),
(u'warning', 1.0),
(u'simply', 1.0),
(u'defects', 1.0),
(u'wasn', 1.0),
(u'corrupt', 1.0),
(u'impossible', 1.0),
(u'lengthy', 1.0),
(u'slow', 1.0),
(u'usb', 1.0),
(u'flat-', 1.0),
(u'delays', 1.0),
(u'firmware', 1.0),
(u'pros', 1.0),
(u'live', 1.0),
(u'/', 1.0),
(u're-flash', 1.0),
(u'stars', 1.0),
(u'cost-effective', 1.0),
(u'move', 1.0),
(u'buggy', 1.0),
(u'performance--', 1.0),
(u'host', 1.0),
(u'arrived', 1.0),
(u'copy', 1.0),
(u'weeks', 1.0),
(u'user-replaceable', 1.0),
(u'extendable', 1.0),
(u'edit', 1.0),
(u'identified', 1.0),
(u'summary', 1.0),
(u'stuff', 1.0),
(u'expecting', 1.0),
(u'con', 1.0),
(u'#1', 0)]]
In [24]:
rake_kw = pre_kw.map(lambda x: [(NPExtractor(pair[0]).extract(), pair[1]) for pair in x]).map(lambda x: [pair for pair in x if pair[0]])
In [38]:
rake_kw_= rake_kw.flatMap(lambda x: x)
In [42]:
rake_kw_.takeOrdered(25, key=lambda x: -x[1])
Out[42]:
[([u'administracion fuera mas completa'], 64.0),
([u'western digital sharespace 4tb 4-bay nas raid supports pcs'],
56.39523809523809),
([u'western digital 1tb 8mb cache total rubbish'], 49.0),
([u'livescribe pulse pen =', u'anoto pen products'], 48.5),
([u'qnap ts', u'pro ii turbo 2-bay nas'], 43.5),
([u'western digital sharespace 4tb 4-bay nas raid'], 38.39523809523809),
([u'western digital caviar'], 36.0),
([u'windows server', u'r2 hyperv test server'], 36.0),
([u'hp officejet pro l7780 network scanner'], 36.0),
([u'western digital', u'red nas disk'], 34.0),
([u'teras pero'], 33.5),
([u'seagate constellation es st32000644ns'], 33.333333333333336),
([u'cat6 cable', u'test machine'], 33.0),
([u'd-link dap', u'wireless dual band switch'], 32.0),
([u'western digital 2tb wd20ears green'], 32.0),
([u'deceptive space sizing-'], 31.0),
([u'seagate freeagent 2tb external', u'hard drive'], 29.71666666666667),
([u'standalone raid storage solution'], 29.25),
([u'verbatim mediashare =', u'axentra hipserv technology'],
28.442857142857143),
([u'buffalo linkstation quad 6tb nas'], 25.0),
([u'green 2t byte wd'], 25.0),
([u'external usb'], 25.0),
([u'usb hub coud'], 25.0),
([u'brite-view bv-5005hd streamer boxbrite-view bv-5005hd'], 25.0),
([u'ups smart power management'], 25.0)]
In [ ]:
Content source: XiaowenLin/cs598rk
Similar notebooks: