# Path: tensorlog/simple.py
# class Compiler(object):
# class Builder(object):
# class RuleCollectionWrapper(parser.RuleCollection):
# class DBWrapper(object):
# class SchemaWrapper(dbschema.TypedSchema):
# class RuleWrapper(parser.Rule):
# class Options(object):
# class Experiment(Options):
#   def __init__(self,target='tensorflow',db=None,prog=None,rule_features=True,autoset_db_params=True,summary_file=None):
#   def get_cross_compiler(self):
#   def get_program(self):
#   def get_database(self):
#   def proof_count(self,mode,inputs=None):
#   def inference(self,mode,inputs=None):
#   def loss(self,mode,inputs=None):
#   def mark_db_predicate_trainable(self,mode):
#   def trainable_db_variables(self,mode,for_optimization=False):
#   def input_placeholder_name(self,mode):
#   def input_placeholder(self,mode):
#   def target_output_placeholder_name(self,mode):
#   def target_output_placeholder(self,mode):
#   def db_param_list(self):
#   def db_param_is_set(self,param_id):
#   def get_db_param_value(self,param_id):
#   def set_db_param_value(self,param_id,value):
#   def set_all_db_params_to_learned_values(self,session):
#   def serialize_db(self,dir_name):
#   def serialize_program(self,dir_name):
#   def _as_dataset(self,spec):
#   def load_dataset(self,dataset_spec):
#   def load_small_dataset(self,dataset_spec):
#   def annotate_small_dataset(self,dset):
#     def wrapped_xy_pair(mode): return (self.xc.wrapInput(dset.getX(mode)), self.xc.wrapInput(dset.getY(mode)))
#   def modes_to_learn(self,dataset_obj):
#   def minibatches(self,dataset_obj,batch_size=100,shuffle_first=True):
#   def load_big_dataset(self,dataset_spec,verbose=True):
#   def annotate_big_dataset(self,dset):
#       def rows_per_gigabyte(c): return (1024.0*1024.0*1024.0) / (c*4.0)
#   def __init__(self):
#   def __setattr__(self,name,value):
#   def _split(comma_or_space_sep_names):
#   def variable(variable_name):
#   def variables(space_sep_variable_names):
#   def types(space_sep_type_names):
#   def rule_id(type_name,rule_id):
#   def rule_ids(type_name,space_sep_rule_ids):
#     def goal_builder(rule_id):
#   def predicate(predicate_name):
#   def predicates(space_sep_predicate_names):
#     def goal_builder(pred_name):
#       def builder(*args):
#   def __iadd__(self,other):
#   def __init__(self):
#   def __iadd__(self,other):
#   def __init__(self,builder):
#   def _set_to_value(self,other):
#   def __iadd__(self,other):
#   def __init__(self,builder):
#   def __iadd__(self,other):
#   def _combine(x,y):
#   def __and__(self,other):
#   def __or__(self,other):
#   def __floordiv__(self,other):
#   def __le__(self,other):
#   def __repr__(self):
#   def __init__(self):
#   def set_from_command_line(self,argv):
#   def as_dictionary(self):
#   def option_usage(self):
#   def __init__(self):
#   def run(self):
#     UX,UY = test[self.mode]


import time
import sys
import getopt
import os
import logging
import tensorflow as tf
from tensorlog import simple
    W_rel = b.predicate('wFore_%s' % rel)
    b += answer(Question,Entity) <= mentions_entity(Question,Movie) & P_rel(Movie,Entity) // (W_rel(F) | has_feature(Question,F))
  # echo rules to stdout
  b.rules.listing()
  return b

def run_main():
  logging.basicConfig(level=logging.DEBUG)

  t0 = time.time()

  # configure the experiment, generate the rules, and initialize the
  # Tensorlog compiler.  If we're training, then also initialize the
  # weight vectors to some sort of default values.
  c = configure_from_command_line(sys.argv[1:])
  b = generate_rules()
  # databases can be stored in two formats: the .db format or the
  # .cfacts format.  A .cfacts file is basically a tab-separated-value
  # file, where the first column is a relation name, the other columns
  # are arguments to that relation, and the final column is a weight
  # (if it's a number). The .cfacts file can also include typing
  # information, in lines like '# :-
  # mentions_entity(question_t,entity_t)' .cfacts files must be sorted
  # by relation type.  The .db format is a binary format which is more
  # compact and faster to load.  The syntax "foo.db|foo.cfacts" for a
  # database tells Tensorlog to load a cached .db version of the
  # .cfacts file if it exists (and is more recent than the .cfacts
  # file) and otherwise to load the .cfacts file and create a cached
  # version in the .db file.
  dbspec = '/tmp/train-%d.db|inputs/train-%d.cfacts' % (c.num,c.num) if c.action=='train' else c.model

