class_docstr: A parser for LibSVM-formatted ranking files.
  
  This parser can parse an iterable of lines into an iterable of
  `RankingExampleTuple`s that contain the per-query labels and features.
  
  Example usage:
  >>> lines = ["1 qid:1 1:5.0 2:3.0", "2 qid:1 1:2.0 2:1.0"]
  >>> feature_names = {1: "bm25", 2: "tfidf"}
  >>> parser = LibSVMRankingParser(lines, feature_names)
  >>> for example in parser:
  ...   print(example[0])
  {'bm25': array([5., 2.]), 'tfidf': array([3., 1.]), 'label': array([1, 2])}
  
  The parser will raise a ParserError with an informative error message if the
  content being parsed does not match LibSVM ranking format.
class_docstr_tok: ["A","parser","for","LibSVM-formatted","ranking","files",".","This","parser","can","parse","an","iterable","of","lines","into","an","iterable","of","`","RankingExampleTuple","`","s","that","contain","the","per-query","labels","and","features",".","Example","usage",":",">",">",">","lines","=","[","``","1","qid:1","1:5.0","2:3.0","''",",","``","2","qid:1","1:2.0","2:1.0","''","]",">",">",">","feature_names","=","{","1",":","``","bm25","''",",","2",":","``","tfidf","''","}",">",">",">","parser","=","LibSVMRankingParser","(","lines",",","feature_names",")",">",">",">","for","example","in","parser",":","...","print","(","example","[","0","]",")","{","'bm25","'",":","array","(","[","5.",",","2",".","]",")",",","'tfidf","'",":","array","(","[","3.",",","1",".","]",")",",","'label","'",":","array","(","[","1",",","2","]",")","}","The","parser","will","raise","a","ParserError","with","an","informative","error","message","if","the","content","being","parsed","does","not","match","LibSVM","ranking","format","."]
docstr: Iterates over `RankingExampleTuple`s.
  
  Yields:
    `RankingExampleTuple` that represent a single query.
  
  Raises:
    ParserError: If parsing failed.
docstr_tok: ["Iterates","over","`","RankingExampleTuple","`","s",".","Yields",":","`","RankingExampleTuple","`","that","represent","a","single","query",".","Raises",":","ParserError",":","If","parsing","failed","."]
code: def __iter__(self):
      """Iterates over `RankingExampleTuple`s.
  
      Yields:
        `RankingExampleTuple` that represent a single query.
  
      Raises:
        ParserError: If parsing failed.
      """
      # Parse each line and yield the resulting examples as they become available.
      for line_number, line in enumerate(self._lines, start=1):
          self._parse_line(line_number, line)
          while self._available_examples:
              yield self._available_examples.popleft()
  
      # Signal the end has been reached and yield any remaining items.
      self._end_of_parse()
      while self._available_examples:
          yield self._available_examples.popleft()
  
file_path: datasets/tensorflow_datasets/ranking/libsvm_ranking_parser.py
imports: import collections
  import dataclasses
  import re
  from typing import Iterable, List, Mapping, Tuple
  import numpy
label_desc: Use image node_id 6 for calling the LibSVMRankingParser obj's underlying member method code with example usage: obj.__iter__() without return types