Giter VIP home page Giter VIP logo

please's Introduction

"Please" - An Experimental Programming Language

Simply put: Program by talking to your computer using common English words.

More technically: You can easily write code in Please using speech recognition software (like Dragon NaturallySpeaking, Mac Dictation, or Google Voice Typing) out-of-the-box, without having to train the software to recognize esoteric jargon and special keywords for symbols. As of release v0.2.0: transformer.py compiles Please into Python code and runs that.

Presentation at Round 13 of Toronto Hack && Tell: https://goo.gl/mcdLYH (won 1st place and got a Raspberry Pi!)


Example Code in Please:

First transcribe this code:

please print this string of words

When you run that code, it prints out:

this string of words

Try It:

A) In Your Browser (Mini Version):

No speech recognition software? No Python? Just type code in your browser: https://goo.gl/zk1LFu (go to the text.txt tab to write code in Please).

B) On Your Computer (Full Version):

  1. Download this project from GitHub. https://github.com/hchiam/please/archive/master.zip --> master branch. Or get a different version at https://github.com/hchiam/please/releases

  2. Open the folder using Terminal or Command-line.

  3. Then input the following command and hit enter:

python transformer.py text.txt

The transformer will turn the text file (Please "source code") into Python code, and then run that.

Requires Python 3: https://www.python.org/downloads

This project was built with Python 3.6.0


Why?

Less carpal tunnel syndrome? More accessible programming for people with a mobility impairment? Code while you exercise?

What if you could easily write code just by talking with speech recognition software? What if code could be more like English sentences? How might you combine these two things (easy-to-parse and easy-to-say code)?

Please is an attempt at that.

