Child Directed Speech test 2018-08-06 - 2018-08-09

New (2018-07-05) Grammar Tester, server 88.99.210.144
Each line is calculated 1x, parsing metrics tested 1x for each calculation.
The calculation table is shared as 'short_table.txt' in data folder
http://langlearn.singularitynet.io/data/clustering_2018/Child-Directed-Speech-2018-08-06/
This notebook is shared as static html via
http://langlearn.singularitynet.io/data/clustering_2018/html/Child-Directed-Speech-2018-08-06.html
A multi-run version of this notebook is shared via
http://langlearn.singularitynet.io/data/clustering_2018/html/Child-Directed-Speech-2018-08-06-multi.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 os.path.exists(grammar_learner_path) and 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-06 18:58:03 UTC :: module_path = /home/obaskov/language-learning

Corpus test settings

In [2]:
out_dir = module_path + '/output/Child-Directed-Speech-' + str(UTC())[:10]
runs = (1,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,3)  ,
    'cluster_criteria': 'silhouette',
    'cluster_level' :   1           ,
    'tmpath'        :   tmpath      , 
    'verbose'       :   'min'       ,
    'template_path' :   'poc-turtle',
    'linkage_limit' :   1000        ,
    'categories_generalization': 'off' }
lines = [
    [52, 'ChildDirectedSpeech' , 'LG-English'                     ,0,0, 'none'  ], 
    [53, 'ChildDirectedSpeech' , 'LG-English'                     ,0,0, 'rules' ], 
    [54, 'ChildDirectedSpeech' , 'R=6-Weight=6:R-mst-weight=+1:R' ,0,0, 'none'  ], 
    [55, 'ChildDirectedSpeech' , 'R=6-Weight=6:R-mst-weight=+1:R' ,0,0, 'rules' ]]
rp = module_path + '/data/ChildDirectedSpeech/LG-English'
cp = rp  # corpus path = reference_path :: use 'gold' parses as test corpus

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

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

Lines lines 52-55 renumbered to 58-61 2018-08-09

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
52ChildDirectedSpeechLG-English -- -- nonecDRKc9558%48%
54ChildDirectedSpeechR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc9757%41%
2018-08-07 18:13:25 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
52ChildDirectedSpeechLG-English -- -- nonecDRKd10052%46%
53ChildDirectedSpeechLG-English -- -- rulescDRKd9355%47%
54ChildDirectedSpeechR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd6255%39%
55ChildDirectedSpeechR=6-Weight=6:R-mst-weight=+1:R -- -- rulescDRKd7353%37%
2018-08-07 18:50:57 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
52ChildDirectedSpeechLG-English -- -- nonedDRKd6556%46%
53ChildDirectedSpeechLG-English -- -- rulesdDRKd10052%45%
54ChildDirectedSpeechR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd9950%35%
55ChildDirectedSpeechR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdDRKd10050%34%
2018-08-09 08:58: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
52ChildDirectedSpeechLG-English -- -- nonedILEd298039%37%
53ChildDirectedSpeechLG-English -- -- rulesdILEd242440%37%
54ChildDirectedSpeechR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd35580%0%
55ChildDirectedSpeechR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdILEd341538%28%
2018-08-09 09:08:12 UTC

All tests

In [11]:
display(html_table([header]+long_table))
LineCorpusParsingLW"."GeneralizationSpaceRulesPAPQ
52ChildDirectedSpeechLG-English -- -- nonecDRKc 95 58%48%
54ChildDirectedSpeechR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc 97 57%41%
52ChildDirectedSpeechLG-English -- -- nonecDRKd 100 52%46%
53ChildDirectedSpeechLG-English -- -- rulescDRKd 93 55%47%
54ChildDirectedSpeechR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd 62 55%39%
55ChildDirectedSpeechR=6-Weight=6:R-mst-weight=+1:R -- -- rulescDRKd 73 53%37%
52ChildDirectedSpeechLG-English -- -- nonedDRKd 65 56%46%
53ChildDirectedSpeechLG-English -- -- rulesdDRKd 100 52%45%
54ChildDirectedSpeechR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd 99 50%35%
55ChildDirectedSpeechR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdDRKd 100 50%34%
52ChildDirectedSpeechLG-English -- -- nonedILEd 2980 39%37%
53ChildDirectedSpeechLG-English -- -- rulesdILEd 2424 40%37%
54ChildDirectedSpeechR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd 3558 0%0%
55ChildDirectedSpeechR=6-Weight=6:R-mst-weight=+1:R -- -- rulesdILEd 3415 38%28%
In [13]:
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-09 09:14:13 UTC :: finished, elapsed 62.3 hours
Results saved to /home/obaskov/language-learning/output/Child-Directed-Speech-2018-08-06/short_table.txt

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