當前位置: 首頁>>代碼示例>>Python>>正文


Python JsonSimple.getJsonSimpleList方法代碼示例

本文整理匯總了Python中au.edu.usq.fascinator.common.JsonSimple.getJsonSimpleList方法的典型用法代碼示例。如果您正苦於以下問題:Python JsonSimple.getJsonSimpleList方法的具體用法?Python JsonSimple.getJsonSimpleList怎麽用?Python JsonSimple.getJsonSimpleList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在au.edu.usq.fascinator.common.JsonSimple的用法示例。


在下文中一共展示了JsonSimple.getJsonSimpleList方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: process_tags

# 需要導入模塊: from au.edu.usq.fascinator.common import JsonSimple [as 別名]
# 或者: from au.edu.usq.fascinator.common.JsonSimple import getJsonSimpleList [as 別名]
    def process_tags(self, result):
        tags = []
        tagsDict = {}
        # Build a dictionary of the tags
        for doc in result:
            # Get Anotar data from Solr data
            doc = JsonSimple(doc.get("jsonString"))
            # Get actual tag text
            tag = doc.getString(None, ["content", "literal"])
            # Find out if they have locators
            locs = doc.getJsonSimpleList(["annotates", "locators"]).size()
            if locs == 0:
                # Basic tags, just aggregate counts
                if tag in tagsDict:
                    # We've seen it before, just increment the counter
                    existing = tagsDict[tag]
                    count = existing.getInteger(0, ["tagCount"])
                    existing.getJsonObject().put("tagCount", str(count + 1))
                else:
                    # First time, store this object
                    doc.getJsonObject().put("tagCount", str(1))
                    tagsDict[tag] = doc
            else:
                # Tags with a locator, special case for images etc.
                tags.append(doc.toString())

        # Push all the 'basic' counts into the list to return
        for tag in tagsDict:
            tags.append(tagsDict[tag].toString())
        return "[" + ",".join(tags) + "]"
開發者ID:kiranba,項目名稱:the-fascinator,代碼行數:32,代碼來源:anotar.py

示例2: __activate__

# 需要導入模塊: from au.edu.usq.fascinator.common import JsonSimple [as 別名]
# 或者: from au.edu.usq.fascinator.common.JsonSimple import getJsonSimpleList [as 別名]
    def __activate__(self, context):
        self.vc = context

        responseType = "text/html; charset=UTF-8"
        responseMsg = ""
        func = self.vc("formData").get("func")
        if func == "placeName":
            try:
                placeName = self.vc("formData").get("q")
                url = "http://ws.geonames.org/searchJSON?fuzzy=0.7&q=" + placeName
                client = BasicHttpClient(url)
                get = GetMethod(url)
                statusInt = client.executeMethod(get)
                r = str(statusInt)
                json = JsonSimple(get.getResponseBodyAsString().strip())
                for geoName in json.getJsonSimpleList("geonames"):
                    responseMsg += "%s, %s|%s \n" % (geoName.getString(None, "name"), geoName.getString(None, "countryName"), geoName.getString(None, "geonameId"))
            except Exception, e:
                print "exception: ", str(e)
                r = str(e), None
            responseType = "text/plain; charset=UTF-8"
開發者ID:kiranba,項目名稱:the-fascinator,代碼行數:23,代碼來源:geonames.py


注:本文中的au.edu.usq.fascinator.common.JsonSimple.getJsonSimpleList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。