コード例 #1
0
ファイル: citeproc.py プロジェクト: hrtshu/vimrc
 def relevance(self, query):  #{{{2
     # Returns the relevance of an item for a query
     query = re.compile(query, re.I)
     relevance = float(0.0)
     tags_matched = []
     for tag in _significant_tags:
         for token in self.as_array(tag):
             if query.search(flatten(token)):
                 tags_matched.append(tag)
                 break
     if tags_matched != []:
         relevance = sum([_significant_tags[t] for t in tags_matched])
     return relevance
コード例 #2
0
ファイル: citeproc.py プロジェクト: duckwork/vim-pandoc
 def relevance(self, query): #{{{2
     # Returns the relevance of an item for a query
     query = re.compile(query, re.I)
     relevance = float(0.0)
     tags_matched = []
     for tag in _significant_tags:
         for token in self.as_array(tag):
             if query.search(flatten(token)):
                 tags_matched.append(tag)
                 break
     if tags_matched != []:
         relevance = sum([_significant_tags[t] for t in tags_matched])
     return relevance
コード例 #3
0
ファイル: citeproc.py プロジェクト: hrtshu/vimrc
    def match(self, query):  #{{{2
        # Matching engine. Returns 1 if match found, 0 otherwise.
        # Expects query to be a compiled regexp.

        # Very simple, just searches for substrings. Could be updated
        # to provide a 'matches' value for ranking? Using numbers here
        # so as to permit this future application.

        matched = False
        for variable in _significant_tags:
            for token in self.as_array(variable):
                matched = matched or query.search(flatten(token))
                if matched:
                    break

        if matched:
            return 1
        else:
            return 0
コード例 #4
0
ファイル: citeproc.py プロジェクト: duckwork/vim-pandoc
    def match(self, query): #{{{2
        # Matching engine. Returns 1 if match found, 0 otherwise.
        # Expects query to be a compiled regexp.

        # Very simple, just searches for substrings. Could be updated
        # to provide a 'matches' value for ranking? Using numbers here
        # so as to permit this future application.

        matched = False
        for variable in _significant_tags:
            for token in self.as_array(variable):
                matched = matched or query.search(flatten(token))
                if matched:
                    break

        if matched:
            return 1
        else:
            return 0