POC-English-NoAmb tests 2018-10-03

Connector identificators changed (2018-09-26): C01 ⇒ B/AB/AAB...
.dict file format updated to Link Grammar 5.5.1 -- Local ULL-DEV environment.

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/POC-English-NoAmb-2018-10-03/
This notebook is shared as static html via
http://langlearn.singularitynet.io/data/clustering_2018/html/POC-English-NoAmb-2018-10-03.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)
from src.grammar_learner.utl import UTC
from src.grammar_learner.read_files import check_dir
from src.grammar_learner.widgets import html_table
from src.grammar_learner.pqa_table import table_row  # updated, incl. silhouette index
from src.grammar_learner.write_files import list2file
tmpath = module_path + '/tmp/'
check_dir(tmpath, True, 'none')
table = []
long_table = []
header = ['Line','Corpus','Parsing','LW','RW','Gen.','Space','Rules','Silhouette','PA','PQ']
start = time.time()
print(UTC(), ':: module_path =', module_path)
2018-10-03 17:11:06 UTC :: module_path = /home/obaskov/py/language-learning

Grammar Learner corpus-specific parameters

In [2]:
corpus = 'POC-English-NoAmb'
out_dir = module_path + '/output/'+ corpus + '-' + 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       ,
    'word_space'    :   'vectors'   ,
    'cluster_range' :   (50,2,9)    ,   # (2,30,1,5) - 5 is not enough
    'clustering'    :   ('kmeans', 'kmeans++', 18),
    'tmpath'        :   tmpath      , 
    'verbose'       :   'max'       ,
    'template_path' :   'poc-turtle',
    'linkage_limit' :   1000         ,
    'categories_generalization': 'off' }
lines = [
    [14, 'POC-English-NoAmb', 'MST-fixed-manually'              ,'LW','.', 'none' ],
    [15, 'POC-English-NoAmb', 'MST-fixed-manually'              , 0  , 0 , 'none' ],
    [16, 'POC-English-NoAmb', 'LG-English'                      ,'LW','.', 'none' ],
    [17, 'POC-English-NoAmb', 'LG-English'                      , 0  , 0 , 'none' ],
    [18, 'POC-English-NoAmb', 'R=6-Weight=6:R-mst-weight=+1:R'  ,'LW','.', 'none' ],
    [19, 'POC-English-NoAmb', 'R=6-Weight=6:R-mst-weight=+1:R'  , 0  , 0 , 'none' ],
    [20, 'POC-English-NoAmb', 'R=6-Weight=1-mst-weight=+1:R'    ,'LW','.', 'none' ], 
    [21, 'POC-English-NoAmb', 'R=6-Weight=1-mst-weight=+1:R'    , 0  , 0 , 'none' ], 
    [22, 'POC-English-NoAmb', 'LG-ANY-mst-weight=+1:R'          ,'LW','.', 'none' ],
    [23, 'POC-English-NoAmb', 'LG-ANY-mst-weight=+1:R'          , 0  , 0 , 'none' ]]
# cp,rp :: (test) corpus_path and reference_path
cp = module_path + '/data/POC-English-NoAmb/poc_english_noamb_corpus.txt'
rp = module_path + '/data/POC-English-NoAmb/poc-english_noAmb-parses-gold.txt'
#cp = rp  # July 2018 Grammar Tester option

ULL Project Plan ⇒ Parses Backup ⇒ lines 14-23

Connectors-DRK-Connectors

In [3]:
%%capture
kwargs['context'] = 1
kwargs['word_space'] = 'vectors'
kwargs['clustering'] = ('kmeans','kmeans++',18)
#kwargs['cluster_range'] = (50,2,9)  # thorough clustering search for max silhouette index
kwargs['grammar_rules'] = 1
average21, long21 = table_row(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average21)
long_table.extend(long21)
In [4]:
display(html_table([header]+average21))
LineCorpusParsingLWRWGen.SpaceRulesSilhouettePAPQ
14POC-English-NoAmbMST-fixed-manuallyLW . nonecDRKc100.4564%55%
15POC-English-NoAmbMST-fixed-manually -- -- nonecDRKc80.5172%64%
16POC-English-NoAmbLG-EnglishLW . nonecDRKc130.5268%55%
17POC-English-NoAmbLG-English -- -- nonecDRKc110.5875%64%
18POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:RLW . nonecDRKc100.4492%56%
19POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc90.4999%65%
20POC-English-NoAmbR=6-Weight=1-mst-weight=+1:RLW . nonecDRKc240.1690%60%
21POC-English-NoAmbR=6-Weight=1-mst-weight=+1:R -- -- nonecDRKc220.1890%55%
22POC-English-NoAmbLG-ANY-mst-weight=+1:RLW . nonecDRKc100.4498%64%
23POC-English-NoAmbLG-ANY-mst-weight=+1:R -- -- nonecDRKc90.4899%65%

