Rigorous and Reliable (RAR)

Full Version: BIBO -- O
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9
(09-03-2020 11:53 PM)lingu Wrote: [ -> ]insert (){
# if "type":"insert"
casetype=`jq '.type' $newcasepfn`
if [[ $casetype == "\"insert\"" ]]; then
newdir=$(ls /thinker/globe/udata/lingu/testy/procuratorate/tests/typical | wc -l)

such logic is quite error-prone because w dont know who may write something to the dir 'typical'.

I suggest we change it to use casecnt.
Code:
newdir=/thinker/globe/udata/lingu/testy/procuratorate/tests/typical/$((++casecnt))

Quote: mkdir $newdir
casecnt=$((++newdir))

no need to do ++ here and the assignment because the code above already handles both.

RR zhihao

--- working practively, I have implemented the above in cod://yotta commit fae4fb1
I am deleting the trash cases 11-200.

save a copy first.
Code:
21:09:59 lingu@g1b-2:/home/lingu/forest/prada/prada> cd /thinker/globe/udata/lingu/testy/procuratorate/tests/typical
21:14:17 lingu@g1b-2:/thinker/globe/udata/lingu/testy/procuratorate/tests/typical> ls
0    107  116  125  134  143  152  161  170  18   189  198  26  35  44  53  62  71  80  9   99
1    108  117  126  135  144  153  162  171  180  19   199  27  36  45  54  63  72  81  90
10   109  118  127  136  145  154  163  172  181  190  2    28  37  46  55  64  73  82  91
100  11   119  128  137  146  155  164  173  182  191  20   29  38  47  56  65  74  83  92
101  110  12   129  138  147  156  165  174  183  192  200  3   39  48  57  66  75  84  93
102  111  120  13   139  148  157  166  175  184  193  21   30  4   49  58  67  76  85  94
103  112  121  130  14   149  158  167  176  185  194  22   31  40  5   59  68  77  86  95
104  113  122  131  140  15   159  168  177  186  195  23   32  41  50  6   69  78  87  96
105  114  123  132  141  150  16   169  178  187  196  24   33  42  51  60  7   79  88  97
106  115  124  133  142  151  160  17   179  188  197  25   34  43  52  61  70  8   89  98
21:14:18 lingu@g1b-2:/thinker/globe/udata/lingu/testy/procuratorate/tests/typical> mkdir -p /thinker/globe/udata/lingu/testy/shed/20200922
21:15:05 lingu@g1b-2:/thinker/globe/udata/lingu/testy/procuratorate/tests/typical> cd ..
21:15:24 lingu@g1b-2:/thinker/globe/udata/lingu/testy/procuratorate/tests> rsync -arv typical /thinker/globe/udata/lingu/testy/shed/20200922/
...
typical/95/
typical/95/insert.json
typical/95/insert.json1
typical/95/insert.json~
typical/96/
typical/96/insert.json
typical/96/insert.json1
typical/96/insert.json~
typical/97/
typical/97/insert.json
typical/97/insert.json1
typical/97/insert.json~
typical/98/
typical/98/insert.json
typical/98/insert.json1
typical/98/insert.json~
typical/99/
typical/99/insert.json
typical/99/insert.json1
typical/99/insert.json~

sent 3799548 bytes  received 12120 bytes  124972.72 bytes/sec
total size is 3760682  speedup is 0.99
21:16:18 lingu@g1b-2:/thinker/globe/udata/lingu/testy/procuratorate/tests>

Remove trash files.
Code:
21:17:23 lingu@g1b-2:/thinker/globe/udata/lingu/testy/procuratorate/tests/typical> rm -rf 1[1-9] [2
-9]? 1??
21:18:13 lingu@g1b-2:/thinker/globe/udata/lingu/testy/procuratorate/tests/typical> ls
0  1  10  2  200  3  4  5  6  7  8  9
21:18:16 lingu@g1b-2:/thinker/globe/udata/lingu/testy/procuratorate/tests/typical> rm -rf 200
rm: cannot remove '200/insert.json1': Permission denied
rm: cannot remove '200/insert.json': Permission denied
rm: cannot remove '200/insert.json~': Permission denied
21:18:19 lingu@g1b-2:/thinker/globe/udata/lingu/testy/procuratorate/tests/typical> sudo rm -rf 200
[sudo] password for lingu:

Adjust the value of bibo_doc_cnt.
Code:
[root@g1b-2 typical]# echo "bibo_doc_cnt: 10" > /thinker/globe/soft/bibo/bibo-ext.pcf
[root@g1b-2 typical]# chmod 777 /thinker/globe/soft/bibo/bibo-ext.pcf
[root@g1b-2 typical]# cat /thinker/globe/soft/bibo/bibo-ext.pcf
bibo_doc_cnt: 10
[root@g1b-2 typical]#

zhihao

(09-03-2020 11:53 PM)lingu Wrote: [ -> ]talk2thinker.sh
Code:
读取一个案例请求,保存到$toneroot/newreeq文件,执行tellThinker, getresults函数
...
...
  /bin/cp $reqpfn $newcasepfn
  flog_enable_timestamp=True flog "    received new case in $newcasepfn"

insert (){
  # if "type":"insert"
  casetype=`jq '.type' $newcasepfn`
  if [[ $casetype == "\"insert\"" ]]; then
    newdir=$(ls /thinker/globe/udata/lingu/testy/procuratorate/tests/typical | wc -l)
    mkdir $newdir
    casecnt=$((++newdir))
    cp $newcasepfn $newdir/insert.json

    echo -e "{\n\
    "code": 200,\n\
    "msg": "ok",\n\
    "children": []\n\
    }"
    exit 0
  fi
}

修改首文talk2thinker.sh的伪代码部分为:
Code:
function work; do
    while $newcasepfn is not null; do
        read $newcasepfn
    done

    funtion tellThinker; do
        set $casecnt as the number of cases
        create a new directory $newdir, set its name as $casecnt + 1
        copy $newcasepfn to $newdir
        
        for each case; do
            analyse cases with sage
        done
    done

    function getresults; do
        function scrutinize:
            generate response for each case
        generate response for all cases
        return response
    done
done

RR lingu

zhihao

(09-22-2020 09:56 PM)lingu Wrote: [ -> ]
(09-03-2020 11:53 PM)lingu Wrote: [ -> ]insert (){
# if "type":"insert"
casetype=`jq '.type' $newcasepfn`
if [[ $casetype == "\"insert\"" ]]; then
newdir=$(ls /thinker/globe/udata/lingu/testy/procuratorate/tests/typical | wc -l)

such logic is quite error-prone because w dont know who may write something to the dir 'typical'.

I suggest we change it to use casecnt.
Code:
newdir=/thinker/globe/udata/lingu/testy/procuratorate/tests/typical/$((++casecnt))

Quote: mkdir $newdir
casecnt=$((++newdir))

no need to do ++ here and the assignment because the code above already handles both.

RR zhihao

--- working practively, I have implemented the above in cod://yotta commit fae4fb1

LGTM

zhihao

(09-22-2020 09:41 PM)lingu Wrote: [ -> ]driver: we need handle case count well for the bibo system.

(09-03-2020 11:53 PM)lingu Wrote: [ -> ]talk2thinker.sh

读取一个案例请求,保存到$toneroot/newreeq文件,执行tellThinker, getresults函数
...
...

If we have vars in bibo-ext.pcf -- http://rar.shufangkeji.com:60380/showthr...4#pid43444 I suggest we read case count here.
Code:
casecnt = use the pcf program to read bibo_doc_cnt in $bibo_base/bibo-ext.pcf

Quote:
/bin/cp $reqpfn $newcasepfn
flog_enable_timestamp=True flog " received new case in $newcasepfn"

insert (){
# if "type":"insert"
casetype=`jq '.type' $newcasepfn`
if [[ $casetype == "\"insert\"" ]]; then
newdir=$(ls /thinker/globe/udata/lingu/testy/procuratorate/tests/typical | wc -l)
mkdir $newdir
casecnt=$((++newdir))

We need update the case count here.
Code:
use the pcf program to write bibo_doc_cnt as casecnt in $bibo_base/bibo-ext.pcf

RR zhihao

--- working proactively. I added the logic in cod://prada commit 7b8c391

A simple test of pcf shows the functionality of pcf works as expected.
Code:
20:35:08 lingu@g1b-2:/home/lingu/forest/prada/prada> pcf --pcf /thinker/globe/soft/bibo/bibo-ext.pcf --get bibo_doc_cnt
10
20:49:09 lingu@g1b-2:/home/lingu/forest/prada/prada> pcf --pcf /thinker/globe/soft/bibo/bibo-ext.pcf --add bibo_doc_cnt 11
20:49:27 lingu@g1b-2:/home/lingu/forest/prada/prada> pcf --pcf /thinker/globe/soft/bibo/bibo-ext.pcf --get bibo_doc_cnt
11
20:49:29 lingu@g1b-2:/home/lingu/forest/prada/prada>

LGTM
(09-23-2020 12:39 AM)zhihao Wrote: [ -> ]
(09-03-2020 11:53 PM)lingu Wrote: [ -> ]talk2thinker.sh
Code:
读取一个案例请求,保存到$toneroot/newreeq文件,执行tellThinker, getresults函数
...
...
  /bin/cp $reqpfn $newcasepfn
  flog_enable_timestamp=True flog "    received new case in $newcasepfn"

insert (){
  # if "type":"insert"
  casetype=`jq '.type' $newcasepfn`
  if [[ $casetype == "\"insert\"" ]]; then
    newdir=$(ls /thinker/globe/udata/lingu/testy/procuratorate/tests/typical | wc -l)
    mkdir $newdir
    casecnt=$((++newdir))
    cp $newcasepfn $newdir/insert.json

    echo -e "{\n\
    "code": 200,\n\
    "msg": "ok",\n\
    "children": []\n\
    }"
    exit 0
  fi
}

修改首文talk2thinker.sh的伪代码部分为:

function work; do
while $newcasepfn is not null; do
read $newcasepfn
done

You need define that is 'not full'. Otherwise, we cannot translate this pseudocode into code scientifically.

Quote: funtion tellThinker; do
set $casecnt as the number of cases
create a new directory $newdir, set its name as $casecnt + 1
copy $newcasepfn to $newdir

for each case; do
analyse cases with sage
done
done

OK but pls use a separate code block for a function, unless the function is nested in another.

I also suggest you use C-style syntactic structures, such as
Code:
tellThinker() {
        set $casecnt as the number of cases
        create a new directory $newdir, set its name as $casecnt + 1
        copy $newcasepfn to $newdir
        
        for each case {
            analyse cases with sage
        }
}

The C-style representation is usually more concise.

Quote: function getresults; do
function scrutinize:
generate response for each case
generate response for all cases
return response
done
done
[/code]

RR lingu

I think they are generally better than before. So I am fine with the updates.

zhihao

(09-23-2020 01:08 AM)lingu Wrote: [ -> ]
(09-23-2020 12:39 AM)zhihao Wrote: [ -> ]
(09-03-2020 11:53 PM)lingu Wrote: [ -> ]talk2thinker.sh
Code:
读取一个案例请求,保存到$toneroot/newreeq文件,执行tellThinker, getresults函数
...
...
  /bin/cp $reqpfn $newcasepfn
  flog_enable_timestamp=True flog "    received new case in $newcasepfn"

insert (){
  # if "type":"insert"
  casetype=`jq '.type' $newcasepfn`
  if [[ $casetype == "\"insert\"" ]]; then
    newdir=$(ls /thinker/globe/udata/lingu/testy/procuratorate/tests/typical | wc -l)
    mkdir $newdir
    casecnt=$((++newdir))
    cp $newcasepfn $newdir/insert.json

    echo -e "{\n\
    "code": 200,\n\
    "msg": "ok",\n\
    "children": []\n\
    }"
    exit 0
  fi
}

修改首文talk2thinker.sh的伪代码部分为:

function work; do
while $newcasepfn is not null; do
read $newcasepfn
done

You need define that is 'not full'. Otherwise, we cannot translate this pseudocode into code scientifically.

while循环已修改为 read $newcasepfn till meet blank line

(09-23-2020 01:08 AM)lingu Wrote: [ -> ]
Quote: funtion tellThinker; do
set $casecnt as the number of cases
create a new directory $newdir, set its name as $casecnt + 1
copy $newcasepfn to $newdir

for each case; do
analyse cases with sage
done
done

OK but pls use a separate code block for a function, unless the function is nested in another.

I also suggest you use C-style syntactic structures, such as
Code:
tellThinker() {
        set $casecnt as the number of cases
        create a new directory $newdir, set its name as $casecnt + 1
        copy $newcasepfn to $newdir
        
        for each case {
            analyse cases with sage
        }
}

The C-style representation is usually more concise.

work内的函数已提取到代码块外面。
函数现已使用C结构表示。
伪代码如下:
Code:
work() {
    read $newcasepfn till meet blank line

    tellThinker()
    getresults()
}

tellThinker() {
    set $casecnt as the number of cases
    create a new directory $newdir, set its name as $casecnt + 1
    copy $newcasepfn to $newdir
    
    for each case; do
        analyse cases with sage
    done
}

getresults() {
    scrutinize() {
        generate response for each case
        }
    generate response for all cases
    return response
}


(09-23-2020 01:08 AM)lingu Wrote: [ -> ]
Quote: function getresults; do
function scrutinize:
generate response for each case
generate response for all cases
return response
done
done
[/code]

RR lingu

I think they are generally better than before. So I am fine with the updates.

已更新首文talk2thinker.sh伪代码
(09-23-2020 11:34 AM)zhihao Wrote: [ -> ]not null 已修改为 not full。work内的函数已提取到代码块外面。函数现已使用C结构表示。
已更新首文。

I have split the blocks of functions in the headpost, and added an explanation line to the functions. This will make the writing easier to read.

Quote:tellThinker() {
set $casecnt as the number of cases
create a new directory $newdir, set its name as $casecnt + 1
copy $newcasepfn to $newdir

for each case; do
analyse cases with sage
done
}

This logic needs to handle multiple types of requests -- query, insert, delete. Pls design the switching logic and use different functions to do the work.

Also, design and implement the delete logic as we discussed -- for delete, rename the original file to be a different name, create a file in the original name and make sure it does not match any keywords.

Later, we need move the logic to a C++ program so that it can communicate with think in memory-to-memory data exchange.

zhihao

(09-03-2020 11:53 PM)lingu Wrote: [ -> ]procone.py
Code:
在某一案例内容中搜索key{1,2,3},构建"keys": []。

添加procone.py 伪代码,增加删除功能
Code:
main() {
    set $tycajson_pfn as a insert.json
    get $reqtype from $tycajson_pfn
    if $reqtype is "delete"
        rename insert.json as insert2.json
        create file insert.json
    else
        generate query response
}

RR lingu

zhihao

(09-23-2020 12:14 PM)lingu Wrote: [ -> ]
Quote:tellThinker() {
set $casecnt as the number of cases
create a new directory $newdir, set its name as $casecnt + 1
copy $newcasepfn to $newdir

for each case; do
analyse cases with sage
done
}

This logic needs to handle multiple types of requests -- query, insert, delete. Pls design the switching logic and use different functions to do the work.

已加上switch逻辑
Code:
tellThinker() {
    set $casecnt as the number of cases

    switch $casetype {
        case "insert":
            create a new directory $newdir, set its name as $casecnt + 1
            copy $newcasepfn to $newdir
            generate insert success response
        case "delete":
            for each case; do
                analyse cases with sage
            done
            generate delete success response
        case "query":
            for each case; do
                analyse cases with sage
            done
            generate query result response
    }
}
RR lingu

(09-23-2020 12:14 PM)lingu Wrote: [ -> ]Also, design and implement the delete logic as we discussed -- for delete, rename the original file to be a different name, create a file in the original name and make sure it does not match any keywords.

Later, we need move the logic to a C++ program so that it can communicate with think in memory-to-memory data exchange.

删除逻辑设计在procone.py内,已在#49回复
Pages: 1 2 3 4 5 6 7 8 9
Reference URL's