[deprecated] 建議使用方法 `get_question_results()`
970702
def list_results(self, number, username):
        
        # 取得新 API 的結果
        data = self.get_question_results(number, username)
        # 實作相容的結構
        result = []
        for number in data:
            # 儲存題目資訊
            result += [(number, data[number])]
        # 回傳結果
        return result
1166125
public QuestionStructure getMainPart(String question, List<edu.stanford.nlp.ling.Word> words) {
        QuestionStructure questionStructure = new QuestionStructure();
        questionStructure.setQuestion(question);

        Tree tree = LP.apply(words);
        LOG.info("句法树: ");
        tree.pennPrint();
        questionStructure.setTree(tree);

        GrammaticalStructure gs = GSF.newGrammaticalStructure(tree);
        if(gs == null){
            return null;
        }
        //获取依存关系
        Collection<TypedDependency> tdls = gs.typedDependenciesCCprocessed(true);
        questionStructure.setTdls(tdls);
        Map<String, String> map = new HashMap<>();
        String top = null;
        String root = null;
        LOG.info("句子依存关系：");
        //依存关系
        List<String> dependencies = new ArrayList<>();
        for (TypedDependency tdl : tdls) {
            String item = tdl.toString();
            dependencies.add(item);
            LOG.info("\t" + item);
            if (item.startsWith("top")) {
                top = item;
            }
            if (item.startsWith("root")) {
                root = item;
            }
            int start = item.indexOf("(");
            int end = item.lastIndexOf(")");
            item = item.substring(start + 1, end);
            String[] attr = item.split(",");
            String k = attr[0].trim();
            String v = attr[1].trim();
            String value = map.get(k);
            if (value == null) {
                map.put(k, v);
            } else {
                //有值
                value += ":";
                value += v;
                map.put(k, value);
            }
        }
        questionStructure.setDependencies(dependencies);

        String mainPartForTop = null;
        String mainPartForRoot = null;
        if (top != null) {
            mainPartForTop = topPattern(top, map);
        }
        if (root != null) {
            mainPartForRoot = rootPattern(root, map);
        }
        questionStructure.setMainPartForTop(mainPartForTop);
        questionStructure.setMainPartForRoot(mainPartForRoot);

        if (questionStructure.getMainPart() == null) {
            LOG.error("未能识别主谓宾：" + question);
        } else {
            LOG.info("主谓宾：" + questionStructure.getMainPart());
        }
        return questionStructure;
    }
219430
function queryBat (queue, cb) {
  const res = []

  queue.forEach(item => {
    const { selector, single, fields, component } = item
    // selector 的容器节点
    /* eslint-disable */
    const container = (
      component !== null ?
        (Nerv.findDOMNode(component) || document) :
        document
    )
    /* eslint-enable */

    // 特殊处理 ---- 选自己
    let selectSelf = false
    if (container !== document) {
      const $nodeList = container.parentNode.querySelectorAll(selector)
      for (let i = 0, len = $nodeList.length; i < len; ++i) {
        if (container === $nodeList[i]) {
          selectSelf = true
          break
        }
      }
    }

    if (single) {
      const el = selectSelf === true ? container : container.querySelector(selector)
      res.push(filter(fields, el, selector))
    } else {
      const $children = container.querySelectorAll(selector)
      const children = []
      selectSelf === true && children.push(container)
      for (let i = 0, len = $children.length; i < len; ++i) {
        children.push($children[i])
      }
      res.push(children.map(dom => filter(fields, dom)))
    }
  })
  cb(res)
}
180897
function getPostList(issues) {
  if (!issues.body || !issues.headers) return;

  let pageInfo = getPage(issues.headers.link);
  let pageList = [];

  issues.body.forEach((item) => {
    // 如果文章不存在分类，则不展示出来，该功能先取消
    // if (!item.labels || item.labels.length === 0) return;

    pageList.push(getPost(item));
  });

  return {
    page: pageInfo,
    list: pageList
  }
}
710653
@Override
	public Object call(Object[] args, Context context) {
		// 只能有一个参数且只能为字符串
		if ((args.length >= 1) && (args[0] instanceof String) && (args[0] != null)) {
			String spel = (String) args[0];
			Expression expression = getExpression(spel);
			// 如果有第二参数，取他作为根对象
			if ((args.length >= 2) && (args[1] != null)) {
				return expression.getValue(createEvaluationContext(args[1], context));
			} else {
				return expression.getValue(createEvaluationContext(Collections.emptyMap(), context));
			}
		}
		return null;
	}