Connectors-DRK-Disjuncts

In [5]:
%%capture
kwargs['grammar_rules'] = 2
average22, long22 = table_row(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average22)
long_table.extend(long22)
In [6]:
display(html_table([header]+average22))
LineCorpusParsingLWRWGen.SpaceRulesSilhouettePAPQ
14POC-English-NoAmbMST-fixed-manuallyLW . nonecDRKd100.450%0%
15POC-English-NoAmbMST-fixed-manually -- -- nonecDRKd80.51100%100%
16POC-English-NoAmbLG-EnglishLW . nonecDRKd120.520%0%
17POC-English-NoAmbLG-English -- -- nonecDRKd110.5846%39%
18POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:RLW . nonecDRKd100.4493%56%
19POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd90.49100%66%
20POC-English-NoAmbR=6-Weight=1-mst-weight=+1:RLW . nonecDRKd240.1670%46%
21POC-English-NoAmbR=6-Weight=1-mst-weight=+1:R -- -- nonecDRKd210.1881%57%
22POC-English-NoAmbLG-ANY-mst-weight=+1:RLW . nonecDRKd110.4495%58%
23POC-English-NoAmbLG-ANY-mst-weight=+1:R -- -- nonecDRKd90.48100%60%

Disjuncts-DRK-Disjuncts

In [7]:
%%capture
kwargs['context'] = 2
average23, long23 = table_row(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average23)
long_table.extend(long23)
In [8]:
display(html_table([header]+average23))
LineCorpusParsingLWRWGen.SpaceRulesSilhouettePAPQ
14POC-English-NoAmbMST-fixed-manuallyLW . nonedDRKd130.520%0%
15POC-English-NoAmbMST-fixed-manually -- -- nonedDRKd110.5862%56%
16POC-English-NoAmbLG-EnglishLW . nonedDRKd140.50%0%
17POC-English-NoAmbLG-English -- -- nonedDRKd120.5646%39%
18POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:RLW . nonedDRKd110.38100%68%
19POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd120.46100%68%
20POC-English-NoAmbR=6-Weight=1-mst-weight=+1:RLW . nonedDRKd270.5165%40%
21POC-English-NoAmbR=6-Weight=1-mst-weight=+1:R -- -- nonedDRKd100.4189%57%
22POC-English-NoAmbLG-ANY-mst-weight=+1:RLW . nonedDRKd100.3797%62%
23POC-English-NoAmbLG-ANY-mst-weight=+1:R -- -- nonedDRKd100.4598%62%

Disjuncts-ILE-Disjuncts

In [9]:
%%capture
kwargs['word_space'] = 'discrete'
kwargs['clustering'] = 'group'
average24, long24 = table_row(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average24)
long_table.extend(long24)
In [10]:
display(html_table([header]+average24))
LineCorpusParsingLWRWGen.SpaceRulesSilhouettePAPQ
14POC-English-NoAmbMST-fixed-manuallyLW . nonedILEd15---0%0%
15POC-English-NoAmbMST-fixed-manually -- -- nonedILEd13---46%39%
16POC-English-NoAmbLG-EnglishLW . nonedILEd15---0%0%
17POC-English-NoAmbLG-English -- -- nonedILEd13---46%39%
18POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:RLW . nonedILEd16---93%58%
19POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd14---100%68%
20POC-English-NoAmbR=6-Weight=1-mst-weight=+1:RLW . nonedILEd44---63%39%
21POC-English-NoAmbR=6-Weight=1-mst-weight=+1:R -- -- nonedILEd42---72%50%
22POC-English-NoAmbLG-ANY-mst-weight=+1:RLW . nonedILEd16---94%58%
23POC-English-NoAmbLG-ANY-mst-weight=+1:R -- -- nonedILEd14---97%62%

All tests (all entries for multi-test runs > (1.1))

