def wc():
    import matplotlib as mpl
    import matplotlib.pyplot as plt1
    from subprocess import check_output
    from wordcloud import WordCloud, STOPWORDS

    #mpl.rcParams['figure.figsize']=(8.0,6.0)    #(6.0,4.0)
    mpl.rcParams['font.size']=12                #10
    mpl.rcParams['savefig.dpi']=100             #72
    mpl.rcParams['figure.subplot.bottom']=.1

    stopwords = set(STOPWORDS)
    data = Asin.getWordCloud()
    # print(data)

    wordcloud = WordCloud(    collocations=False,
                              background_color='white',
                              height=300, width=400,
                              relative_scaling = 0.5,
                              random_state=2,
                              stopwords=stopwords,
                              max_words=200,
                              max_font_size=75,
                              min_font_size=5
                             ).generate(data)

    # print(wordcloud)
    plt1.cla()
    fig = plt1.figure()
    plt1.imshow(wordcloud)
    plt1.axis('off')
    #plt.show()
    asin=Asin.getAsinValue()
    fig.savefig('images/'+asin+'_wc.png', bbox_inches='tight')
    plt1.close()
    def retranslateUi(self, CompareWindow):
        _translate = QtCore.QCoreApplication.translate
        CompareWindow.setWindowTitle(
            _translate("CompareWindow", "Compare Products"))
        self.label.setText(_translate("CompareWindow", "Select Product"))

        #our stuff
        asin = Asin.getAsinValue()
        name = Asin.getPhoneName(asin)
        self.product1Label.setText(name)

        if (name != 'Moto G5'):
            self.comboBox.addItem("Moto G5")
        if (name != 'Moto G Play'):
            self.comboBox.addItem("Moto G Play")
        if (name != 'Moto Z'):
            self.comboBox.addItem("Moto Z")
        if (name != 'Moto Z Play'):
            self.comboBox.addItem("Moto Z Play")
        if (name != 'Samsung Galaxy S8'):
            self.comboBox.addItem("Samsung Galaxy S8")
        if (name != 'Samsung Galaxy S8+'):
            self.comboBox.addItem("Samsung Galaxy S8+")
        if (name != 'Samsung Galaxy S9'):
            self.comboBox.addItem("Samsung Galaxy S9")
        if (name != 'Samsung S7 Edge'):
            self.comboBox.addItem("Samsung S7 Edge")

        self.showscores(asin)
        self.compareProduct()
        self.comboBox.currentIndexChanged.connect(self.compareProduct)
 def search(self):
     asinValue = Asin.getAsinValue()
     feature = str(self.featurecomboBox.currentText())
     self.positiveList.clear()
     self.negativeList.clear()
     if (feature == 'All'):
         self.show(asinValue)
     elif (feature == 'Camera'):
         search_for = ['camera', 'picture', 'photo']
         self.implicitsearch(asinValue, search_for)
     elif (feature == 'Battery'):
         search_for = ['battery', 'drain', 'discharge']
         self.implicitsearch(asinValue, search_for)
     elif (feature == 'Screen'):
         search_for = ['screen', 'display', 'touch', 'glass']
         self.implicitsearch(asinValue, search_for)
     elif (feature == 'Processor'):
         search_for = ['processor', 'speed', 'processing speed']
         self.implicitsearch(asinValue, search_for)
     elif (feature == 'Memory'):
         search_for = ['memory', ' ram ', ' rom ', 'storage', 'sd card']
         self.implicitsearch(asinValue, search_for)
     elif (feature == 'Size'):
         search_for = ['size', 'dimensiion', 'weight']
         self.implicitsearch(asinValue, search_for)
     elif (feature == 'Audio'):
         search_for = ['audio', 'sound', 'music', 'noise']
         self.implicitsearch(asinValue, search_for)
 def showscores(self, asin):
     key_rating_d = algo.noun_dict()
     cost = Asin.getPrice(asin)
     self.product1Text.addItem("MRP\t\t : \t" + cost)
     for keys, values in key_rating_d.items():
         for i in values:
             s = i.split('/')
         value = keys + "\t\t : \t" + str(s[0]).rstrip(" ")
         self.product1Text.addItem(value)
    def retranslateUi(self, Dashboard):
        _translate = QtCore.QCoreApplication.translate
        Dashboard.setWindowTitle(_translate("Dashboard", "Dashboard"))
        self.showReviewButton.setText(_translate("Dashboard", "SHOW REVIEWS"))
        self.showScoreButton.setText(_translate("Dashboard", "SHOW SCORES"))
        self.compareButton.setText(_translate("Dashboard", "COMPARE"))
        self.analysisButton.setText(_translate("Dashboard", "SHOW ANALYSIS"))

        # our stuff
        asins=["B01LW9P0H4","B01M7O431L","B06Y15G61T","B06Y137TLR","B071WDBTW1","B079JSZ1Z2","B079SGQNPN","B079YM4RXS"]
        asin = Asin.getAsinValue()
        algo.summaryFunction(asin)
        name = Asin.getPhoneName(asin)
        print(name)
        if asin not in asins:
           image.img(asin)
        self.setContent(asin,name)

        self.showReviewButton.clicked.connect(self.showReview)
        self.showScoreButton.clicked.connect(self.showScore)
        self.compareButton.clicked.connect(self.showCompare)
        self.analysisButton.clicked.connect(self.showAnalysis)
    def retranslateUi(self, ScoreWindow):
        _translate = QtCore.QCoreApplication.translate
        ScoreWindow.setWindowTitle(
            _translate("ScoreWindow", "Feature Based Scores"))
        self.label.setText(_translate("ScoreWindow", "Feature-Score"))
        self.label_2.setText(_translate("ScoreWindow", "Service-Score"))
        self.label_3.setText(
            _translate("ScoreWindow", "Select specific feature"))

        #our stuff
        asin = Asin.getAsinValue()
        self.showscores(asin)
        self.showServiceScore(asin)
        self.featureCombo.currentIndexChanged.connect(self.showValue)
    def retranslateUi(self, ReviewsWindow):
        _translate = QtCore.QCoreApplication.translate
        ReviewsWindow.setWindowTitle(_translate("ReviewsWindow", "Reviews"))
        self.featureSelectLabel.setText(
            _translate("ReviewsWindow", "Select Feature"))
        self.label.setText(_translate("ReviewsWindow", "Positive Reviews"))
        self.label_2.setText(_translate("ReviewsWindow", "Negative Reviews"))

        #our stuff
        self.featurecomboBox.addItem("All")
        self.featurecomboBox.addItem("Camera")
        self.featurecomboBox.addItem("Battery")
        self.featurecomboBox.addItem("Screen")
        self.featurecomboBox.addItem("Memory")
        self.featurecomboBox.addItem("Size")
        self.featurecomboBox.addItem("Audio")
        self.featurecomboBox.addItem("Processor")
        asin = Asin.getAsinValue()
        Run.pos_neg(asin)
        self.show(asin)
        self.featurecomboBox.currentIndexChanged.connect(self.search)
 def onClick(self):
     if (self.BrandRadio.isChecked() == True):
         product = str(self.ProductCombo.currentText())
         textboxValue = Asin.getAsinCompare(product)
         Run.crawl(textboxValue)
         Run.convert(textboxValue)
         self.setAsin(textboxValue)
         self.openDashboard()
     elif (self.AsinRadio.isChecked() == True):
         textboxValue = self.Asintext.text()
         if (len(textboxValue) != 10):
             msgbox = QtWidgets.QMessageBox()
             msgbox.setGeometry(550, 340, 600, 450)
             msgbox.setIcon(QtWidgets.QMessageBox.Warning)
             msgbox.setText("Please enter valid ASIN!")
             msgbox.setWindowTitle("Error")
             msgbox.setEscapeButton(QtWidgets.QMessageBox.Close)
             msgbox.exec_()
             self.Asintext.clear()
         else:
             Run.crawl(textboxValue)
             Run.convert(textboxValue)
             self.setAsin(textboxValue)
             self.openDashboard()