1073403
def hot_answers(self):
        
        from .question import Question
        from .author import Author
        from .answer import Answer
        hot_questions_url = Topic_Hot_Questions_Url.format(self.id)
        params = {'start': 0, '_xsrf': self.xsrf}
        res = self._session.get(hot_questions_url)
        soup = BeautifulSoup(res.content)
        while True:
            answers_div = soup.find_all('div', class_='feed-item')
            last_score = answers_div[-1]['data-score']
            for div in answers_div:
                # 没有 text area 的情况是：答案被和谐。
                if not div.textarea:
                    continue
                question_url = Zhihu_URL + div.h2.a['href']
                question_title = div.h2.a.text.strip()
                question = Question(question_url, question_title,
                                    session=self._session)
                author_link = div.find('a', class_='author-link')
                if not author_link:
                    author_url = None
                    author_name = '匿名用户'
                    author_motto = ''
                else:
                    author_url = Zhihu_URL + author_link['href']
                    author_name = author_link.text
                    author_motto_span = div.find('span', class_='bio')
                    author_motto = author_motto_span['title'] \
                        if author_motto_span else ''
                author = Author(author_url, author_name, author_motto,
                                session=self._session)

                body = div.find('div', class_='zm-item-rich-text')
                answer_url = Zhihu_URL + body['data-entry-url']
                upvote_num = int(div.find(
                    'div', class_='zm-item-vote-info')['data-votecount'])

                yield Answer(answer_url, question, author, upvote_num,
                             session=self._session)

            params['offset'] = last_score
            res = self._session.post(hot_questions_url, data=params)
            gotten_feed_num = res.json()['msg'][0]
            # 如果得到问题数量为0则返回
            if gotten_feed_num == 0:
                return
            soup = BeautifulSoup(res.json()['msg'][1])
220850
protected function buildQuery()
    {
        // 设置当前模型 确保查询返回模型对象
        $class = $this->query;
        $query = (new $class())->connect($this->connection)
            ->model($this)
            ->json($this->json, $this->jsonAssoc)
            ->setJsonFieldType($this->jsonType);

        if (isset(static::$readMaster['*']) || isset(static::$readMaster[static::class])) {
            $query->master(true);
        }

        // 设置当前数据表和模型名
        if (!empty($this->table)) {
            $query->table($this->table);
        } else {
            $query->name($this->name);
        }

        if (!empty($this->pk)) {
            $query->pk($this->pk);
        }

        return $query;
    }
72164
def QueryHowDoI(Query, num_answers, full_text, window:sg.Window):
    '''
    
    '''
    howdoi_command = HOW_DO_I_COMMAND
    full_text_option = ' -a' if full_text else ''
    t = subprocess.Popen(howdoi_command + ' \"'+ Query + '\" -n ' + str(num_answers)+full_text_option, stdout=subprocess.PIPE)
    (output, err) = t.communicate()
    window.Element('_OUTPUT_').Update('{:^88}'.format(Query.rstrip()), append=True)
    window.Element('_OUTPUT_').Update('_'*60, append=True)
    window.Element('_OUTPUT_').Update(output.decode("utf-8"), append=True)
    exit_code = t.wait()
312632
def get_class_recipes(class_url, max_page=20, sleep=0.1):
    """"""
    class_url = class_url + "?page={page}"
    recipes = dict()

    # 暴力爬取方案，每个菜谱分类请求100页
    for page in range(1, max_page):
        time.sleep(sleep)
        url = class_url.format(page=page)
        print("current url: ", url)
        response = requests.get(url, headers=get_header())
        html = BeautifulSoup(response.text, "lxml")

        # 获取本页菜谱
        menus = html.find("div", {'class': 'new-menu-list search-menu-list clearfix mt10'})
        if menus:
            print("get recipes fail: ", url)
            menus = menus.find_all('a')
            for m in menus:
                name = re.sub("\n| ", "", m.text)
                recipe_url = urljoin(HOME_URL, m['href'])
                recipes[name] = recipe_url

        # 判断是否是最后一页
        # next_page = html.find('div', {'class': 'paging mt20'}).text
        # if "下一页" in next_page:
        #     page += 1
        # else:
        #     break
    return recipes