In [11]:
display(html_table([header]+long_table))
LineCorpusParsingLWRWGen.SpaceRulesSilhouettePAPQ
14POC-English-NoAmbMST-fixed-manuallyLW . nonecDRKc 10 0.4564%55%
15POC-English-NoAmbMST-fixed-manually -- -- nonecDRKc 8 0.5172%64%
16POC-English-NoAmbLG-EnglishLW . nonecDRKc 13 0.5268%55%
17POC-English-NoAmbLG-English -- -- nonecDRKc 11 0.5875%64%
18POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:RLW . nonecDRKc 10 0.4492%56%
19POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc 9 0.4999%65%
20POC-English-NoAmbR=6-Weight=1-mst-weight=+1:RLW . nonecDRKc 24 0.1690%60%
21POC-English-NoAmbR=6-Weight=1-mst-weight=+1:R -- -- nonecDRKc 22 0.1890%55%
22POC-English-NoAmbLG-ANY-mst-weight=+1:RLW . nonecDRKc 10 0.4498%64%
23POC-English-NoAmbLG-ANY-mst-weight=+1:R -- -- nonecDRKc 9 0.4899%65%
14POC-English-NoAmbMST-fixed-manuallyLW . nonecDRKd 10 0.450%0%
15POC-English-NoAmbMST-fixed-manually -- -- nonecDRKd 8 0.51100%100%
16POC-English-NoAmbLG-EnglishLW . nonecDRKd 12 0.520%0%
17POC-English-NoAmbLG-English -- -- nonecDRKd 11 0.5846%39%
18POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:RLW . nonecDRKd 10 0.4493%56%
19POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd 9 0.49100%66%
20POC-English-NoAmbR=6-Weight=1-mst-weight=+1:RLW . nonecDRKd 24 0.1670%46%
21POC-English-NoAmbR=6-Weight=1-mst-weight=+1:R -- -- nonecDRKd 21 0.1881%57%
22POC-English-NoAmbLG-ANY-mst-weight=+1:RLW . nonecDRKd 11 0.4495%58%
23POC-English-NoAmbLG-ANY-mst-weight=+1:R -- -- nonecDRKd 9 0.48100%60%
14POC-English-NoAmbMST-fixed-manuallyLW . nonedDRKd 13 0.520%0%
15POC-English-NoAmbMST-fixed-manually -- -- nonedDRKd 11 0.5862%56%
16POC-English-NoAmbLG-EnglishLW . nonedDRKd 14 0.50%0%
17POC-English-NoAmbLG-English -- -- nonedDRKd 12 0.5646%39%
18POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:RLW . nonedDRKd 11 0.38100%68%
19POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd 12 0.46100%68%
20POC-English-NoAmbR=6-Weight=1-mst-weight=+1:RLW . nonedDRKd 27 0.5165%40%
21POC-English-NoAmbR=6-Weight=1-mst-weight=+1:R -- -- nonedDRKd 10 0.4189%57%
22POC-English-NoAmbLG-ANY-mst-weight=+1:RLW . nonedDRKd 10 0.3797%62%
23POC-English-NoAmbLG-ANY-mst-weight=+1:R -- -- nonedDRKd 10 0.4598%62%
14POC-English-NoAmbMST-fixed-manuallyLW . nonedILEd 15 --- 0%0%
15POC-English-NoAmbMST-fixed-manually -- -- nonedILEd 13 --- 46%39%
16POC-English-NoAmbLG-EnglishLW . nonedILEd 15 --- 0%0%
17POC-English-NoAmbLG-English -- -- nonedILEd 13 --- 46%39%
18POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:RLW . nonedILEd 16 --- 93%58%
19POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd 14 --- 100%68%
20POC-English-NoAmbR=6-Weight=1-mst-weight=+1:RLW . nonedILEd 44 --- 63%39%
21POC-English-NoAmbR=6-Weight=1-mst-weight=+1:R -- -- nonedILEd 42 --- 72%50%
22POC-English-NoAmbLG-ANY-mst-weight=+1:RLW . nonedILEd 16 --- 94%58%
23POC-English-NoAmbLG-ANY-mst-weight=+1:R -- -- nonedILEd 14 --- 97%62%
In [12]:
print(UTC(), ':: finished, elapsed', str(round((time.time()-start)/60, 1)), 'min')
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-10-03 17:35:20 UTC :: finished, elapsed 24.2 min
Results saved to /home/obaskov/py/language-learning/output/POC-English-NoAmb-2018-10-03/short_table.txt