Child Directed Speech constituency test 2018-08-14 [10x]

Updated (2018-08-14) Grammar Tester, server 94.130.238.118
Each line is calculated 10x, parsing metrics tested 1x for each calculation.
This notebook is shared as static html via
http://langlearn.singularitynet.io/data/clustering_2018/html/Child-Directed-Speech-2018-08-14.html

Basic settings

In [1]:
import os, sys, time
from IPython.display import display
module_path = os.path.abspath(os.path.join('..'))
if module_path not in sys.path: sys.path.append(module_path)
grammar_learner_path = module_path + '/src/grammar_learner/'
if grammar_learner_path not in sys.path: sys.path.append(grammar_learner_path)
from utl import UTC
from read_files import check_dir
from widgets import html_table
from pqa_table import table_cds
tmpath = module_path + '/tmp/'
if check_dir(tmpath, True, 'none'):
    table = []
    long_table = []
    header = ['Line','Corpus','Parsing','LW','"."','Generalization','Space','Rules','PA','PQ']
    start = time.time()
    print(UTC(), ':: module_path =', module_path)
else: print(UTC(), ':: could not create temporary files directory', tmpath)
2018-08-14 11:10:37 UTC :: module_path = /home/obaskov/language-learning

Corpus test settings

In [2]:
out_dir = module_path + '/output/Child-Directed-Speech-' + str(UTC())[:10]
runs = (10,1)    # (attempts to learn grammar per line, grammar tests per attempt)
if runs != (1,1): out_dir += '-multi'
kwargs = {
    'left_wall'     :   ''          ,
    'period'        :   False       ,
    'clustering'    :   ('kmeans', 'kmeans++', 10),
    'cluster_range' :   (30,120,5,3), # min, max, step, repeat
    'cluster_criteria': 'silhouette',
    'cluster_level' :   1           ,
    'tmpath'        :   tmpath      , 
    'verbose'       :   'min'       ,
    'template_path' :   'poc-turtle',
    'linkage_limit' :   1000        ,
    'categories_generalization': 'off' }
lines = [
    [58, 'CDS-caps-br-text+brent9mos' , 'LG-English'                     ,0,0, 'none'  ], 
    [59, 'CDS-caps-br-text+brent9mos' , 'LG-English'                     ,0,0, 'rules' ], 
    [60, 'CDS-caps-br-text+brent9mos' , 'R=6-Weight=6:R-mst-weight=+1:R' ,0,0, 'none'  ], 
    [61, 'CDS-caps-br-text+brent9mos' , 'R=6-Weight=6:R-mst-weight=+1:R' ,0,0, 'rules' ]]
rp = module_path + '/data/CDS-caps-br-text+brent9mos/LG-English'
cp = rp  # corpus path = reference_path :: use 'gold' parses as test corpus

ULL Project Plan ⇒ Parses ⇒ lines 58-61, by columns

Connectors-DRK-Connectors

In [3]:
%%capture
kwargs['context'] = 1
kwargs['word_space'] = 'vectors'
kwargs['clustering'] = 'kmeans'
kwargs['grammar_rules'] = 1
average21, long21 = table_cds(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average21)
long_table.extend(long21)
In [4]:
display(html_table([header]+average21))
print(UTC())
LineCorpusParsingLW"."GeneralizationSpaceRulesPAPQ
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKc8071%50%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc6770%44%
2018-08-14 12:06:54 UTC

Connectors-DRK-Disjuncts

In [5]:
%%capture
kwargs['context'] = 1
kwargs['word_space'] = 'vectors'
kwargs['clustering'] = 'kmeans'
kwargs['grammar_rules'] = 2
average22, long22 = table_cds(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average22)
long_table.extend(long22)
In [6]:
display(html_table([header]+average22))
print(UTC())
LineCorpusParsingLW"."GeneralizationSpaceRulesPAPQ
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKd8264%49%
59CDS-caps-br-text+brent9mosLG-English -- -- rulescDRKd8264%49%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd6767%41%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulescDRKd6468%41%
2018-08-14 15:01:37 UTC

Disjuncts-DRK-Disjuncts

In [7]:
%%capture
kwargs['context'] = 2
kwargs['word_space'] = 'vectors'
kwargs['clustering'] = 'kmeans'
kwargs['grammar_rules'] = 2
average23, long23 = table_cds(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average23)
long_table.extend(long23)
In [8]:
display(html_table([header]+average23))
print(UTC())
LineCorpusParsingLW"."GeneralizationSpaceRulesPAPQ
58CDS-caps-br-text+brent9mosLG-English -- -- nonedDRKd7462%47%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdDRKd7263%47%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd8663%38%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdDRKd8663%38%
2018-08-14 18:09:22 UTC

Disjuncts-ILE-Disjuncts

In [9]:
%%capture
kwargs['context'] = 2
kwargs['word_space'] = 'discrete'
kwargs['clustering'] = 'group'
kwargs['grammar_rules'] = 2
average24, long24 = table_cds(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average24)
long_table.extend(long24)
In [10]:
display(html_table([header]+average24))
print(UTC())
LineCorpusParsingLW"."GeneralizationSpaceRulesPAPQ
58CDS-caps-br-text+brent9mosLG-English -- -- nonedILEd298040%37%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdILEd242441%37%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd35580%0%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdILEd341548%31%
2018-08-14 20:00:38 UTC

All tests