133127
private function getResult($url, $body, $type, $method)
    {
        $data = $this->connection($url, $body, $type, $method);
        if (isset($data) && !empty($data)) {
            $result = $data;
        } else {
            $result = '没有返回数据';
        }

        return $result;
    }
75570
private List<String> extractQuestionPatternFromQuestion(String question, PatternMatchStrategy patternMatchStrategy) {
        List<String> questionPatterns = new ArrayList<>();
        //去除问题中的前后空白字符
        question = question.trim();
        LOG.info("问题：" + question);
        if (patternMatchStrategy.enableQuestionPattern(QuestionPattern.Question)) {
            questionPatterns.add(question);
        }
        if (patternMatchStrategy.enableQuestionPattern(QuestionPattern.TermWithNatures)
                || patternMatchStrategy.enableQuestionPattern(QuestionPattern.Natures)) {
            String termWithNature = questionPatternCache.get(question + "termWithNature");
            String nature = questionPatternCache.get(question + "nature");

            if (termWithNature == null || nature == null) {
                //提取问题词性以便和模式进行匹配
                List<Word> words = WordParser.parse(question);
                //APDPlat的发起人是谁？
                //apdplat/en 的/uj 发起人/n 是/v 谁/RW.RWPersonSingle ？/w 
                StringBuilder termWithNatureStrs = new StringBuilder();
                //APDPlat的发起人是谁？
                //en/uj/n/v/RW.RWPersonSingle/w		
                StringBuilder natureStrs = new StringBuilder();
                int i = 0;
                for (Word word : words) {
                    termWithNatureStrs.append(word.getText()).append("/").append(word.getPartOfSpeech().getPos()).append(" ");
                    if ((i++) > 0) {
                        natureStrs.append("/");
                    }
                    natureStrs.append(word.getPartOfSpeech().getPos());
                }
                termWithNature = termWithNatureStrs.toString();
                nature = natureStrs.toString();
                questionPatternCache.put(question + "termWithNature", termWithNature);
                questionPatternCache.put(question + "nature", nature);
            }

            if (patternMatchStrategy.enableQuestionPattern(QuestionPattern.TermWithNatures)) {
                questionPatterns.add(termWithNature);
                LOG.info("词和词性序列：" + termWithNature);
            }
            if (patternMatchStrategy.enableQuestionPattern(QuestionPattern.Natures)) {
                questionPatterns.add(nature);
                LOG.info("词性序列：" + nature);
            }
        }
        if (patternMatchStrategy.enableQuestionPattern(QuestionPattern.MainPartPattern)
                || patternMatchStrategy.enableQuestionPattern(QuestionPattern.MainPartNaturePattern)) {
            String mainPart = questionPatternCache.get(question + "mainPart");
            if (mainPart == null) {
                //提取主谓宾及词性以便和模式进行匹配
                QuestionStructure questionStructure = mainPartExtracter.getMainPart(question);
                if(questionStructure != null){
                    mainPart = questionStructure.getMainPart();
                    questionPatternCache.put(question + "mainPart", mainPart);
                }
            }
            if (mainPart != null) {
                if (patternMatchStrategy.enableQuestionPattern(QuestionPattern.MainPartPattern)) {
                    String questionMainPartPattern = questionPatternCache.get(question + "questionMainPartPattern");
                    if (questionMainPartPattern == null) {
                        questionMainPartPattern = mainPartExtracter.getQuestionMainPartPattern(question, mainPart);
                        questionPatternCache.put(question + "questionMainPartPattern", questionMainPartPattern);
                    }
                    questionPatterns.add(questionMainPartPattern);
                    LOG.info("主谓宾词和词性序列：" + questionMainPartPattern);
                }
                if (patternMatchStrategy.enableQuestionPattern(QuestionPattern.MainPartNaturePattern)) {
                    String questionMainPartNaturePattern = questionPatternCache.get(question + "questionMainPartNaturePattern");
                    if (questionMainPartNaturePattern == null) {
                        questionMainPartNaturePattern = mainPartExtracter.getQuestionMainPartNaturePattern(question, mainPart);
                        questionPatternCache.put(question + "mainPartPattern", questionMainPartNaturePattern);
                    }
                    questionPatterns.add(questionMainPartNaturePattern);
                    LOG.info("主谓宾词性序列：" + questionMainPartNaturePattern);
                }
            }
        }
        return questionPatterns;
    }
