class_docstr: Set expansion module, given a trained np2vec model.
class_docstr_tok: ["Set","expansion","module",",","given","a","trained","np2vec","model","."]
docstr: Given a seed of terms, return the expanded set of terms.
  
  Args:
      seed: seed terms
      topn: maximal number of expanded terms to return
  
  Returns:
      up to topn expanded terms and their probabilities
docstr_tok: ["Given","a","seed","of","terms",",","return","the","expanded","set","of","terms",".","Args",":","seed",":","seed","terms","topn",":","maximal","number","of","expanded","terms","to","return","Returns",":","up","to","topn","expanded","terms","and","their","probabilities"]
code: def expand(self, seed, topn=500):
      """
      Given a seed of terms, return the expanded set of terms.
  
      Args:
          seed: seed terms
          topn: maximal number of expanded terms to return
  
      Returns:
          up to topn expanded terms and their probabilities
      """
      seed_ids = list()
      upper = True
      lower = True
      for np in seed:
          np = np.strip()
          if not self.grouping and (upper or lower):
              # case feature is relevant only if we don't have grouping
              if np[0].islower():
                  upper = False
              else:
                  lower = False
          id = self.term2id(np)
          if id is not None:
              seed_ids.append(id)
          else:
              logger.warning("The term: '%s' is out-of-vocabulary.", np)
      if len(seed_ids) > 0:
          if not self.grouping and (upper or lower):
              res_id = self.np2vec_model.most_similar(
                  seed_ids, topn=2 * topn
              )
          else:
              res_id = self.np2vec_model.most_similar(
                  seed_ids, topn=topn
              )
          res = list()
          for r in res_id:
              if len(res) == topn:
                  break
              # pylint: disable=R0916
              if (
                  self.grouping
                  or (not lower and not upper)
                  or (upper and r[0][0].isupper())
                  or (lower and r[0][0].islower())
              ):
                  term = self.__id2term(r[0])
                  if term is not None:
                      res.append((self.__id2term(r[0]), r[1]))
          ret_val = res
      else:
          logger.info("All the seed terms are out-of-vocabulary.")
          ret_val = None
      return ret_val
  
file_path: nlp-architect/solutions/set_expansion/set_expand.py
imports: import logging
  import sys
  from argparse import ArgumentParser
  from os import path
  from nlp_architect.models.np2vec import NP2vec
  from nlp_architect.utils.io import validate_existing_filepath, check_size, load_json_file
label_desc: Use image node_id 8 for calling the SetExpand obj's underlying member method code with example usage: obj.expand(seed, topn) and returns: ret_val