ezii 0.0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ezii-client/Gemfile +6 -0
- data/ezii-client/Gemfile.lock +32 -0
- data/ezii-client/Procfile +2 -0
- data/ezii-client/README.md +16 -0
- data/ezii-client/chat.txt +1446 -0
- data/ezii-client/config.ru +1 -0
- data/ezii-client/fake.rb +5 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/functions/base_command.rb +26 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/functions/mouse_y_axis_to_3d_z_axis.rb +4 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/functions/record_audio_and_send_to_wit.rb +18 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/functions/rotate_camera_axis_using_mouse_drag.rb +37 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/functions/selection_cube.rb +35 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/gam.rb +388 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/gems.locked +75 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/gems.rb +10 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/lib/drb_server.rb +13 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/lib/mittsu_monkeypatches/box_geometry.rb +5 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/runnable.rb +20 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/shapes/cube.rb +29 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/sig/runable.rbi +9 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/test.sh +5 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/test/commands/test_move_cube.rb +18 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/test/commands/test_selection_cube.rb +31 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/test/test_command_remapping.rb +30 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/test/test_helper.rb +75 -0
- data/ezii-client/managables/services/chat-bot-integrations/chat.txt +15 -0
- data/ezii-client/managables/services/chat-bot-integrations/gems.locked +66 -0
- data/ezii-client/managables/services/chat-bot-integrations/gems.rb +18 -0
- data/ezii-client/managables/services/chat-bot-integrations/gitter_zircon.rb +644 -0
- data/ezii-client/managables/services/chat-bot-integrations/regexes.rb +240 -0
- data/ezii-client/managables/services/chat-bot-integrations/setup-mac-os-x.sh +0 -0
- data/ezii-client/managables/services/chat-bot-integrations/setup.sh +1 -0
- data/ezii-client/managables/services/chat-bot-integrations/start.sh +3 -0
- data/ezii-client/managables/services/error-inspect/simplest-log +1 -0
- data/ezii-client/managables/services/error-inspect/simplest-log-init +1 -0
- data/ezii-client/managables/services/livestream-interactive/Twitch.Tv/ascii_nebuchadnezzar +9 -0
- data/ezii-client/managables/services/livestream-interactive/Twitch.Tv/chat.txt +1 -0
- data/ezii-client/managables/services/livestream-interactive/Twitch.Tv/twitch_zircon.rb +61 -0
- data/ezii-client/managables/services/livestream-interactive/Twitch.Tv/zion_fleet.rb +198 -0
- data/ezii-client/managables/services/livestream-interactive/chat.txt +40 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/README.md +3 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/__main__.js +58 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/black-out-random-word.js +74 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-sentence.js +57 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-wikipedia-page.js +25 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-words.js +34 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/rare-enough-word.js +41 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/wikipedia-page.js +35 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/package.json +20 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/statistics/count-word.js +12 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/utils/log-to-natural-database.js +10 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/word2vec-models/test-text8-vector.bin +0 -0
- data/ezii-client/managament_interface/gems.locked +13 -0
- data/ezii-client/managament_interface/gems.rb +3 -0
- data/ezii-client/managament_interface/management_interface +4 -0
- data/ezii-client/managament_interface/runnable.rb +30 -0
- data/ezii-client/rocknrolla +1 -0
- data/ezii-client/start.sh +2 -0
- data/ezii-client/test.wav +0 -0
- data/ezii-misc/detect-intent-from-git-patch.rb +46 -0
- data/ezii-server/Gemfile +23 -0
- data/ezii-server/Gemfile.lock +84 -0
- data/ezii-server/README.md +13 -0
- data/ezii-server/config.ru +2 -0
- data/ezii-server/eezee.rb +1243 -0
- data/ezii-server/httpsprojecteulernetproblem=155.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=205.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=228.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=262.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=3.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=333.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=334.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=337.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=426.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=442.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=449.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=497.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=51.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=514.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=520.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=571.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=587.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=588.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=599.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=72.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=93.png +0 -0
- data/ezii-server/regexes +258 -0
- data/ezii-server/sample.wav +0 -0
- data/ezii.gemspec +13 -0
- metadata +132 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
Welcome, GLHF!
|
2
|
+
Your host is tmi.twitch.tv
|
3
|
+
This server is rather new
|
4
|
+
-
|
5
|
+
-
|
6
|
+
You are in a maze of twisty passages, all alike.
|
7
|
+
>
|
8
|
+
|
9
|
+
=
|
10
|
+
#rw_grim
|
11
|
+
hey
|
12
|
+
Now Playing: Eye of Terror by Wontolla -> https://prtzl.to/kbHxL6DBFy
|
13
|
+
wit.ai chat bot in training + me (manuel k.) as a human supervisor
|
14
|
+
raffle?
|
15
|
+
nice to meet u
|
16
|
+
raffle
|
17
|
+
The winner of this raffle is sillybaboy! [Follower]
|
18
|
+
The winner of this raffle is morriscodes! [Follower]
|
19
|
+
The winner of this raffle is makerblaker! [Follower]
|
20
|
+
Follower
|
21
|
+
:)
|
22
|
+
!raffle
|
23
|
+
madlads
|
24
|
+
watsapp
|
25
|
+
VoHiYo
|
26
|
+
next wit.ai model training in a minute
|
27
|
+
you say echo and you print it in the script
|
28
|
+
Now Playing: Nightmare Court - edit by Wontolla -> https://prtzl.to/BJH9aYmAUN
|
29
|
+
put it in single quotes
|
30
|
+
add cool new features
|
31
|
+
1:
|
32
|
+
2:
|
33
|
+
3:
|
34
|
+
4:
|
35
|
+
PLEASE
|
36
|
+
Wait? is ezii_tm_registerred's owner here?
|
37
|
+
yes
|
38
|
+
|
39
|
+
do they have permission? @rw_grim
|
40
|
+
PLEASE
|
@@ -0,0 +1,58 @@
|
|
1
|
+
const lib = require('lib');
|
2
|
+
const _ = require('underscore');
|
3
|
+
// const countWord = require('../statistics/count-word.js');
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Qanda question endpoint.
|
7
|
+
* @returns {object}
|
8
|
+
*/
|
9
|
+
module.exports = async (language = "en", source="wikipedia", context) => {
|
10
|
+
let randomSentenceResponse = await randomSentenceErrorProne(language, source, context);
|
11
|
+
|
12
|
+
let blackedOutDict = await lib[`${context.service.identifier}.black-out-random-word`]({sentence: randomSentenceResponse.rs.result});
|
13
|
+
let randomWordsFromArticle = await lib[`${context.service.identifier}.random-words`]({
|
14
|
+
similarTo: blackedOutDict.termNormal
|
15
|
+
});
|
16
|
+
|
17
|
+
let choices = [];
|
18
|
+
|
19
|
+
_.each(randomWordsFromArticle, (randomWord) => {
|
20
|
+
choices.push({correctAnswer: false, word: randomWord.word});
|
21
|
+
});
|
22
|
+
|
23
|
+
choices.push({correctAnswer: true, word: blackedOutDict.blackedOutWord});
|
24
|
+
|
25
|
+
choices = _.shuffle(choices);
|
26
|
+
|
27
|
+
let response = {
|
28
|
+
articleTitle: randomSentenceResponse.p.title,
|
29
|
+
wikipediaId: randomSentenceResponse.p.wikipediaId,
|
30
|
+
sentence: blackedOutDict,
|
31
|
+
choices: choices,
|
32
|
+
surroundingSentences: randomSentenceResponse.rs.surroundingSentences
|
33
|
+
};
|
34
|
+
|
35
|
+
return response;
|
36
|
+
}
|
37
|
+
|
38
|
+
async function randomSentenceErrorProne(language, source, context) {
|
39
|
+
var text;
|
40
|
+
var page;
|
41
|
+
if (source === 'wikipedia') {
|
42
|
+
page = await lib[`${context.service.identifier}.random-wikipedia-page`]({language: language});
|
43
|
+
text = page.text;
|
44
|
+
} else {
|
45
|
+
page = {title: "Random texts from scan functionality (earliest alpha lel)"}
|
46
|
+
const ocrQuery = lib.koma['ocr-query']['@dev'];
|
47
|
+
|
48
|
+
text = await ocrQuery['random-ocr-text']();
|
49
|
+
}
|
50
|
+
|
51
|
+
let randomSentence = await lib[`${context.service.identifier}.random-sentence`]({text: text});
|
52
|
+
|
53
|
+
if(randomSentence.error === true) {
|
54
|
+
return randomSentenceErrorProne(language, source, context);
|
55
|
+
} else {
|
56
|
+
return {p: page, rs: randomSentence};
|
57
|
+
}
|
58
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
const _ = require('underscore');
|
2
|
+
const nlp = require('compromise');
|
3
|
+
const lib = require('lib');
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Black out a random word in a sentence.
|
7
|
+
* @returns {object}
|
8
|
+
*/
|
9
|
+
module.exports = async (sentence = "", context) => {
|
10
|
+
let sentenceTerms = nlp(sentence).out('terms');
|
11
|
+
|
12
|
+
let sentenceDict = {
|
13
|
+
before: "",
|
14
|
+
blackedOutWord: undefined,
|
15
|
+
after: ""
|
16
|
+
};
|
17
|
+
|
18
|
+
sentenceTerms = _.filter(sentenceTerms, (term) => {
|
19
|
+
return term.normal !== "";
|
20
|
+
});
|
21
|
+
|
22
|
+
|
23
|
+
var nounIndices = [];
|
24
|
+
for(i = 0; i < sentenceTerms.length; i++) {
|
25
|
+
let term = sentenceTerms[i];
|
26
|
+
let isNoun = _.includes(term.tags, 'Noun');
|
27
|
+
let isLongerThan2Chars = term.normal.length > 2;
|
28
|
+
|
29
|
+
if(isNoun && isLongerThan2Chars) {
|
30
|
+
nounIndices.push(i);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
console.log(nounIndices);
|
35
|
+
|
36
|
+
|
37
|
+
let blackedOutIndex = _.sample(nounIndices);
|
38
|
+
|
39
|
+
console.log(blackedOutIndex);
|
40
|
+
|
41
|
+
_.each(sentenceTerms, (term, index)=> {
|
42
|
+
if(index < blackedOutIndex) {
|
43
|
+
sentenceDict.before += term.text;
|
44
|
+
|
45
|
+
if(index !== (blackedOutIndex - 1)) {
|
46
|
+
sentenceDict.before += " ";
|
47
|
+
}
|
48
|
+
} else if(index > blackedOutIndex) {
|
49
|
+
sentenceDict.after += term.text;
|
50
|
+
|
51
|
+
if((sentenceTerms.length - 1) !== index) {
|
52
|
+
sentenceDict.after += " ";
|
53
|
+
}
|
54
|
+
} else if(index === blackedOutIndex) {
|
55
|
+
var termText = term.text;
|
56
|
+
|
57
|
+
let specialCharsCharacterClass = '[,\\.\\?!()\\-\\–\/"\\s;:*]';
|
58
|
+
let nonWordCharsRegex = new RegExp(`^(${specialCharsCharacterClass}*)(.+?)(${specialCharsCharacterClass}*)$`);
|
59
|
+
let matchResult = nonWordCharsRegex.exec(termText);
|
60
|
+
|
61
|
+
sentenceDict.termNormal = term.normal;
|
62
|
+
sentenceDict.tags = term.tags;
|
63
|
+
sentenceDict.before += matchResult[1];
|
64
|
+
sentenceDict.blackedOutWord = matchResult[2];
|
65
|
+
sentenceDict.after += matchResult[3];
|
66
|
+
}
|
67
|
+
});
|
68
|
+
|
69
|
+
return sentenceDict;
|
70
|
+
};
|
71
|
+
|
72
|
+
function getRandomInt(min, max) {
|
73
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
74
|
+
}
|
data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-sentence.js
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
const nlp = require('compromise');
|
2
|
+
const _ = require('underscore');
|
3
|
+
const lib = require('lib');
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Get a random sentence from provided text.
|
7
|
+
* @returns {object}
|
8
|
+
*/
|
9
|
+
module.exports = async (text = "", wikiPediaPageId=0, context) => {
|
10
|
+
if(wikiPediaPageId !== 0) {
|
11
|
+
page = await lib[`${context.service.identifier}.random-wikipedia-page`]({pageIds: [wikiPediaPageId]});
|
12
|
+
text = page.text;
|
13
|
+
}
|
14
|
+
|
15
|
+
var sentencesDoc = nlp(text, {allowedTags: []}).sentences();
|
16
|
+
|
17
|
+
sentences = sentencesDoc.list.map(ts => {
|
18
|
+
return ts.terms.map(t =>{
|
19
|
+
return t.text
|
20
|
+
});
|
21
|
+
});
|
22
|
+
|
23
|
+
if(sentences.length === 0) {
|
24
|
+
return {error: true, message: 'No sentences found'};
|
25
|
+
}
|
26
|
+
|
27
|
+
|
28
|
+
function calculateRandomIndex(items) {
|
29
|
+
return Math.floor(Math.random()*items.length)
|
30
|
+
}
|
31
|
+
|
32
|
+
let randomIndex = calculateRandomIndex(sentences);
|
33
|
+
let sentence = sentences[randomIndex]
|
34
|
+
let tries = 0;
|
35
|
+
while(sentence.length < 5 && tries < 5) {
|
36
|
+
randomIndex = calculateRandomIndex(sentences);
|
37
|
+
sentence = sentences[randomIndex]
|
38
|
+
tries++;
|
39
|
+
}
|
40
|
+
|
41
|
+
if(sentence.length < 5) {
|
42
|
+
return {error: true, message: 'No sentence with more than 5 words found'};
|
43
|
+
}
|
44
|
+
|
45
|
+
let sentencesBefore = [sentences[randomIndex-1].join(' ')];
|
46
|
+
let sentencesAfter = [sentences[randomIndex+1].join(' ')];
|
47
|
+
|
48
|
+
joinedSentence = sentence.join(' ');
|
49
|
+
return {
|
50
|
+
error: false,
|
51
|
+
result: joinedSentence,
|
52
|
+
surroundingSentences: {
|
53
|
+
before: sentencesBefore,
|
54
|
+
after: sentencesAfter
|
55
|
+
}
|
56
|
+
};
|
57
|
+
};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
const axios = require('axios');
|
2
|
+
const _ = require('underscore');
|
3
|
+
const sanitizeHtml = require('sanitize-html');
|
4
|
+
const decodeHtml = require('decode-html');
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Random wikipedia article contents
|
8
|
+
* @returns {object}
|
9
|
+
*/
|
10
|
+
module.exports = async (language = 'en') => {
|
11
|
+
var apiResponse = await axios.get(randomWikipediaArticleApiEndpoint(language));
|
12
|
+
var page = _.values(apiResponse.data['query']['pages'])[0];
|
13
|
+
var response = {};
|
14
|
+
|
15
|
+
response['text'] = decodeHtml(sanitizeHtml(page['extract'], {allowedTags: []}));
|
16
|
+
response['title'] = page['title'];
|
17
|
+
response['wikipediaId'] = page['pageid'];
|
18
|
+
|
19
|
+
return response;
|
20
|
+
};
|
21
|
+
|
22
|
+
function randomWikipediaArticleApiEndpoint(language) {
|
23
|
+
return `https://${language}.wikipedia.org/w/api.php?format=json&action=query&generator=random&grnnamespace=0&prop=extracts&grnlimit=1`;
|
24
|
+
//return `https://en.wikipedia.org/w/api.php?format=json&action=query&titles=World_history&grnnamespace=0&prop=extracts&grnlimit=1`;
|
25
|
+
}
|
data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-words.js
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
const _ = require('underscore');
|
2
|
+
const nlp = require('compromise');
|
3
|
+
const w2v = require("word2vec-pure-js")
|
4
|
+
w2v.load("./word2vec-models/test-text8-vector.bin")
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Get random words form the provided text.
|
8
|
+
* @returns {array}
|
9
|
+
*/
|
10
|
+
module.exports = async (numberOfWords = 3, similarTo = "") => {
|
11
|
+
let relatedTerms = _.shuffle(w2v.getSimilarWords(similarTo, numberOfWords ** 2));
|
12
|
+
|
13
|
+
let terms = nlp(relatedTerms.join(" ")).out("terms");
|
14
|
+
|
15
|
+
terms = _.uniq(terms, 'normal');
|
16
|
+
|
17
|
+
terms = _.filter(terms, function(term) {
|
18
|
+
return _.contains(term.tags, 'Noun');
|
19
|
+
});
|
20
|
+
|
21
|
+
let relatedTermsEnrichedByCompromiseNlp = [];
|
22
|
+
for(i=0;i<numberOfWords;i++) {
|
23
|
+
let randIndex = Math.floor(Math.random()*terms.length);
|
24
|
+
relatedTermsEnrichedByCompromiseNlp.push(terms[randIndex]);
|
25
|
+
terms.splice(randIndex, 1);
|
26
|
+
}
|
27
|
+
|
28
|
+
|
29
|
+
let randomWords = _.map(relatedTermsEnrichedByCompromiseNlp, (term, index)=> {
|
30
|
+
return {word: term.text, termNormal: term.normal};
|
31
|
+
});
|
32
|
+
|
33
|
+
return randomWords;
|
34
|
+
};
|
data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/rare-enough-word.js
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
const lib = require('lib');
|
2
|
+
// const l2nadb = require('./log-to-natural-database');
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Get random words form the provided text.
|
6
|
+
* @returns {any}
|
7
|
+
*/
|
8
|
+
module.exports = async function(word = "") {
|
9
|
+
//TODO: make database work again, natural db neeeds hosting
|
10
|
+
|
11
|
+
// return "test";
|
12
|
+
|
13
|
+
// let queryMin = {
|
14
|
+
// "resource": "WordFrequency",
|
15
|
+
// "minColumn": "count"
|
16
|
+
// };
|
17
|
+
//
|
18
|
+
// let lessUsedWordCount = parseInt(
|
19
|
+
// (await lib[`koma.natural-db[@dev].min`](queryMin))
|
20
|
+
// ['result']
|
21
|
+
// [0]
|
22
|
+
// );
|
23
|
+
//
|
24
|
+
// let queryWordCount = {
|
25
|
+
// resource: 'WordFrequency',
|
26
|
+
// filter: 'word_normal',
|
27
|
+
// filterValue: word
|
28
|
+
// };
|
29
|
+
//
|
30
|
+
// let wordUsedCountQueryResult = (
|
31
|
+
// (await lib[`koma.natural-db[@dev].show`](queryWordCount))
|
32
|
+
// ['result']
|
33
|
+
// );
|
34
|
+
//
|
35
|
+
// if (wordUsedCountQueryResult.length === 0) return true;
|
36
|
+
//
|
37
|
+
// let wordUsedCount = parseInt(wordUsedCountQueryResult[0][2]);
|
38
|
+
//
|
39
|
+
// return (wordUsedCount < (lessUsedWordCount + 10));
|
40
|
+
return word.length > 5;
|
41
|
+
}
|
data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/wikipedia-page.js
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
const axios = require('axios');
|
2
|
+
const _ = require('underscore');
|
3
|
+
const sanitizeHtml = require('sanitize-html');
|
4
|
+
const decodeHtml = require('decode-html');
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Random wikipedia article contents
|
8
|
+
* @returns {object}
|
9
|
+
*/
|
10
|
+
module.exports = async (language = 'en', pageIds = []) => {
|
11
|
+
var apiResponse;
|
12
|
+
if(pageIds) {
|
13
|
+
apiResponse = await axios.get(randomWikipediaArticleApiEndpoint(language));
|
14
|
+
} else {
|
15
|
+
apiResponse = await axios.get(artByPageId(pageIds[0]));
|
16
|
+
}
|
17
|
+
|
18
|
+
var page = _.values(apiResponse.data['query']['pages'])[0];
|
19
|
+
var response = {};
|
20
|
+
|
21
|
+
response['text'] = decodeHtml(sanitizeHtml(page['extract'], {allowedTags: []}));
|
22
|
+
response['title'] = page['title'];
|
23
|
+
response['wikipediaId'] = page['pageid'];
|
24
|
+
|
25
|
+
return response;
|
26
|
+
};
|
27
|
+
|
28
|
+
function randomWikipediaArticleApiEndpoint(language) {
|
29
|
+
return `https://${language}.wikipedia.org/w/api.php?format=json&action=query&generator=random&grnnamespace=0&prop=extracts&grnlimit=1`;
|
30
|
+
//return `https://en.wikipedia.org/w/api.php?format=json&action=query&titles=World_history&grnnamespace=0&prop=extracts&grnlimit=1`;
|
31
|
+
}
|
32
|
+
|
33
|
+
function artByPageId(pageId) {
|
34
|
+
return `https://en.wikipedia.org/w/api.php?format=json&action=query&pageids=${pageId}&grnnamespace=0&prop=extracts&grnlimit=1`
|
35
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"name": "koma/qanda-api",
|
3
|
+
"description": "qanda-app.com API",
|
4
|
+
"version": "0.0.17",
|
5
|
+
"author": "koma",
|
6
|
+
"stdlib": {
|
7
|
+
"name": "koma/qanda-api",
|
8
|
+
"publish": true,
|
9
|
+
"timeout": 10000
|
10
|
+
},
|
11
|
+
"dependencies": {
|
12
|
+
"axios": "^0.18.0",
|
13
|
+
"underscore": "^1.9.1",
|
14
|
+
"compromise": "^11.9.1",
|
15
|
+
"sanitize-html": "^1.18.2",
|
16
|
+
"decode-html": "^2.0.0",
|
17
|
+
"lib": "^3.0.2",
|
18
|
+
"word2vec-pure-js": "^0.0.2"
|
19
|
+
}
|
20
|
+
}
|
data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/statistics/count-word.js
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
const lib = require('lib');
|
2
|
+
|
3
|
+
module.exports = async function(word) {
|
4
|
+
await lib[`koma.natural-db[@dev].create-or-increment`]({
|
5
|
+
resource: 'WordFrequency',
|
6
|
+
whereColumn: 'word_normal',
|
7
|
+
whereValue: word,
|
8
|
+
incrementColumn: 'count',
|
9
|
+
token: process.env.NATURAL_DB_TOKEN,
|
10
|
+
db: 19
|
11
|
+
});
|
12
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
const lib = require('lib');
|
2
|
+
|
3
|
+
module.exports = async function(textToLog) {
|
4
|
+
await lib[`koma.natural-db[@dev].add`]({
|
5
|
+
resource: 'Logs',
|
6
|
+
data: {logged_text: textToLog},
|
7
|
+
token: "eyJhbGciOiJIUzI1NiJ9.eyJwcm9qZWN0X2lkIjoyMiwiZXhwIjoxNTYwMzU0ODM3fQ.jghaYoFOiMDWLQNNBZAWXYLE40DPwtMd5AN8-JyFpCI",
|
8
|
+
db: 46
|
9
|
+
});
|
10
|
+
}
|
Binary file
|