In [11]:
display(html_table([header]+long_table))
LineCorpusParsingLW"."GeneralizationSpaceRulesPAPQ
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKc 84 71%50%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKc 83 71%50%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKc 74 71%51%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKc 70 71%51%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKc 73 71%51%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKc 86 70%50%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKc 79 70%50%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKc 81 71%50%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKc 86 70%50%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKc 79 72%51%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc 63 70%44%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc 63 70%44%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc 68 70%44%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc 60 70%44%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc 77 70%44%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc 65 70%44%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc 64 70%44%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc 70 70%44%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc 76 70%44%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc 64 70%44%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKd 80 64%49%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKd 85 64%49%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKd 83 66%49%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKd 81 63%48%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKd 82 65%50%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKd 83 63%49%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKd 81 65%49%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKd 85 63%49%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKd 84 62%48%
58CDS-caps-br-text+brent9mosLG-English -- -- nonecDRKd 80 64%49%
59CDS-caps-br-text+brent9mosLG-English -- -- rulescDRKd 76 66%50%
59CDS-caps-br-text+brent9mosLG-English -- -- rulescDRKd 85 63%49%
59CDS-caps-br-text+brent9mosLG-English -- -- rulescDRKd 84 65%50%
59CDS-caps-br-text+brent9mosLG-English -- -- rulescDRKd 79 65%49%
59CDS-caps-br-text+brent9mosLG-English -- -- rulescDRKd 82 63%49%
59CDS-caps-br-text+brent9mosLG-English -- -- rulescDRKd 86 65%49%
59CDS-caps-br-text+brent9mosLG-English -- -- rulescDRKd 86 63%48%
59CDS-caps-br-text+brent9mosLG-English -- -- rulescDRKd 83 63%48%
59CDS-caps-br-text+brent9mosLG-English -- -- rulescDRKd 79 67%50%
59CDS-caps-br-text+brent9mosLG-English -- -- rulescDRKd 85 62%49%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd 79 65%39%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd 57 69%42%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd 65 68%41%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd 60 68%42%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd 71 67%41%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd 74 67%40%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd 56 68%42%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd 79 66%40%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd 64 68%41%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd 69 66%40%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulescDRKd 66 68%41%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulescDRKd 59 69%42%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulescDRKd 61 69%42%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulescDRKd 72 67%41%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulescDRKd 63 68%41%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulescDRKd 65 68%41%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulescDRKd 69 68%41%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulescDRKd 76 67%40%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulescDRKd 54 69%42%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulescDRKd 58 69%42%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedDRKd 83 61%46%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedDRKd 78 62%47%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedDRKd 68 62%46%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedDRKd 79 60%46%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedDRKd 57 66%48%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedDRKd 71 61%47%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedDRKd 72 63%47%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedDRKd 70 62%46%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedDRKd 86 60%46%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedDRKd 78 61%46%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdDRKd 62 66%48%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdDRKd 84 59%46%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdDRKd 82 61%46%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdDRKd 48 68%48%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdDRKd 81 62%46%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdDRKd 74 63%47%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdDRKd 81 60%46%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdDRKd 62 64%47%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdDRKd 75 62%47%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdDRKd 74 61%46%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd 85 62%37%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd 88 64%38%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd 86 64%38%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd 88 62%38%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd 87 63%38%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd 87 63%38%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd 87 64%39%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd 86 64%39%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd 85 63%39%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd 85 63%38%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdDRKd 87 63%38%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdDRKd 85 63%38%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdDRKd 87 63%38%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdDRKd 85 64%39%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdDRKd 85 62%38%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdDRKd 87 64%39%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdDRKd 88 62%37%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdDRKd 86 64%39%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdDRKd 86 64%39%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdDRKd 87 63%38%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedILEd 2980 40%37%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedILEd 2980 40%37%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedILEd 2980 40%37%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedILEd 2980 40%37%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedILEd 2980 40%37%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedILEd 2980 40%37%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedILEd 2980 40%37%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedILEd 2980 40%37%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedILEd 2980 40%37%
58CDS-caps-br-text+brent9mosLG-English -- -- nonedILEd 2980 40%37%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdILEd 2424 41%37%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdILEd 2424 41%37%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdILEd 2424 41%37%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdILEd 2424 41%37%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdILEd 2424 41%37%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdILEd 2424 41%37%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdILEd 2424 41%37%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdILEd 2424 41%37%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdILEd 2424 41%37%
59CDS-caps-br-text+brent9mosLG-English -- -- rulesdILEd 2424 41%37%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd 3558 0%0%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd 3558 0%0%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd 3558 0%0%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd 3558 0%0%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd 3558 0%0%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd 3558 0%0%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd 3558 0%0%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd 3558 0%0%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd 3558 0%0%
60CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd 3558 0%0%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdILEd 3415 48%31%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdILEd 3415 48%31%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdILEd 3415 48%31%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdILEd 3415 48%31%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdILEd 3415 48%31%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdILEd 3415 48%31%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdILEd 3415 48%31%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdILEd 3415 48%31%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdILEd 3415 48%31%
61CDS-caps-br-text+brent9mosR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdILEd 3415 48%31%
In [12]:
from write_files import list2file
print(UTC(), ':: finished, elapsed', str(round((time.time()-start)/3600.0, 1)), 'hours')
table_str = list2file(table, out_dir+'/short_table.txt')
if runs == (1,1):
    print('Results saved to', out_dir + '/short_table.txt')
else:
    long_table_str = list2file(long_table, out_dir+'/long_table.txt')
    print('Average results saved to', out_dir + '/short_table.txt\n'
          'Detailed results for every run saved to', out_dir + '/long_table.txt')
2018-08-14 20:00:38 UTC :: finished, elapsed 8.8 hours
Average results saved to /home/obaskov/language-learning/output/Child-Directed-Speech-2018-08-14-multi/short_table.txt
Detailed results for every run saved to /home/obaskov/language-learning/output/Child-Directed-Speech-2018-08-14-multi/long_table.txt

2018-08-05 'cluster_range': (120,30,2) ~33.4 min / server 88...
2018-08-05 'cluster_range': (30,120,5,3) ~0.7 h / server 94...