Similar to the parsing tree example in class, there is not much usefulness in parsing and evaluating statements without an operator. Therefore, it is safe to assume that any input to your parsing tree will contain an operator.
Examples of valid inputs are:
Example of inputs that are not expected (and that you don’t need to account for):
Also, if you haven’t started, and want a clean slate to start with, use this skeleton code in MS Teams: mp_parse.py (Links to an external site.)
What is the assignment?
What to hand in?
What needs to be done?
The primary tasks in this fourth assignment are to implement the following three functions.
1. buildMPLogicParseTree(s) – this function should take a string as input (e.g. s=”( T OR P_0.9 )”) and should return the binary tree representing the parse tree as described in class
2. evaluateMPLogicParseTree(t) – this function should take a binary tree as input and should return a T or an F that is based on the on the input statement
3. printMPLogicExpression(t) – this function should take a binary tree as input and should return the string that looks like the original string (perhaps with extra parentheses)
4. create some examples of how your functions work (inside of def main()), and test that each of the functions works correctly (using unittest)
Note: Those exact function names above should be used. If those name are not used 10pts will be automatically deducted.
When you submit your assignment, it will be graded in large part based on whether it successfully runs when using different input strings. The tests will roughy look like the following:
pt = buildMPLogicParseTree('( ( T AND F ) OR M_0.3 )')
ans = evaluateMPLogicParseTree(pt)
exp = printMPLogicExpression(pt)
# pt, ans, and exp will all be checked to ensure they are correct
Again, several different input strings will be also be tested.
When an M_x or P_x is present then the test will confirm that your tree evaluates to the correct average.
For example, the above input string will evaluate to T roughly 30% of the time.
What does maybe-probably logic look like again, exactly?
The symbols of our maybe-probably Boolean logic are:
Some additional examples of statements in this language are:
As with other assignments, the final code should be your own work. However, discussing the general approach, or specific Python issues/functions, with others (e.g. on MSU Discord server), is acceptable, and encouraged! Of course, don’t hesitate to ask questions in MS Teams, by email, and in class. Again, note that the tree should include x, and that M_x or P_x terms should evaluate only inside of the evaluate function.
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.Read more
Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.Read more
Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.Read more
Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.Read more
By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.Read more