summaryrefslogtreecommitdiff
path: root/wolfram
diff options
context:
space:
mode:
authorVasil Zlatanov <v@skozl.com>2017-10-17 18:24:07 +0100
committerVasil Zlatanov <v@skozl.com>2017-10-17 18:24:07 +0100
commit8141b4227780faddc9672041bda60d84206b8422 (patch)
tree10b8894b9718b5642baf08b66faad9b67a662042 /wolfram
downloadspeech-8141b4227780faddc9672041bda60d84206b8422.tar.gz
speech-8141b4227780faddc9672041bda60d84206b8422.tar.bz2
speech-8141b4227780faddc9672041bda60d84206b8422.zip
make speech project public
Diffstat (limited to 'wolfram')
-rw-r--r--wolfram/.api-old.sh.un~bin0 -> 705 bytes
-rw-r--r--wolfram/.api.sh.un~bin0 -> 3520 bytes
-rw-r--r--wolfram/.wolf.p6.un~bin0 -> 18707 bytes
-rw-r--r--wolfram/.wolf.un~bin0 -> 6458 bytes
-rw-r--r--wolfram/.wolfram.sh.un~bin0 -> 60875 bytes
-rw-r--r--wolfram/api-perl6.sh6
-rwxr-xr-xwolfram/api.sh7
-rw-r--r--wolfram/api.sync-conflict-20150502-090303.sh7
-rw-r--r--wolfram/api.sync-conflict-20150615-220742.sh7
-rw-r--r--wolfram/example-result.xml64
-rw-r--r--wolfram/example2-result.xml64
-rw-r--r--wolfram/lat40
-rw-r--r--wolfram/lat.py26
-rw-r--r--wolfram/wolfram-old.sh16
14 files changed, 237 insertions, 0 deletions
diff --git a/wolfram/.api-old.sh.un~ b/wolfram/.api-old.sh.un~
new file mode 100644
index 0000000..279d7f5
--- /dev/null
+++ b/wolfram/.api-old.sh.un~
Binary files differ
diff --git a/wolfram/.api.sh.un~ b/wolfram/.api.sh.un~
new file mode 100644
index 0000000..6b72a93
--- /dev/null
+++ b/wolfram/.api.sh.un~
Binary files differ
diff --git a/wolfram/.wolf.p6.un~ b/wolfram/.wolf.p6.un~
new file mode 100644
index 0000000..446a50e
--- /dev/null
+++ b/wolfram/.wolf.p6.un~
Binary files differ
diff --git a/wolfram/.wolf.un~ b/wolfram/.wolf.un~
new file mode 100644
index 0000000..f320ec4
--- /dev/null
+++ b/wolfram/.wolf.un~
Binary files differ
diff --git a/wolfram/.wolfram.sh.un~ b/wolfram/.wolfram.sh.un~
new file mode 100644
index 0000000..7dd5287
--- /dev/null
+++ b/wolfram/.wolfram.sh.un~
Binary files differ
diff --git a/wolfram/api-perl6.sh b/wolfram/api-perl6.sh
new file mode 100644
index 0000000..8990cf1
--- /dev/null
+++ b/wolfram/api-perl6.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+# id: U6E8UV-AP3QJAT6RK
+DIR="$HOME/Dropbox/speech"
+toread=$(curl "http://api.wolframalpha.com/v2/query?input=$1&appid=U6E8UV-AP3QJAT6RK" | perl6 -e 'my $crap=slurp;my $out = $crap ~~ ms/"200" .*? "<plaintext>" <( .*? )> "</plaintext>"/;$out ~~ s/\(.*\)//;print "$out"')
+$DIR/tts.sh "$toread"
+
diff --git a/wolfram/api.sh b/wolfram/api.sh
new file mode 100755
index 0000000..28fcd93
--- /dev/null
+++ b/wolfram/api.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+# id: U6E8UV-AP3QJAT6RK
+DIR="$HOME/Sync/Programming/speech"
+toread=$(curl "http://api.wolframalpha.com/v2/query?input=$1&appid=U6E8UV-AP3QJAT6RK&format=plaintext&podindex=2" | sed ':a;N;$!ba;s/\n/ /g' |perl -pe '($_)=m{<plaintext>(.*?)</plaintext>} or print "No data found";s/\(.*\)//g')
+$DIR/tts.sh "$toread"
+echo $toread;
+
diff --git a/wolfram/api.sync-conflict-20150502-090303.sh b/wolfram/api.sync-conflict-20150502-090303.sh
new file mode 100644
index 0000000..2ac45b2
--- /dev/null
+++ b/wolfram/api.sync-conflict-20150502-090303.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+# id: U6E8UV-AP3QJAT6RK
+DIR="$HOME/Dropbox/speech"
+toread=$(curl "http://api.wolframalpha.com/v2/query?input=$1&appid=U6E8UV-AP3QJAT6RK&format=plaintext&podindex=2" | gsed ':a;N;$!ba;s/\n/ /g' |perl -pe '($_)=m{<plaintext>(.*?)</plaintext>} or print "No data found";s/\(.*\)//g')
+$DIR/tts.sh "$toread"
+echo $toread;
+
diff --git a/wolfram/api.sync-conflict-20150615-220742.sh b/wolfram/api.sync-conflict-20150615-220742.sh
new file mode 100644
index 0000000..2ac45b2
--- /dev/null
+++ b/wolfram/api.sync-conflict-20150615-220742.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+# id: U6E8UV-AP3QJAT6RK
+DIR="$HOME/Dropbox/speech"
+toread=$(curl "http://api.wolframalpha.com/v2/query?input=$1&appid=U6E8UV-AP3QJAT6RK&format=plaintext&podindex=2" | gsed ':a;N;$!ba;s/\n/ /g' |perl -pe '($_)=m{<plaintext>(.*?)</plaintext>} or print "No data found";s/\(.*\)//g')
+$DIR/tts.sh "$toread"
+echo $toread;
+
diff --git a/wolfram/example-result.xml b/wolfram/example-result.xml
new file mode 100644
index 0000000..6dc1570
--- /dev/null
+++ b/wolfram/example-result.xml
@@ -0,0 +1,64 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<queryresult success='true'
+ error='false'
+ numpods='2'
+ datatypes=''
+ timedout=''
+ timedoutpods=''
+ timing='0.664'
+ parsetiming='0.299'
+ parsetimedout='false'
+ recalculate=''
+ id='MSPa2661b53440gdhceah8200002e67fb9ae0777967'
+ host='http://www2.wolframalpha.com'
+ server='18'
+ related='http://www2.wolframalpha.com/api/v2/relatedQueries.jsp?id=MSPa2671b53440gdhceah82000060b56f323e8bg19i&amp;s=18'
+ version='2.6'>
+ <pod title='Input interpretation'
+ scanner='Identity'
+ id='Input'
+ position='100'
+ error='false'
+ numsubpods='1'>
+ <subpod title=''>
+ <plaintext>Answer to the Ultimate Question of Life, the Universe, and Everything</plaintext>
+ <img src='http://www2.wolframalpha.com/Calculate/MSP/MSP2681b53440gdhceah82000067ib32g29di4d9g8?MSPStoreType=image/gif&amp;s=18'
+ alt='Answer to the Ultimate Question of Life, the Universe, and Everything'
+ title='Answer to the Ultimate Question of Life, the Universe, and Everything'
+ width='455'
+ height='18' />
+ </subpod>
+ </pod>
+ <pod title='Result'
+ scanner='Data'
+ id='Result'
+ position='200'
+ error='false'
+ numsubpods='1'
+ primary='true'>
+ <subpod title=''>
+ <plaintext>42
+(according to Douglas Adams&apos; humorous science-fiction novel The Hitchhiker&apos;s Guide to the Galaxy)</plaintext>
+ <img src='http://www2.wolframalpha.com/Calculate/MSP/MSP2691b53440gdhceah82000019d6099492d028ff?MSPStoreType=image/gif&amp;s=18'
+ alt='42
+(according to Douglas Adams&apos; humorous science-fiction novel The Hitchhiker&apos;s Guide to the Galaxy)'
+ title='42
+(according to Douglas Adams&apos; humorous science-fiction novel The Hitchhiker&apos;s Guide to the Galaxy)'
+ width='486'
+ height='47' />
+ </subpod>
+ </pod>
+ <assumptions count='1'>
+ <assumption type='SubCategory'
+ word='the answer to life'
+ template='Assuming ${desc1}. Use ${desc2} instead'
+ count='2'>
+ <value name='AnswerToLifeUniverseEverything'
+ desc='The Ultimate Answer'
+ input='*DPClash.MiscellaneousE.the+answer+to+life-_*AnswerToLifeUniverseEverything-' />
+ <value name='MontyPythonsMeaningOfLife'
+ desc='Monty Python&apos;s Meaning of Life'
+ input='*DPClash.MiscellaneousE.the+answer+to+life-_*MontyPythonsMeaningOfLife-' />
+ </assumption>
+ </assumptions>
+</queryresult> \ No newline at end of file
diff --git a/wolfram/example2-result.xml b/wolfram/example2-result.xml
new file mode 100644
index 0000000..6aae1cc
--- /dev/null
+++ b/wolfram/example2-result.xml
@@ -0,0 +1,64 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<queryresult success='true'
+ error='false'
+ numpods='2'
+ datatypes=''
+ timedout=''
+ timedoutpods=''
+ timing='0.664'
+ parsetiming='0.299'
+ parsetimedout='false'
+ recalculate=''
+ id='MSPa2661b53440gdhceah8200002e67fb9ae0777967'
+ host='http://www2.wolframalpha.com'
+ server='18'
+ related='http://www2.wolframalpha.com/api/v2/relatedQueries.jsp?id=MSPa2671b53440gdhceah82000060b56f323e8bg19i&amp;s=18'
+ version='2.6'>
+ <pod title='Input interpretation'
+ scanner='Identity'
+ id='Input'
+ position='100'
+ error='false'
+ numsubpods='1'>
+ <subpod title=''>
+ <plaintext>Answer to the Ultimate Question of Life, the Universe, and Everything
+ <img src='http://www2.wolframalpha.com/Calculate/MSP/MSP2681b53440gdhceah82000067ib32g29di4d9g8?MSPStoreType=image/gif&amp;s=18'
+ alt='Answer to the Ultimate Question of Life, the Universe, and Everything'
+ title='Answer to the Ultimate Question of Life, the Universe, and Everything'
+ width='455'
+ height='18' />
+ </subpod>
+ </pod>
+ <pod title='Result'
+ scanner='Data'
+ id='Result'
+ position='200'
+ error='false'
+ numsubpods='1'
+ primary='true'>
+ <subpod title=''>
+ <plaintext>42
+(according to Douglas Adams&apos; humorous science-fiction novel The Hitchhiker&apos;s Guide to the Galaxy)</plaintext>
+ <img src='http://www2.wolframalpha.com/Calculate/MSP/MSP2691b53440gdhceah82000019d6099492d028ff?MSPStoreType=image/gif&amp;s=18'
+ alt='42
+(according to Douglas Adams&apos; humorous science-fiction novel The Hitchhiker&apos;s Guide to the Galaxy)'
+ title='42
+(according to Douglas Adams&apos; humorous science-fiction novel The Hitchhiker&apos;s Guide to the Galaxy)'
+ width='486'
+ height='47' />
+ </subpod>
+ </pod>
+ <assumptions count='1'>
+ <assumption type='SubCategory'
+ word='the answer to life'
+ template='Assuming ${desc1}. Use ${desc2} instead'
+ count='2'>
+ <value name='AnswerToLifeUniverseEverything'
+ desc='The Ultimate Answer'
+ input='*DPClash.MiscellaneousE.the+answer+to+life-_*AnswerToLifeUniverseEverything-' />
+ <value name='MontyPythonsMeaningOfLife'
+ desc='Monty Python&apos;s Meaning of Life'
+ input='*DPClash.MiscellaneousE.the+answer+to+life-_*MontyPythonsMeaningOfLife-' />
+ </assumption>
+ </assumptions>
+</queryresult>
diff --git a/wolfram/lat b/wolfram/lat
new file mode 100644
index 0000000..8d3cdf0
--- /dev/null
+++ b/wolfram/lat
@@ -0,0 +1,40 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<queryresult success='true'
+ error='false'
+ numpods='1'
+ datatypes=''
+ timedout='Integral,Series,Plot,Plotter,Simplification,Sequence,Sum'
+ timedoutpods=''
+ timing='4.551'
+ parsetiming='0.832'
+ parsetimedout='false'
+ recalculate='http://www3.wolframalpha.com/api/v2/recalc.jsp?id=MSPa54207hied0e9cb85c30000613102i371h49b63&amp;s=16'
+ id='MSPa55207hied0e9cb85c300004c5338diei1i0bg0'
+ host='http://www3.wolframalpha.com'
+ server='16'
+ related='http://www3.wolframalpha.com/api/v2/relatedQueries.jsp?id=MSPa56207hied0e9cb85c300004a3i69g2d3i729f9&amp;s=16'
+ version='2.6'>
+ <pod title='Alternate form of the integral'
+ scanner='Integral'
+ id='AlternateForm'
+ position='200'
+ error='false'
+ numsubpods='1'>
+ <subpod title=''>
+ <plaintext>1/24 (3 r (sqrt(3) r-2 x) sqrt(-3 r^2+4 r (sqrt(3) x+1)-4 x^2)-4 (3 r^2 (x-tan^(-1)((sqrt(3) r-2 x)/sqrt(-3 r^2+4 sqrt(3) r x+4 r-4 x^2)))-3 r (sqrt(3) x+2) x+2 x^3))+constant</plaintext>
+ </subpod>
+ </pod>
+ <assumptions count='1'>
+ <assumption type='Clash'
+ word='integral'
+ template='Assuming &quot;${word}&quot; is ${desc1}. Use as ${desc2} instead'
+ count='2'>
+ <value name='IntegralsWord'
+ desc='an integral'
+ input='*C.integral-_*IntegralsWord-' />
+ <value name='MathematicalFunctionIdentityPropertyClass'
+ desc='a function property'
+ input='*C.integral-_*MathematicalFunctionIdentityPropertyClass-' />
+ </assumption>
+ </assumptions>
+</queryresult> \ No newline at end of file
diff --git a/wolfram/lat.py b/wolfram/lat.py
new file mode 100644
index 0000000..92f31d1
--- /dev/null
+++ b/wolfram/lat.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import requests
+from urllib import quote_plus
+import xml.etree.ElementTree as ET
+
+appid = 'U6E8UV-AP3QJAT6RK'
+
+def get_plaintext_query(latex):
+ r = requests.get('http://api.wolframalpha.com/v2/query?input=%s&appid=%s' % (quote_plus(latex), appid))
+ root = ET.fromstring(r.text.encode('utf8'))
+
+ for pod in root:
+ if pod.attrib.get('title', '') in ['Decimal approximation', 'Definite integral']:
+ subpod = pod.find('subpod')
+ result = subpod.find('plaintext').text
+
+ if pod.attrib.get('title', '') == 'Definite integral':
+ return result.split('~~')[1]
+ else:
+ return result
+
+if __name__ == '__main__':
+ from sys import stdin
+ print get_plaintext_query(stdin.read())
diff --git a/wolfram/wolfram-old.sh b/wolfram/wolfram-old.sh
new file mode 100644
index 0000000..c5fd338
--- /dev/null
+++ b/wolfram/wolfram-old.sh
@@ -0,0 +1,16 @@
+DIR="$HOME/Dropbox/speech/wolfram"
+DIRA="$HOME/Dropbox/speech"
+curl "`curl \"$1\" |gsed ':a;N;$!ba;s/\n/ /g'|perl -lpe 's/^.*Result<//' |perl -lpe 's/^.*?src="//' |perl -lpe 's/&amp.*$//'`" > /tmp/jarresult.gif
+echo $?
+if [[ $? -ne 0 ]] ; then
+ exit 1
+fi
+convert /tmp/jarresult.gif /tmp/jarresult.tiff
+
+if [[ $? -ne 0 ]] ; then
+ exit 1
+fi
+
+if tesseract -l eng /tmp/jarresult.tiff /tmp/jarout; then
+$DIRA/tts.sh `cat /tmp/jarout.txt`
+fi