Esempio n. 9
0
def asin(x):
    return Asin(float(x))
    def retranslateUi(self, AnalysisWindow):
        _translate = QtCore.QCoreApplication.translate
        AnalysisWindow.setWindowTitle(_translate("AnalysisWindow", "Analysis"))
        self.label.setText(_translate("AnalysisWindow", "Feature Relevancy"))
        self.label_2.setText(_translate("AnalysisWindow", "Accuracy of relevant features extracted"))
        self.label_3.setText(_translate("AnalysisWindow", "Score Comparision"))
        self.label_4.setText(_translate("AnalysisWindow", "Our Rating"))
        self.label_5.setText(_translate("AnalysisWindow", "Amazon Rating"))
        self.label_6.setText(_translate("AnalysisWindow", "Word Cloud"))

        #our stuff
        asin=Asin.getAsinValue()
        WordCloud.wc()
        self.label_7.setStyleSheet("#label_7{border-image:url(images/"+asin+"_wc.png)}")


        from collections import defaultdict
        key_rating_d = algo.noun_dict()
        objects = key_rating_d.keys()
        performance = []

        for l in key_rating_d.values():
            for i in l:
                # print(i)
                s = i.split('/')
                performance.append(float(s[0]))
        # print(performance)
        sum=0

        for pi in performance:
            sum = sum + pi
        avg = sum/len(performance)
        avg/=2
        # print("old avg:")
        # print(avg)
        phone_word_rating = Asin.getPhone()
        # print("phone:" + str(phone_word_rating))
        new_avg = (avg + phone_word_rating / 2) / 2
        # print("new avg:")
        # print(new_avg)

        Asin.set_Prod_avg(round(new_avg, 2))
        Asin.set_Ama_avg(asin)

        amazon_rating =  Asin.get_Amazon_avg()
        product_rating = Asin.get_Prod_avg()
        # print(amazon_rating,product_rating)
        self.ama_rating.setText(str(amazon_rating))
        self.prod_rating.setText(str(product_rating))

        relcount = 0
        i=1
        for obj in objects:
            relevancy = Asin.check(str(obj))
            if relevancy == 'relevant':
                relcount += 1
            # print(str(obj), relevancy)
            self.listWidget.addItem(str(i)+". "+str(obj)+" \t : \t"+str(relevancy))
            i+=1
        rele = str(round((relcount / len(objects)),2) * 100)
        rel=rele+"%"
        self.relevancyAccuracyLabel.setText(rel)
    def compareProduct(self):
        asinVal1 = Asin.getAsinValue()
        ipFile1 = open(
            "Datasets/" + asinVal1 + "_folder/" + asinVal1 + "_compare.csv",
            "r")
        name = str(self.comboBox.currentText())
        asinVal2 = Asin.getAsinCompare(name)
        ipFile2 = open(
            "Datasets/" + asinVal2 + "_folder/" + asinVal2 + "_compare.csv",
            "r")

        #########---------------File 1
        csv_f1 = csv.reader(ipFile1)
        self.product1Text.clear()
        cost = Asin.getPrice(asinVal1)
        self.product1Text.addItem("MRP\t\t : \t" + cost)

        #########---------------File 2
        self.product2Text.clear()
        cost = Asin.getPrice(asinVal2)
        self.product2Text.addItem("MRP\t\t : \t" + cost)
        list = []

        for row1 in csv_f1:
            feature = row1[0]
            #print("f : " + feature)

            ipFile2.seek(0)
            csv_f2 = csv.reader(ipFile2)
            for row2 in csv_f2:
                if (row2[0] == feature):
                    s1 = row1[1].split('/')
                    value1 = row1[0] + "\t\t : \t" + str(s1[0]).strip("['")
                    self.product1Text.addItem(str(value1).rstrip(" "))
                    s2 = row2[1].split('/')
                    value2 = row2[0] + "\t\t : \t" + str(s2[0]).strip("['")
                    self.product2Text.addItem(str(value2).rstrip(" "))

                    list.append(feature)
                    break
                else:
                    continue

        # print(list)

        ipFile1.seek(0)
        csv_f1 = csv.reader(ipFile1)
        for row in csv_f1:
            if (row[0] in list):
                continue
            else:
                s = row[1].split('/')
                value = row[0] + "\t\t : \t" + str(s[0]).strip("['")
                self.product1Text.addItem(str(value).rstrip(" "))
        ipFile1.close()

        ipFile2.seek(0)
        csv_f2 = csv.reader(ipFile2)
        for row in csv_f2:
            if (row[0] in list):
                continue
            else:
                s = row[1].split('/')
                value = row[0] + "\t\t : \t" + str(s[0]).strip("['")
                self.product2Text.addItem(str(value).rstrip(" "))
        ipFile2.close()
 def setAsin(self, AsinValue):
     Asin.setAsinValue(AsinValue)