chengjie 3 місяців тому
батько
коміт
7af375a606
1 змінених файлів з 18 додано та 18 видалено
  1. 18 18
      src/test/build.test.js

+ 18 - 18
src/test/build.test.js

@@ -7,7 +7,7 @@ async function runScript(){
7 7
     try {
8 8
         
9 9
         //按照高频单词的使用频率排序,列出所有单词
10
-        const sql="select * from Words where BookID=110 and (TranslateEng is null or TranslateEng='') order by ID;"
10
+        const sql="select * from Words where BookID=110 and (EnglishExplanation is null or EnglishExplanation='') order by ID;"
11 11
         let list = await commonModel.RunSql(null,sql);
12 12
         let count=list.length;
13 13
 
@@ -25,24 +25,24 @@ async function runScript(){
25 25
             const word=item.Word;
26 26
 
27 27
             let content={
28
-                "instruction": "用单词"+word+"生成英英翻译",
28
+                "instruction": "Generate an English-English explanation using the word '" + word + "'",
29 29
                 "requirements": [
30
-                    "中国学生学习英文使用",
31
-                    "如果有多个含义,生成一到三个最常用的不同翻译",
32
-                    "每个翻译前面要有词性(可以多个词性)",
33
-                    "尽量用A1、A2单词作为翻译的单词",
34
-                    "格式要求是JSON格式,完全遵循output_format样例格式,另外生成不要有重复“\"”",
35
-                    "如果有多个方案,直接给最好的"
30
+                    "For Chinese students learning English",
31
+                    "If the word has multiple meanings, generate one to three of the most common English-English explanations",
32
+                    "Each explanation should be preceded by the part of speech (multiple parts of speech are allowed)",
33
+                    "Try to use A1 or A2 level vocabulary for the English-English explanations",
34
+                    "The format must be JSON, strictly following the sample output_format, and avoid duplicate quotation marks ('\"')"
36 35
                 ],
37
-                "output_format":{
38
-                    "word":"spring",
39
-                    "Translate": [
40
-                        'n. the season of the year between winter and summer, lasting from March to June north of the equator, and from September to December south of the equator, when the weather becomes warmer, leaves and plants start to grow again and flowers appear',
41
-                        'n. a piece of curved or bent metal that can be pressed into a smaller space but then returns to its usual shape',
42
-                        'n. a place where water naturally flows out from the ground'
36
+                "output_format": {
37
+                    "Word": "spring",
38
+                    "EnglishExplanation": [
39
+                        "n. the season of the year between winter and summer, lasting from March to June north of the equator, and from September to December south of the equator, when the weather becomes warmer, leaves and plants start to grow again and flowers appear",
40
+                        "n. a piece of curved or bent metal that can be pressed into a smaller space but then returns to its usual shape",
41
+                        "n. a place where water naturally flows out from the ground"
43 42
                     ]
44 43
                 }
45
-            };
44
+            }
45
+
46 46
             content=JSON.stringify(content);
47 47
             //console.log(content);
48 48
 
@@ -52,7 +52,7 @@ async function runScript(){
52 52
             //生成例句
53 53
             let result = await aiController.generateArticle(content, aiProvider);
54 54
             
55
-            console.log("result1:"+result);
55
+            //console.log("result1:"+result);
56 56
             //console.log(result.indexOf("{")); 
57 57
             if (result.indexOf("```json")>0){
58 58
                 console.log("```json");
@@ -67,7 +67,7 @@ async function runScript(){
67 67
                 result=result.substring(result.indexOf("```")+3);
68 68
                 result=result.substring(0,result.lastIndexOf("```"));
69 69
             }
70
-            console.log("result2:"+result);
70
+            //console.log("result2:"+result);
71 71
 
72 72
             result=result.replace("\"\":","\":");
73 73
             result=result.replace("\"\" :","\" :");
@@ -86,7 +86,7 @@ async function runScript(){
86 86
 
87 87
             
88 88
             //console.log(result); 
89
-            let sql2="update Words set TranslateEng=? where ID="+item.ID+";";
89
+            let sql2="update Words set EnglishExplanation=? where ID="+item.ID+";";
90 90
             await commonModel.RunSql(result,sql2);
91 91
             
92 92
             console.log( i +"/"+ list.length+" "+word);