99000
public function QueryLogisticsInfo()
        {

            // 參數初始化
            $ParamList = [
                'MerchantID' => '',
                'AllPayLogisticsID' => '',
                'PlatformID' => '',
            ];
            $this->PostParams = $this->GetPostParams($this->Send, $ParamList);
            $this->PostParams['TimeStamp'] = strtotime('now');

            // 參數檢查
            $this->ValidateHashKey();
            $this->ValidateHashIV();
            $this->ValidateID('MerchantID', $this->PostParams['MerchantID'], 10);
            $this->ServiceURL = $this->GetURL('QUERY_LOGISTICS_INFO');
            $this->ValidateID('AllPayLogisticsID', $this->PostParams['AllPayLogisticsID'], 20);
            $this->ValidateID('PlatformID', $this->PostParams['PlatformID'], 10, true);

            // 產生 CheckMacValue
            $this->PostParams['CheckMacValue'] = ECPay_CheckMacValue::generate($this->PostParams, $this->HashKey, $this->HashIV);

            // 解析回傳結果
            // 回應訊息：MerchantID=XXX&MerchantTradeNo=XXX&AllPayLogisticsID=XXX&GoodsAmount=XXX&LogisticsType=XXX&HandlingCharge=XXX&TradeDate=XXX&LogisticsStatus=XXX&GoodsName=XXX &CheckMacValue=XXX
            $Result = [];
            $Feedback = ECPay_IO::ServerPost($this->PostParams, $this->ServiceURL);
            parse_str($Feedback, $Result);

            return $Result;
        }
478115
public function getData()
    {
        $this->validate('orderId', 'txnTime', 'txnAmt', 'queryId');

        $data = array(
            'version'     => $this->getVersion(),        //版本号
            'encoding'    => $this->getEncoding(),        //编码方式
            'certId'      => $this->getCertId(),    //证书ID
            'signMethod'  => $this->getSignMethod(),        //签名方法
            'txnType'     => '31',        //交易类型
            'txnSubType'  => '00',        //交易子类
            'bizType'     => $this->getBizType(),        //业务类型
            'accessType'  => $this->getAccessType(),        //接入类型
            'channelType' => $this->getChannelType(),        //渠道类型
            'orderId'     => $this->getOrderId(),    //商户订单号，重新产生，不同于原消费
            'merId'       => $this->getMerId(),            //商户代码，请改成自己的测试商户号
            'origQryId'   => $this->getQueryId(),
            //原消费的queryId，可以从查询接口或者通知接口中获取
            'txnTime'     => $this->getTxnTime(),    //订单发送时间，重新产生，不同于原消费
            'txnAmt'      => $this->getTxnAmt(),    //交易金额，消费撤销时需和原消费一致
            'backUrl'     => $this->getNotifyUrl(),  //后台通知地址
            'reqReserved' => $this->getReqReserved(),
            //请求方保留域，透传字段，查询、通知、对账文件中均会原样出现
        );

        $data = $this->filter($data);

        $data['signature'] = $this->sign($data);

        return $data;
    }
63003
def paginate(self):
        
        self.tcex.log.warning(u'Using deprecated method (paginate).')
        resources = []
        self._request.add_payload('resultStart', self._result_start)
        self._request.add_payload('resultLimit', self._result_limit)
        results = self.request()
        response = results.get('response')
        if results.get('status') == 'Success':
            data = response.json()['data']
            resources = data[self.request_entity]

            # set results count returned by first API call
            if data.get('resultCount') is not None:
                self._result_count = data.get('resultCount')
                # self._result_start = self._result_limit

            self.tcex.log.debug(u'Result Count: {}'.format(self._result_count))

            while True:
                if len(resources) >= self._result_count:
                    break
                self._result_start += self._result_limit
                self._request.add_payload('resultStart', self._result_start)
                results = self.request()
                resources.extend(results['data'])

            self.tcex.log.debug(u'Resource Count: {}'.format(len(resources)))

        return resources