# Path: tensorlog/simple.py
# class Compiler(object):
# class Builder(object):
# class RuleCollectionWrapper(parser.RuleCollection):
# class DBWrapper(object):
# class SchemaWrapper(dbschema.TypedSchema):
# class RuleWrapper(parser.Rule):
# class Options(object):
# class Experiment(Options):
#   def __init__(self,target='tensorflow',db=None,prog=None,rule_features=True,autoset_db_params=True,summary_file=None):
#   def get_cross_compiler(self):
#   def get_program(self):
#   def get_database(self):
#   def proof_count(self,mode,inputs=None):
#   def inference(self,mode,inputs=None):
#   def loss(self,mode,inputs=None):
#   def mark_db_predicate_trainable(self,mode):
#   def trainable_db_variables(self,mode,for_optimization=False):
#   def input_placeholder_name(self,mode):
#   def input_placeholder(self,mode):
#   def target_output_placeholder_name(self,mode):
#   def target_output_placeholder(self,mode):
#   def db_param_list(self):
#   def db_param_is_set(self,param_id):
#   def get_db_param_value(self,param_id):
#   def set_db_param_value(self,param_id,value):
#   def set_all_db_params_to_learned_values(self,session):
#   def serialize_db(self,dir_name):
#   def serialize_program(self,dir_name):
#   def _as_dataset(self,spec):
#   def load_dataset(self,dataset_spec):
#   def load_small_dataset(self,dataset_spec):
#   def annotate_small_dataset(self,dset):
#     def wrapped_xy_pair(mode): return (self.xc.wrapInput(dset.getX(mode)), self.xc.wrapInput(dset.getY(mode)))
#   def modes_to_learn(self,dataset_obj):
#   def minibatches(self,dataset_obj,batch_size=100,shuffle_first=True):
#   def load_big_dataset(self,dataset_spec,verbose=True):
#   def annotate_big_dataset(self,dset):
#       def rows_per_gigabyte(c): return (1024.0*1024.0*1024.0) / (c*4.0)
#   def __init__(self):
#   def __setattr__(self,name,value):
#   def _split(comma_or_space_sep_names):
#   def variable(variable_name):
#   def variables(space_sep_variable_names):
#   def types(space_sep_type_names):
#   def rule_id(type_name,rule_id):
#   def rule_ids(type_name,space_sep_rule_ids):
#     def goal_builder(rule_id):
#   def predicate(predicate_name):
#   def predicates(space_sep_predicate_names):
#     def goal_builder(pred_name):
#       def builder(*args):
#   def __iadd__(self,other):
#   def __init__(self):
#   def __iadd__(self,other):
#   def __init__(self,builder):
#   def _set_to_value(self,other):
#   def __iadd__(self,other):
#   def __init__(self,builder):
#   def __iadd__(self,other):
#   def _combine(x,y):
#   def __and__(self,other):
#   def __or__(self,other):
#   def __floordiv__(self,other):
#   def __le__(self,other):
#   def __repr__(self):
#   def __init__(self):
#   def set_from_command_line(self,argv):
#   def as_dictionary(self):
#   def option_usage(self):
#   def __init__(self):
#   def run(self):
#     UX,UY = test[self.mode]


# Path: datasets/wikimovies/demo.py
import time
import sys
import getopt
import os
import logging
import tensorflow as tf
from tensorlog import simple

    W_rel = b.predicate('wFore_%s' % rel)
    b += answer(Question,Entity) <= mentions_entity(Question,Movie) & P_rel(Movie,Entity) // (W_rel(F) | has_feature(Question,F))
  # echo rules to stdout
  b.rules.listing()
  return b

def run_main():
  logging.basicConfig(level=logging.DEBUG)

  t0 = time.time()

  # configure the experiment, generate the rules, and initialize the
  # Tensorlog compiler.  If we're training, then also initialize the
  # weight vectors to some sort of default values.
  c = configure_from_command_line(sys.argv[1:])
  b = generate_rules()
  # databases can be stored in two formats: the .db format or the
  # .cfacts format.  A .cfacts file is basically a tab-separated-value
  # file, where the first column is a relation name, the other columns
  # are arguments to that relation, and the final column is a weight
  # (if it's a number). The .cfacts file can also include typing
  # information, in lines like '# :-
  # mentions_entity(question_t,entity_t)' .cfacts files must be sorted
  # by relation type.  The .db format is a binary format which is more
  # compact and faster to load.  The syntax "foo.db|foo.cfacts" for a
  # database tells Tensorlog to load a cached .db version of the
  # .cfacts file if it exists (and is more recent than the .cfacts
  # file) and otherwise to load the .cfacts file and create a cached
  # version in the .db file.
  dbspec = '/tmp/train-%d.db|inputs/train-%d.cfacts' % (c.num,c.num) if c.action=='train' else c.model

  tlog = simple.Compiler(db=dbspec, prog=b.rules, autoset_db_params=(c.action=='train'))