Skip to content

Commit b748755

Browse files
Merge pull request #106 from abruere/master
Improve Harry's Wikipedia example
2 parents 0b026b3 + 57fc01a commit b748755

File tree

2 files changed

+77
-66
lines changed

2 files changed

+77
-66
lines changed

RAWDATA/HARRY/keywordless.top

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# this is the topic for anything that has no obvious topic.
1+
# this is the topic for anything that has no obvious topic.
22
# it is called directly from the control script when everything else fails.
33

44
topic: ~keywordless nostay()
@@ -12,30 +12,32 @@ u: (< say _*) keep() repeat() '_0
1212
#! yes, if user just says OK or yes or continue, then move along and give control to bot
1313
u: ( < [~yesanswer ~more]>) ^keep() gambit($$currenttopic) # current topic gets to continue
1414

15-
?: (what is a _*1 >) keep() $$tmp = _0
16-
$$url = ^"\"https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exsentences=2&exintro=&explaintext=&format=json&titles=$$tmp\""
17-
$$user_agent = ^"myemail@hotmail.com User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"
18-
$$tmp = ^jsonopen(GET $$url "" $$user_agent)
15+
#! What is democracy?
16+
#! What is climate change?
17+
?: (what be {a} _*~2 >) ^keep() $$tmp = '_0
18+
$$url = ^"\"https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exsentences=2&exintro=&explaintext=&format=json&utf8=&redirects=&titles=$$tmp\""
19+
# Url escaping is done by ^jsonopen
20+
$$user_agent = ^"myemail@hotmail.com User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"
21+
$$tmp = ^jsonopen(GET $$url "" $$user_agent)
1922
# ^jsontree($$tmp)
2023
# ^jsonpath( ".query .pages .56333 .extract" $$tmp)
21-
@0 = query(direct_v ? extract ? 1)
24+
@0 = ^query(direct_v ? extract ? 1)
2225
@0object
23-
24-
?: (who be _*1 >) keep() $$tmp = substitute(character '_0 _ %20 )
25-
$$url = ^"\"https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exsentences=2&exintro=&explaintext=&format=json&titles=$$tmp\""
26-
$$user_agent = ^"myemail@hotmail.com User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"
27-
$$tmp = ^jsonopen(GET $$url "" $$user_agent)
28-
# ^jsontree($$tmp)
29-
# ^jsonpath( ".query .pages .56333 .extract" $$tmp)
30-
@0 = query(direct_v ? extract ? 1)
31-
@0object
32-
33-
?: (who be _*1 _*1 >) keep() $$tmp = join('_0 %20 '_1)
34-
$$url = ^"\"https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exsentences=2&exintro=&explaintext=&format=json&titles=$$tmp\""
35-
$$user_agent = ^"myemail@hotmail.com User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"
36-
$$tmp = ^jsonopen(GET $$url "" $$user_agent)
26+
27+
#! Who is Gandhi
28+
#! Who is Lyndon Johnson # merged to Lyndon_Jonhnson
29+
#! Who is Athenian democracy # testing two non merged words
30+
?: (who be _*~2 >) ^keep()
31+
$$tmp = ^pos(capitalize ^original(_0))
32+
##<<
33+
Using original instead of '_0 to skip Wordnet dictionnary, since Wikipedia has more searchable content.
34+
and correct spelling is left to the user. In return this avoids excessive spellcheck on proper nouns.
35+
Wikipedia does not systematically redirect mis-cased requests. Proper names should always be capitalized
36+
##>>
37+
$$url = ^"\"https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exsentences=2&exintro=&explaintext=&format=json&utf8=&redirects=&titles=$$tmp\""
38+
$$user_agent = ^"myemail@hotmail.com User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"
39+
$$tmp = jsonopen(GET $$url "" $$user_agent)
3740
# ^jsontree($$tmp)
3841
# ^jsonpath( ".query .pages .56333 .extract" $$tmp)
39-
@0 = query(direct_v ? extract ? 1)
42+
@0 = ^query(direct_v ? extract ? 1)
4043
@0object
41-

0 commit comments

Comments
 (0)