Here are 3 ground rules to make commands easier to say, but also easier for speech recognition software and Please's code transformer to understand:

  1. Just say words that use your ABCs and spaces between. No special non-letter characters like "?". Why? Speed and recognition. Saying "question mark" just to type out "?" is slow and could be faulty if the speech recognition software thinks you literally want the words "question mark". Please also doesn't differentiate (non-)capital letters because it's a speech-based language (vs. a "written language").
  2. Avoid specialized words or names. Why? So you don't have to specifically train your speech recognition software to recognize uncommon words like "numpy" (mine thought I said "numb pie"). Workaround/trade-off: you have to spell it out, maybe using the first letters of more common words, like "Neptune unicorn moose panda Yoda" to spell out "numpy". Afterwards, you can reassign "numpy" to a shorter label that uses more common words, like "numb pie" or "pneumatic".
  3. "Say please". Start each new sentence with "please" to mark out a new command or line in the code. (But you don't have to: on devices or interfaces that let you enter the newline character, just start your code with "please no need to say please". See terse mode.)

I don't intend to replace Python. In fact, python import capability is built right into Please. See import examples below.


More Example Code:

Currently you can: print out strings and variable values, create variables, assign values/lists to variables, spell out uncommon words, do basic math, use nested if statements, use nested for loops, write comments, import Python modules, use imports, use your own defined functions, access list indices, use terse mode...

Print:

please print this string of words

--> This prints out: this string of words

please assign apple the value one
please print variable apple

--> This prints out: 1

Create Variables:

By design, Please encourages you to use words instead of letters and short forms -- you're saying it out loud.

please create variable apple

or

please variable banana

Assign Values/Lists to Variables:

please assign apple the value one
please assign variable banana the value three hundred
please assign to coconut the value of some words

--> This generates: apple = 1, banana = 300, coconut = 'some words'

Note: variables automatically get created if you didn't already create them.

please assign dragon fruit the value list starting from eight ending at twelve

--> This generates: dragon fruit = [ 8 , 9 , 10 , 11 , 12 ]

please assign crazy list the value list of one and two and tree bark

--> This generates: crazy_list = [ 1 , 2 , 'tree bark' ]

Spell Out a Special Word:

please spell with the first letters of Neptune unicorn moose panda Yoda

--> This evaluates to: numpy (NumPy is a Python library you can import: https://en.wikipedia.org/wiki/NumPy) (Also see import examples)

Note: capital letters are treated the same as lowercase letters. Please is case-insensitive.

Math:

please one plus two

--> This evaluates to: 3

please one plus one equals two

--> This evaluates to: True

please assign result the value one plus two
please print variable result

--> This prints out: 3

If Statements:

please if true then print this is a one line if statement

---> This prints out: this is a 1 line if statement

please if one equals one then
    please print this should print
please end if

--> This prints out: this should print

please if one equals two then
    please print it should not print this
please end if

--> (This doesn't print anything because the if-statement evaluates to False.)

Note: Please ignores whitespace and newline characters because the spoken word doesn't explicitly mark out paragraphs either. So you could type this too:

please if one equals two then  print it should not print this  end if

You can use library/format.py to automatically format your Please code.

For Loops:

assign circle the value list starting from negative one ending at three
please for each index in circle
    please print variable index
please end for

--> This prints out: -1, 0, 1, 2, 3

Comments/Notes:

please note this is a comment

--> (The transformer ignores this sentence.)

Make and Use Your Own Functions:

please define function test with item
    please print variable item
please end function
please assign other the value it works
please use function test on variable other

--> This prints: it works

Import to Add Functionality:

please import alternate

--> This imports: alternate.py (from the local folder)

please import test from library

--> This performs: from library import test --> This imports: /library/test.py

please import spelled with the first letters of Neptune unicorn moose panda Yoda

--> This performs: import numpy. (You can spell out "numpy" since it's not an everyday word, and your speech recognition software might not already be trained to recognize it.)

please import spelled with the first letters of Neptune unicorn moose panda Yoda as noodle

--> This performs: import numpy as noodle. (So no need to spell it out each time you use it.)

please import spelled with the first letters of Neptune unicorn moose panda Yoda as numb pie

--> This performs: import numpy as numb_pie. (You can also just rename it to whatever your speech recognition software thinks you're saying.)

Use an Import Module's Function:

please import test from library
please use test function of test
please use test function from test

--> This performs twice: test.test_function()

--> This prints twice: Yay the import test_function() of test.py from the "library" folder works!

Access List Index:

please no need to say please
assign crazy list the value list of one and two and tree bark
assign sequence the value list starting from zero ending at two
for each item in sequence
    print index variable item of crazy list
end for

--> This prints: 1, 2, 'tree bark'

Example Using numpy.array

Requires numpy already installed to work:

please import spelled with the first letters of Neptune unicorn moose panda Yoda as numb pie

assign array the value list starting from two ending at four
please print array is variable array

please print use array of numb pie on variable array
please assign output the value of using array of numb pie on variable array

please print output of array of numb pie is variable output

--> This imports numpy, creates array = [ 2 , 3 , 4 ], and runs output = numb_pie.array(array)

--> This also prints array is [2, 3, 4], use array of numb pie on [2, 3, 4], and output of array of numb pie is [2 3 4]

Example Fibonacci

Please define function Fibonacci with number
Please if number under two then return number
Please assign apple the value of using function Fibonacci on number -1
Please assign banana the value of using function Fibonacci on number -2
Please assign coconut the value of variable apple plus variable banana
Please return variable coconut
Please done function
Please assign input the value list starting from 0 ending at 8
Please for each Number in input
Please assign output the value of using function Fibonacci on number
Please print variable output
Please done for

--> This compiles to:

def fibonacci(number):
	if number < 2:
		return number
	
	apple = fibonacci(number -1)
	banana = fibonacci(number -2)
	coconut = apple + banana
	return coconut

input = [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ]
for number in input:
	output = fibonacci(number)
	print(str(output))

Terse Mode

please no need to say please
print this works
print no need to say please before each line

--> This prints out: this works and no need to say please before each line


Inspirations for Please:

https://github.com/hchiam/programmingByVoice

https://github.com/AnotherTest/-English

https://www.youtube.com/playlist?list=PLBOh8f9FoHHiKx3ZCPxOZWUtZswrj2zI0 (especially for v0.1.0)

You may also like:

https://github.com/hchiam/code-tutor

https://github.com/hchiam/language-user-interface

https://github.com/hchiam/how


Ideas for Development:

(See the Issues list. Click the "Issues" tab above or go to https://github.com/hchiam/please/issues)

please's People

Contributors

hchiam avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

piandpower

please's Issues

print and if...then but running when should not

Two examples:

This should only print if two equals one then, and not try to run an if-statement:

Please print if two equals one then

This should not print this should not print because the if-statement evaluates to false:

Please if two equals one then
please print this should not print

"create variable spelled with ..."

Enable: "Please create variable spell with the first letters of apple banana coconut". Would be nice to have the flexibility built in.

create dictionary/hashtable

example: please create dictionary my dictionary
example: please create dictionary my dictionary equals...

if-then with multi-line between then and end if

example:

Please if ... then 
Please ... 
Please ... 
Please end if

Also:

if … then
… : if_continue_state or or some other state tracker?
end if: if_continue_state or or some other state tracker?

more elaborate example using numpy? (#17?) see comments

  • from <import name> use <import function> on <variable or math>

    • example: "please from numb pie use array on variable apple"

    • example: "please from numb pie use array on list from one to four"

  • from <import name> use <import function> on <variable or math> [ and <variable or math> ]

    • example: "please from numb pie use array on variable apple and variable banana"
  • from <import name> use <import function> on <variable or math> [ and <variable or math> ] [ and <variable or math> ]

    • example: "please from numb pie use array on variable apple and one and two plus two"

use words_grouped-level data?

Already split sentence in to tokens, so maybe make use of this?
Related to issue #11: check_spell(sentence) in sentence loop, not word loop.

enable "please import SPELL ... as ..." as well

This would enable this: "Please import spelled with the first letters of Neptune unicorn moose panda Yoda as numb pie" --> "import numpy as numb pie", without actually having to train speech recognition software on the word "numpy".

check_if() stopped working for if statements

This code should print out it works:

Please assign list of one and two and tree bark to variable crazy list
please if crazy equals crazy then
    Please print it works
please end if

enable terse mode (see comment)

An initial sentence to trigger expectation of omitted "please" from each line (useful if user can enter new line characters).
For example:
please I can enter new lines
or
please let me use new line characters
or something like the above. Shorter is better.
[EDIT:]
or
please use enter mode ("newline" or "new line" are special words in Mac Dictation and may not be typed out literally)
or
please no need to say please anymore
or
please no need to say please

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.