Ejemplo n.º 1
0
def advancedFeatureSearch(query, sought_feature):
    formatted_query = parser.parse(query)
    scoreDocs = searcher.search(formatted_query, 50).scoreDocs

    #### create return structure ####
    results = []
    comments = []

    for scoreDoc in scoreDocs:
        doc = searcher.doc(scoreDoc.doc)
        featureMap = simplejson.loads(doc.get("feature-contents"))

        comments.append(featureMap["featureMap"][sought_feat]["sentence"])
        resentry = {
            "feature": sought_feature,
            "title": doc.get("title"),
            "review_date": doc.get("modified"),
            "comments": comments
        }
        results.append(resentry)

    return render_to_response("search_by_product_and_feature_results.html", {
        "submitted_query": query,
        "results": results
    })
Ejemplo n.º 2
0
def doFeatureSearch(query, feature_query_list):
    scoreDocs = getResultScoreDocs(query)

    #### create return structure ####
    results = []

    for scoreDoc in scoreDocs:
        doc = searcher.doc(scoreDoc.doc)
        featureMap = simplejson.loads(doc.get("feature-contents"))

        positiveFeatureComments = {}
        negativeFeatureComments = {}
        for feat in featureMap["featureMap"].keys():
            #print feat
            positiveFeatureComments[feat] = []
            negativeFeatureComments[feat] = []

            for fmd in featureMap["featureMap"][feat]:
                if fmd["connotation"] == True:
                    #positiveFeatureComments[feat] = featureMap["featureMap"][feat]
                    positiveFeatureComments[feat].append(fmd)
                else:
                    #negativeFeatureComments[feat] = featureMap["featureMap"][feat]
                    negativeFeatureComments[feat].append(fmd)

            if not positiveFeatureComments[feat]:
                del positiveFeatureComments[feat]

            if not negativeFeatureComments[feat]:
                del negativeFeatureComments[feat]

        resentry = {
            "title": doc.get("title"),
            "content": doc.get("summary"),
            "positiveComments": positiveFeatureComments,
            "negativeComments": negativeFeatureComments
        }
        results.append(resentry)

        results.sort(
            cmp=lambda x, y: compare_feature_search(feature_query_list, x, y),
            reverse=True)

    return render_to_response("results.html", {
        "submitted_query": query,
        "results": results
    })
Ejemplo n.º 3
0
def advancedFeatureSearch(query, sought_feature):
    formatted_query = parser.parse(query)
    scoreDocs = searcher.search(formatted_query, 50).scoreDocs
        
    #### create return structure ####
    results = []
    comments = []
        
    for scoreDoc in scoreDocs:
        doc = searcher.doc(scoreDoc.doc)
        featureMap = simplejson.loads(doc.get("feature-contents"))
        
        comments.append(featureMap["featureMap"][sought_feat]["sentence"])
        resentry = {"feature": sought_feature, "title": doc.get("title"), "review_date": doc.get("modified"),  
                    "comments": comments }
        results.append(resentry)
            
    return render_to_response("search_by_product_and_feature_results.html", {"submitted_query": query, "results" : results})
Ejemplo n.º 4
0
def doProductFeatureSearch(query, product_query_list, feature_query_list):
    
    scoreDocs = getResultScoreDocs(query)
    
    #### create return structure ####
    results = []
    
    for scoreDoc in scoreDocs:
        doc = searcher.doc(scoreDoc.doc)
        featureMap = simplejson.loads(doc.get("feature-contents"))
        
        positiveFeatureComments = {}
        negativeFeatureComments = {}
        for feat in featureMap["featureMap"].keys():
            #print feat
            positiveFeatureComments[feat] = []
            negativeFeatureComments[feat] = []
            
            for fmd in featureMap["featureMap"][feat]:
                if fmd["connotation"] == True:
                    #positiveFeatureComments[feat] = featureMap["featureMap"][feat]
                    positiveFeatureComments[feat].append(fmd)
                else:
                    #negativeFeatureComments[feat] = featureMap["featureMap"][feat]
                    negativeFeatureComments[feat].append(fmd)
            
            if not positiveFeatureComments[feat]:
                del positiveFeatureComments[feat]
                
            if not negativeFeatureComments[feat]:
                del negativeFeatureComments[feat]
        
        resentry = {"title": doc.get("title"), "content": doc.get("summary"), 
                    "positiveComments": positiveFeatureComments, "negativeComments": negativeFeatureComments }
        results.append(resentry)
        
        results.sort(cmp=compare_product_feature_search, reverse=True)
        
    return render_to_response("results.html", {"submitted_query": query, "results" : results})