parameters: (className, basedir,
                                  validFile = lambda x: x.endswith('.sig'),
                                  filename2gid = lambda x: splitext(basename(x))[0])
return_statement: return classMap
docstring: Given a hierarchy where the .sig files are contained in directories
      which name is the class they belong to, return a map from filename -> class.
  
      validFile is a function that returns whether a given file should be considered
      filename2gid is the function that returns a Gaia ID given a sig filename. By default,
      this returns the base filename without the extension.
docstring_summary: Given a hierarchy where the .sig files are contained in directories
      which name is the class they belong to, return a map from filename -> class.
docstring_tokens: Given a hierarchy where the . sig files are contained in directories which name is the class they belong to return a map from filename - > class .
function: def getGroundTruthFromDirectory(className, basedir,
                                  validFile = lambda x: x.endswith('.sig'),
                                  filename2gid = lambda x: splitext(basename(x))[0]):
      """Given a hierarchy where the .sig files are contained in directories
      which name is the class they belong to, return a map from filename -> class.
  
      validFile is a function that returns whether a given file should be considered
      filename2gid is the function that returns a Gaia ID given a sig filename. By default,
      this returns the base filename without the extension.
      """
  
      if not exists(basedir):
          raise IOError("Directory '%s' doesn't exist" % basedir)
  
      classes = [ basename(d) for d in glob.glob(join(basedir, '*')) ]
  
      # get class map: point id -> class
      classMap = GroundTruth(className)
  
      for cls in classes:
          files = [ f for f in glob.glob(join(basedir, cls, '*')) if validFile(f) ]
  
          for f in files:
              classMap[filename2gid(f)] = cls
  
      return classMap
function_tokens: def getGroundTruthFromDirectory ( className , basedir , validFile = lambda x : x . endswith ( '.sig' ) , filename2gid = lambda x : splitext ( basename ( x ) ) [ 0 ] ) : if not exists ( basedir ) : raise IOError ( "Directory '%s' doesn't exist" % basedir ) classes = [ basename ( d ) for d in glob . glob ( join ( basedir , '*' ) ) ] # get class map: point id -> class classMap = GroundTruth ( className ) for cls in classes : files = [ f for f in glob . glob ( join ( basedir , cls , '*' ) ) if validFile ( f ) ] for f in files : classMap [ filename2gid ( f ) ] = cls return classMap