Пример #1
0
  def __init__(self, host, port, spec = None, vhost = None):
    self.host = host
    self.port = port
    if spec:
      self.spec = spec
    else:
      from qpid_config import amqp_spec_0_9
      self.spec = load(amqp_spec_0_9)
    self.structs = StructFactory(self.spec)
    self.sessions = {}

    self.mechanism = None
    self.response = None
    self.locale = None

    self.vhost = vhost
    if self.vhost == None:
      self.vhost = "/"

    self.queues = {}
    self.lock = threading.Lock()

    self.closed = False
    self.reason = None
    self.started = threading.Event()
Пример #2
0
def init_spec(train_raw):
  if OPTIONS.load_file:
    print >> sys.stderr, 'Loading saved params from %s' % OPTIONS.load_file
    spec = specutil.load(OPTIONS.load_file)
  elif OPTIONS.train_data:
    print >> sys.stderr, 'Initializing parameters...'
    in_vocabulary = get_input_vocabulary(train_raw)
    out_vocabulary = get_output_vocabulary(train_raw)
    lexicon = get_lexicon()
    spec = get_spec(in_vocabulary, out_vocabulary, lexicon)
  else:
    raise Exception('Must either provide parameters to load or training data.')
  return spec
Пример #3
0
def init_spec(train_raw, databases):
  if OPTIONS.load_file:
    print >> sys.stderr, 'Loading saved params from %s' % OPTIONS.load_file
    spec = specutil.load(OPTIONS.load_file)
  elif OPTIONS.train_data:
    print >> sys.stderr, 'Initializing parameters...'
    in_vocabulary = get_input_vocabulary(train_raw)
    out_vocabulary = get_output_vocabulary(OPTIONS.domain, databases)
    #out_vocabulary = get_output_vocabulary(train_raw)
    spec = get_spec(in_vocabulary, out_vocabulary)
  else:
    raise Exception('Must either provide parameters to load or training data.')
  return spec
Пример #4
0
def init_spec(train_raw, dev_raw):
    if OPTIONS.load_file:
        print >> sys.stderr, 'Loading saved params from %s' % OPTIONS.load_file
        spec = specutil.load(OPTIONS.load_file)
    elif OPTIONS.train_data:
        print >> sys.stderr, 'Initializing parameters...'
        in_vocabulary = get_input_vocabulary(train_raw)
        out_vocabulary = get_output_vocabulary(train_raw)
        domain_stats_vocab = DomainStatsVocab(train_raw + dev_raw,
                                              is_use=OPTIONS.domain_stats)
        lexicon = get_lexicon()
        spec = get_spec(in_vocabulary, out_vocabulary, lexicon,
                        domain_stats_vocab)
    else:
        raise Exception(
            'Must either provide parameters to load or training data.')
    return spec
Пример #5
0
def init_spec(train_raw):
    if OPTIONS.load_file:
        print >> sys.stderr, 'Loading saved params from %s' % OPTIONS.load_file
        spec = specutil.load(OPTIONS.load_file)
    elif OPTIONS.train_data:
        print >> sys.stderr, 'Initializing parameters...'
        numpy.random.seed(1)
        domain_vocabulary = get_domain_vocabulary(train_raw)
        out_vocabularies = get_output_vocabularies(train_raw)
        numpy.random.seed(0)
        in_vocabulary = get_input_vocabulary(train_raw)
        out_vocabulary = get_output_vocabulary(train_raw)

        lexicon = get_lexicon()
        spec = get_spec(in_vocabulary, out_vocabulary, domain_vocabulary,
                        out_vocabularies, lexicon)
    else:
        raise Exception(
            'Must either provide parameters to load or training data.')
    return spec