2018-12-25-beta
¶LGE-clean corpus, min_word_count = 11
; 500 clusters, varying agglomerative clustering parameters
Link Grammar 5.5.1, test_grammar
updated 2018-10-19.
This notebook is shared as static Gutenberg-Children-Books-2018-12-25.html.
Output data shared via Gutenberg-Children-Books-2018-12-25 directory.
import os, sys, time
module_path = os.path.abspath(os.path.join('..'))
if module_path not in sys.path: sys.path.append(module_path)
from src.grammar_learner.utl import UTC, test_stats
from src.grammar_learner.read_files import check_dir, check_corpus
from src.grammar_learner.write_files import list2file
from src.grammar_learner.widgets import html_table
from src.grammar_learner.pqa_table import table_rows, params, wide_rows
tmpath = module_path + '/tmp/'
check_dir(tmpath, True, 'none')
start = time.time()
runs = (1,1)
print(UTC(), ':: module_path:', module_path)
corpus = 'GCB' # 'Gutenberg-Children-Books-Caps'
# corpus = 'CDS'
dataset = 'LG-E-clean'
kwargs = {
'left_wall' : '' ,
'period' : False ,
'context' : 1 ,
'min_word_count': 11 ,
'word_space' : 'sparse' ,
'clustering' : ['agglomerative', 'ward', 'euclidean'],
'clustering_metric' : ['silhouette', 'cosine'],
'cluster_range' : 500 ,
'top_level' : 0.01 ,
'grammar_rules' : 2 ,
'max_disjuncts' : 1000000 , # off
'tmpath' : tmpath ,
'verbose' : 'log+' ,
'template_path' : 'poc-turtle',
'linkage_limit' : 1000 }
rp = module_path + '/data/' + corpus + '/LG-E-clean/GCB-LG-English-clean.ull'
# rp = module_path + '/data/' + corpus + '/LG-E-clean/CDS-LG-English-clean.ull'
cp = rp # corpus path = reference_path
runs = (1,1)
out_dir = module_path + '/output/' + 'Gutenberg-Children-var-ALE-par-' + str(UTC())[:10]
if check_corpus(rp, 'min'): print(UTC(), '\n', out_dir)
min_word_count = 2
; 500 clusters¶%%capture
table = []
kwargs['clustering'] = ['agglomerative', 'ward', 'euclidean']
line = [['1.1', corpus, dataset, 0, 0, 'none']]
a, _, header, log, rules = wide_rows(line, out_dir, cp, rp, runs, **kwargs)
header[0] = 'Cell'
table.extend(a)
display(html_table([header] + a)); print(test_stats(log))
%%capture
t2 = []
n = 2.0
for affinity in ['euclidean', 'manhattan', 'cosine']:
n = round(n + 0.1, 1)
kwargs['clustering'] = ['agglomerative', 'complete', affinity]
line = [[n, corpus, dataset, 0, 0, 'none']]
a, _, header, log, rules = wide_rows(line, out_dir, cp, rp, runs, **kwargs)
t2.extend(a)
table.extend(a)
display(html_table([header] + t2))
%%capture
t3 = []
m = 3.0
for affinity in ['euclidean', 'manhattan', 'cosine']:
n = round(n + 0.1, 1)
kwargs['clustering'] = ['agglomerative', 'average', affinity]
line = [[n, corpus, dataset, 0, 0, 'none']]
a, _, header, log, rules = wide_rows(line, out_dir, cp, rp, runs, **kwargs)
t3.extend(a)
table.extend(a)
display(html_table([header] + t3))
Grammar test for the last line (affinity = cosine
) started 2018-12-26 ~10:31 UTC, connection lost, still running
display(html_table([header] + table))
print(UTC(), ':: finished, elapsed', str(round((time.time()-start)/3600.0, 1)), 'hours')
table_str = list2file(table, out_dir + '/all_tests_table.txt')
print('Results saved to', out_dir + '/all_tests_table.txt')