예제 #1
0
 def test(self):
     DTEULAAPP.loadmodels()
     theclauses = DTEULAAPP.extractClauses(clausetext1)
     predictions = DTEULAAPP.predicteula(theclauses)
     self.assertEqual(len(predictions['prediction']), 22,
                      'There are 22 predictions')
     self.assertEqual(len(predictions['windows']), 22,
                      'There are 22 sets of windows')
예제 #2
0
 def test(self):
     DTEULAAPP.loadmodels()
     resourcefolder = helpers.getresourcefolder()
     outpath = os.path.join(resourcefolder, 'tempout.json')
     DTEULAAPP.batch(resourcefolder, outpath)
     self.assertEqual(
         os.stat(outpath).st_size, 329185,
         'The output file is 329185 bytes in size')
     os.remove(outpath)
예제 #3
0
 def test(self):
     DTEULAAPP.loadmodels()
     results = DTEULAAPP.processClauseText('', 'text')
     self.assertEqual(len(results), 0,
                      'There are 0 results of processing no text')
     accs = sum(1 for curresult in results
                if curresult['classification'] == 'Acceptable')
     self.assertEqual(accs, 0,
                      'There are 0 acceptable clauses in the no text')
예제 #4
0
 def test(self):
     DTEULAAPP.loadmodels()
     results = DTEULAAPP.processClauseText(clausetext1, 'text')
     self.assertEqual(len(results), 18,
                      'There are 18 results of processing plain text')
     accs = sum(1 for curresult in results
                if curresult['classification'] == 'Acceptable')
     self.assertEqual(accs, 16,
                      'There are 16 acceptable clauses in the plain text')
예제 #5
0
 def test(self):
     DTEULAAPP.loadmodels()
     theclauses = DTEULAAPP.extractClauses(clausetext1)
     matches = [
         DTEULAAPP.dicesearch(curclause, DTEULAAPP.accsearch)
         for curclause in theclauses
     ]
     self.assertEqual(len(matches), 22, 'There are 22 matches')
     self.assertEqual(
         len(matches[0]), 83,
         'The first clause matched a known acceptable clause of 83 characters in length'
     )
예제 #6
0
 def test(self):
     DTEULAAPP.loadmodels()
     resourcefolder = helpers.getresourcefolder()
     wordPath = os.path.join(resourcefolder, 'sample_eula_1.docx')
     curdata = ''
     with open(wordPath, 'rb') as curfile:
         curdata = base64.b64encode(curfile.read()).decode()
     results = DTEULAAPP.processClauseText(curdata, 'word')
     self.assertEqual(len(results), 140,
                      'There are 140 results of processing Word text')
     accs = sum(1 for curresult in results
                if curresult['classification'] == 'Acceptable')
     self.assertEqual(accs, 139,
                      'There are 139 acceptable clauses in the Word text')
예제 #7
0
def main():  # type: () -> None
    leParser = argparse.ArgumentParser()
    leParser.add_argument('--operation',
                          help='What do you want to do? (app|batch)')
    leParser.add_argument(
        '--input',
        help=
        'Where should eulaapp look for files? (folder with .txt, .docx, .pdf files)'
    )
    leParser.add_argument('--output',
                          help='Where should eulaapp write results? (.json)')
    lesArgs = leParser.parse_args()
    if not hasattr(lesArgs, 'operation') or lesArgs.operation is None:
        logging.error('dteulaapp needs to know what to do')
        leParser.print_help()
        sys.exit(2)
    if lesArgs.operation == 'app':
        app = create_app()
        app.run(debug=True)
    elif lesArgs.operation == 'batch':
        if not hasattr(lesArgs, 'input') or lesArgs.input is None:
            logging.error(
                'dteulaapp needs to know where to find files to process')
            leParser.print_help()
            sys.exit(2)
        if not os.path.isdir(lesArgs.input):
            logging.error(lesArgs.input +
                          ' doesn\'t seem to be a folder on your computer.')
            leParser.print_help()
            sys.exit(2)
        if not hasattr(lesArgs, 'output') or lesArgs.output is None:
            logging.error('dteulaapp needs to know where to write results')
            leParser.print_help()
            sys.exit(2)
        EULACORE.loadmodels()
        EULACORE.batch(lesArgs.input, lesArgs.output)