File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ [submodule "AZ-GAG-dataset "]
2+ path = AZ-GAG-dataset
3+ url = https://github.com/AZ-GAG/AZ-GAG-dataset.git
Original file line number Diff line number Diff line change 1+ import readline from 'readline'
2+ import getGag from './lib.js'
3+
4+ const rl = readline . createInterface ( {
5+ input : process . stdin ,
6+ output : process . stdout ,
7+ terminal : process . stdin . isTTY ,
8+ } ) ;
9+
10+ let [ question , answer ] = getGag ( ) ;
11+ let isWaiting = false ;
12+
13+ process . stdout . write ( '\u001b[2J\u001b[0;0f' ) ;
14+ console . log ( `질문: ${ question } ` ) ;
15+
16+ rl . on ( 'line' , ( line ) => {
17+ if ( isWaiting )
18+ return ;
19+ console . log ( `정답: ${ answer } ` ) ;
20+ ( [ question , answer ] = getGag ( ) ) ;
21+ isWaiting = true ;
22+ setTimeout ( ( ) => {
23+ process . stdout . write ( '\u001b[2J\u001b[0;0f' ) ;
24+ console . log ( `질문: ${ question } ` ) ;
25+ isWaiting = false ;
26+ } , 1000 ) ;
27+ } ) ;
28+
29+ rl . on ( 'close' , ( ) => {
30+ console . log ( `정답: ${ answer } ` ) ;
31+ } ) ;
Original file line number Diff line number Diff line change 1+ import { readFileSync } from "fs" ;
2+ import assert from "assert" ;
3+
4+ /**
5+ * @type {[a: string, answer: string][] }
6+ */
7+ const dataset = ( ( ) => {
8+ const question = readFileSync ( "./AZ-GAG-dataset/question.csv" ) . toString ( ) . split ( "\n" ) . filter ( ( line ) => line ) ;
9+ const answer = readFileSync ( "./AZ-GAG-dataset/answer.csv" ) . toString ( ) . split ( "\n" ) . filter ( ( line ) => line ) ;
10+ assert ( question . length === answer . length ) ;
11+ return question . map ( ( _ , i ) => [ question [ i ] , answer [ i ] ] ) ;
12+ } ) ( ) ;
13+
14+ /**
15+ * @returns {[question: string, answer: string] } random AZGag
16+ */
17+ export default function AZGagGenerator ( ) {
18+ return dataset [ Math . floor ( Math . random ( ) * dataset . length ) ] ;
19+ } ;
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " az-generator" ,
3+ "organizations" : " AZ-GAG" ,
4+ "version" : " 0.0.0" ,
5+ "description" : " generates az-gag" ,
6+ "main" : " index.js" ,
7+ "type" : " module" ,
8+ "scripts" : {
9+ "test" : " echo \" Error: no test specified\" && exit 1"
10+ },
11+ "repository" : {
12+ "type" : " git" ,
13+ "url" : " git+https://github.com/AZ-GAG/AZ-generator.git"
14+ },
15+ "keywords" : [
16+ " az-gag" ,
17+ " comedy" ,
18+ " generator"
19+ ],
20+ "author" : " AZ-GAG" ,
21+ "contributors" : [
22+ " Kwanho Kim <kwanho0096@gmail.com> (https://github.com/KKWANH)" ,
23+ " YeonSeong-Lee <yeonseong.dev@gmail.com> (https://github.com/YeonSeong-Lee)" ,
24+ " Minjae Kim <hjn966@naver.com> (https://github.com/minjae9610)" ,
25+ " Juyeong Maing <mjy9088@naver.com> (https://github.com/mjy9088)"
26+ ],
27+ "license" : " MIT" ,
28+ "bugs" : {
29+ "url" : " https://github.com/AZ-GAG/AZ-generator/issues"
30+ },
31+ "homepage" : " https://github.com/AZ-GAG/AZ-generator#readme"
32+ }
You can’t perform that action at this time.
0 commit comments