759691
private static function get_models_data(){
        $attr = self::$attr;
        if(!$attr['table']) return [];
        //表不存在返回空数组
        $sql = 'show tables like \''.config('database.prefix').$attr['table'].'\' ';
        $flag = Db::query($sql);
        if(!count($flag))return [];

        $Db = Db::name($attr['table']);

        if(strlen($attr['where'])) $Db->where($attr['where']);
        if(strlen($attr['field'])) $Db->field($attr['field']);
        if(strlen($attr['limit'])) $Db->limit($attr['limit']);
        if(strlen($attr['group'])) $Db->group($attr['group']);

        $data = $Db->select();

        $return = [];
        $arr = explode(',',$attr['field']);
        //变成一维数组
        foreach($data as $k => $v){
            $return[$v[$arr[0]]] = $v[$arr[1]];
        }
        return $return;
    }
119460
function () {
                    var index = 0;

                    while (index < fireLength) {

                        if ([].indexOf.call(arguments, list[index]) !== -1) {

                            // 从队列中删除当前回调
                            list.splice(index, 1);

                            // 如果当前回调队列被多层嵌套执行
                            // 上几层队列也可能会受到影响
                            if (firing) {
                                if (fireQueue.length) {
                                    fireQueue.forEach(function (value, key) {
                                        // 被删除的回调位于当前索引位置前面
                                        // 当前索引位置自减1
                                        if (index <= value) {
                                            fireQueue[key]--;
                                        }
                                    });
                                }

                                // 如果被删除的函数的索引位置在fireIndex的前面
                                // fireIndex自减1

                                if (index <= fireIndex) {
                                    fireIndex--;
                                }
                            }

                            // 回调列表长度改变
                            fireLength--;
                        } else {
                            index++;
                        }
                    }

                    return this;
                }
1259669
private QuestionTypePattern extractQuestionTypePattern(String questionTypePatternFile) {
        QuestionTypePattern value = questionTypePatternCache.get(questionTypePatternFile);
        if (value != null) {
            return value;
        }
        //统计不重复的【问题类型】和【问题模式】
        Set<String> questionTypesForSet = new HashSet<>();
        Set<Pattern> questionPatternsForSet = new HashSet<>();
        //顺序存储，【问题类型】和【问题模式】一一对应
        List<String> types = new ArrayList<>();
        List<Pattern> patterns = new ArrayList<>();
        BufferedReader reader = null;
        try {
            InputStream in = PatternBasedMultiLevelQuestionClassifier.class.getResourceAsStream(questionTypePatternFile);
            reader = new BufferedReader(new InputStreamReader(in, "utf-8"));
            String line = null;
            int i = 1;
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (line.length() == 0 || line.startsWith("//") || line.startsWith("#")) {
                    continue;
                }
                LOG.debug("处理模式" + (i++) + "：" + line);
                String[] tokens = line.split("\\s+", 3);
                types.add(tokens[0]);
                questionTypesForSet.add(tokens[0]);
                patterns.add(Pattern.compile(tokens[1], Pattern.CASE_INSENSITIVE));
                questionPatternsForSet.add(Pattern.compile(tokens[1], Pattern.CASE_INSENSITIVE));
            }
        } catch (Exception e) {
            LOG.error("问题模式文件读取失败: " + questionTypePatternFile);
            LOG.debug("问题模式文件读取失败: " + questionTypePatternFile, e);
            return null;
        } finally {
            try {
                reader.close();
            } catch (Exception e) {
                LOG.error("问题模式文件关闭失败: " + questionTypePatternFile);
                LOG.debug("问题模式文件关闭失败: " + questionTypePatternFile, e);
                return null;
            }
        }
        if (patterns.isEmpty() || patterns.size() != types.size()) {
            LOG.info("问题模式文件为空：" + questionTypePatternFile);
            return null;
        }
        LOG.debug("问题模式文件加载成功");
        LOG.debug("所有问题类型：");
        int i = 1;
        for (String type : questionTypesForSet) {
            LOG.debug("类型" + (i++) + ": " + type);
        }
        LOG.debug("所有问题模式：");
        i = 1;
        for (Pattern pattern : questionPatternsForSet) {
            LOG.debug("模式" + (i++) + ": " + pattern.pattern());
        }
        QuestionTypePattern questionTypePattern = new QuestionTypePattern();
        questionTypePattern.setPatterns(patterns);
        questionTypePattern.setTypes(types);

        questionTypePatternCache.put(questionTypePatternFile, questionTypePattern);

        return questionTypePattern;
    }