<commit_before># etcabductionpy.__main__
# Etcetera Abduction in Python
# <NAME>
# Spring 2016

from __future__ import print_function
import argparse
import sys

import parse
import etcetera
import forward
import incremental

argparser = argparse.ArgumentParser(description='Etcetera Abduction in Python')

argparser.add_argument('-i', '--infile',
                       nargs='?',
                       type=argparse.FileType('r'),
                       default=sys.stdin,
                       help='Input file of observed literals as lisp s-expressions, defaults to STDIN')

argparser.add_argument('-o', '--outfile',
                       nargs='?',
                       type=argparse.FileType('w'),
                       default=sys.stdout,
                       help='Output file, defaults to STDOUT')

argparser.add_argument('-k', '--kb',
                       nargs='?',
                       type=argparse.FileType('r'),
                       help='Knowledge base of definite clauses as lisp s-expressions')

argparser.add_argument('-n', '--nbest',
                       type=int,
                       default=10,
                       help='Generate NBEST-best proofs, defaults to 10')

argparser.add_argument('-g', '--graph',
                       action='store_true',
                       help='Output graph of solution in .dot format')

argparser.add_argument('-s', '--solution',
                       type=int,
                       default=1,
                       help='Graph the SOLUTION-best solution, defaults to 1')

argparser.add_argument('-d', '--depth',
                       type=int,
                       default=5,
                       help='Backchain to depth DEPTH, defaults to 5')

argparser.add_argument('-a', '--all',
                       action='store_true',
                       help='Generate all solutions')

argparser.add_argument('-f', '--forward',
                       action='store_true',
                       help='Forward chain from INFILE with KB')
argparser.add_argument('-c', '--incremental',
                       action='store_true',
                       help='Use incremental abduction')
argparser.add_argument('-w', '--window',
                       type=int,
                       default=4,
                       help='Incremental abduction window-size, defaults to 4')
argparser.add_argument('-b', '--beam',
                       type=int,
                       default=10,
                       help='Incremental abduction beam-size, defaults to 10')
args = argparser.parse_args()


# Load files

inlines = args.infile.readlines()
intext = "".join(inlines)
kb, obs = parse.definite_clauses(parse.parse(intext))
<commit_msg>Support for existential variables in the observables<commit_after># etcabductionpy.__main__
# Etcetera Abduction in Python
# <NAME>
# Spring 2016

from __future__ import print_function
import argparse
import sys

import parse
import etcetera
import forward
import incremental
import unify

argparser = argparse.ArgumentParser(description='Etcetera Abduction in Python')

argparser.add_argument('-i', '--infile',
                       nargs='?',
                       type=argparse.FileType('r'),
                       default=sys.stdin,
                       help='Input file of observed literals as lisp s-expressions, defaults to STDIN')

argparser.add_argument('-o', '--outfile',
                       nargs='?',
                       type=argparse.FileType('w'),
                       default=sys.stdout,
                       help='Output file, defaults to STDOUT')

argparser.add_argument('-k', '--kb',
                       nargs='?',
                       type=argparse.FileType('r'),
                       help='Knowledge base of definite clauses as lisp s-expressions')

argparser.add_argument('-n', '--nbest',
                       type=int,
                       default=10,
                       help='Generate NBEST-best proofs, defaults to 10')

argparser.add_argument('-g', '--graph',
                       action='store_true',
                       help='Output graph of solution in .dot format')

argparser.add_argument('-s', '--solution',
                       type=int,
                       default=1,
                       help='Graph the SOLUTION-best solution, defaults to 1')

argparser.add_argument('-d', '--depth',
                       type=int,
                       default=5,
                       help='Backchain to depth DEPTH, defaults to 5')

argparser.add_argument('-a', '--all',
                       action='store_true',
                       help='Generate all solutions')

argparser.add_argument('-f', '--forward',
                       action='store_true',
                       help='Forward chain from INFILE with KB')
argparser.add_argument('-c', '--incremental',
                       action='store_true',
                       help='Use incremental abduction')
argparser.add_argument('-w', '--window',
                       type=int,
                       default=4,
                       help='Incremental abduction window-size, defaults to 4')
argparser.add_argument('-b', '--beam',
                       type=int,
                       default=10,
                       help='Incremental abduction beam-size, defaults to 10')
args = argparser.parse_args()


# Load files

inlines = args.infile.readlines()
intext = "".join(inlines)
kb, obs = parse.definite_clauses(parse.parse(intext))
obs = unify.standardize(obs)

{'fraction_non_alphanumeric': 0.11423390752493201, 'fraction_numerical': 0.006527651858567543, 'mean_word_length': 1.6455635491606715, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3595745', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1385, 'n_words': 334}