Compare commits

...
This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.

54 Commits
master ... nlp

Author SHA1 Message Date
Hugo Sales 808d76e169 Formatting of error message 2018-12-20 23:31:33 +00:00
Hugo Sales 88413e2b02 Small bug in multiply 2018-12-20 23:29:12 +00:00
Diogo Cordeiro 5f5352ddb1
Update README.md with NLP info 2018-12-20 23:22:58 +00:00
Diogo Cordeiro 9fd09b6059 Merge branch 'nlp' of https://github.com/diogogithub/polynomialmani.pl into nlp 2018-12-20 23:19:42 +00:00
Diogo Cordeiro f12221bed0 Add help examples 2018-12-20 23:19:22 +00:00
Hugo Sales bfb580c566 Negative numbers working 2018-12-20 23:15:18 +00:00
Hugo Sales 4e9d1ec760 Replace tokezing process with actual tokenizer. Now we can handle things like 3*x and even 3x 2018-12-20 23:04:19 +00:00
Hugo Sales f9d579c494 Added pointless function requested by spec and the partial ability to parse polynomials with normal ops 2018-12-20 22:45:58 +00:00
Hugo Sales fffe104684 Allow omiting mult operator 2018-12-20 22:05:37 +00:00
Hugo Sales 9a181a076a Proper handling of multiplication 2018-12-20 21:52:17 +00:00
Hugo Sales 1232fa0b3c Fixed number parsing 2018-12-20 21:38:46 +00:00
Diogo Cordeiro d054989bc0 Some progress in supporting floats
Fixed some typos
2018-12-20 20:45:11 +00:00
Diogo Cordeiro 3af7f72aa4 Say NO to duplicated output 2018-12-20 04:03:38 +00:00
Diogo Cordeiro 4264649271 Make addition great again 2018-12-20 03:26:17 +00:00
Hugo Sales 3daaee65a5 Merge branch 'nlp' of github.com:diogogithub/polynomialmani.pl into nlp 2018-12-20 03:04:39 +00:00
Hugo Sales 4e37792c0a Fixed major bug with parsing 2018-12-20 03:04:22 +00:00
Diogo Cordeiro c7ad8a2883 Chavetas mágicas 2018-12-20 02:51:21 +00:00
Hugo Sales 90b5c6b3f1 Merge branch 'nlp' of github.com:diogogithub/polynomialmani.pl into nlp 2018-12-20 02:40:30 +00:00
Hugo Sales dfdd65abdf The Great Documentation Efort, a small refactor and small bug fixes 2018-12-20 02:24:31 +00:00
Diogo Cordeiro e48ededaa7 Make as great again 2018-12-20 02:22:38 +00:00
Diogo Cordeiro 2057d2b14f Make multiply great again 2018-12-20 01:39:11 +00:00
Diogo Cordeiro 957e484db5 Add minus 2018-12-20 01:10:35 +00:00
Diogo Cordeiro d9d835b00d O Emacs fez das suas... 2018-12-20 00:48:57 +00:00
Diogo Cordeiro 3a1602ff62 Replace Van Morrison with Elvis Presley - the king 2018-12-20 00:45:35 +00:00
Diogo Cordeiro 7a667c2cd8 Merge branch 'nlp' of https://github.com/diogogithub/polynomialmani.pl into nlp 2018-12-20 00:39:45 +00:00
Diogo Cordeiro 2a6f7920bf Add help menu (no examples added yet)
It features tons of musical references

I'm sad that I didn't add any song of the king
2018-12-20 00:38:50 +00:00
Hugo Sales b4a94461a7 Bug fixing and fixed using stored variables 2018-12-20 00:21:07 +00:00
Hugo Sales b14aeb8893 Fixed small type .-. 2018-12-19 23:37:26 +00:00
Hugo Sales d5d86bee62 Fixed small derp 2018-12-19 23:33:49 +00:00
Hugo Sales e9a739b33e Bug fixes, support for floating point numbers 2018-12-19 23:27:12 +00:00
Hugo Sales c057493d86 Bug fix and added support for scaling a polynomial 2018-12-19 21:04:17 +00:00
Hugo Sales 05fcfcbcb2 Big progress\n\nCan now properly use memory, mostly, simplify, parse literal numbers\nFixed some bugs 2018-12-19 19:11:54 +00:00
Diogo Cordeiro 8c2c66c6ba pushing things 2018-12-19 14:31:17 +00:00
Diogo Cordeiro 04199f670f Added some elementary missing functionalities and minor bug fixes
Added multiply, add, etc. to process_input
Memory is now properly working (store, forget and access storage)
Command concatenation is now properly working (as is sophisticated numbers [bug fix])
2018-12-18 03:02:53 +00:00
Diogo Cordeiro b984b0efd4 Fix polynomial_tree_to_polynomial 2018-12-17 20:29:00 +00:00
Diogo Cordeiro a6c2073209 Added simplify instruction
Refactored print_polynomial to print_polynomial_tree

nl instead of write(\n)
2018-12-17 20:19:41 +00:00
Hugo Sales 240b480aae WIP processing 2018-12-17 17:06:25 +00:00
Hugo Sales 10fb55086f Quick fix v2 2018-12-17 16:35:41 +00:00
Hugo Sales 9aeaebfded Quick fix 2018-12-17 16:34:02 +00:00
Hugo Sales 74d9e9cc5b Merge branch 'nlp-ph' into nlp 2018-12-17 16:31:10 +00:00
Hugo Sales 506cd53192 Merged other 2018-12-17 15:41:21 +00:00
Diogo Cordeiro 40da15ba54 I guess polyplay now works fine...
Fixed various bugs, refactored, reorganized, simplified logic
2018-12-17 15:39:11 +00:00
Hugo Sales fc12b219c0 Merge branch 'nlp' of github.com:diogogithub/polynomialmani.pl into nlp 2018-12-17 14:41:14 +00:00
Diogo Cordeiro c9a2eeca89 No need of that anymore 2018-12-17 04:23:00 +00:00
Diogo Cordeiro 0dfe64e740 Link everything properly and some small improvements 2018-12-17 04:22:12 +00:00
Hugo Sales d7f3a9996b Expanded parser and fixed parsing numbers 2018-12-14 22:46:14 +00:00
Phablulo 047d6b9a4b basic language parsing 2018-12-13 19:42:03 -03:00
Diogo Cordeiro deb3e27f2d Update assignment 2018-12-13 17:11:49 +00:00
Diogo Cordeiro 1c498108fc Fix previous merge issues 2018-12-13 17:09:25 +00:00
Diogo Cordeiro aafef78100 Merged cenas com hugo 2018-12-10 17:37:34 +00:00
Hugo Sales ea80d57ef9 More concise number parsing 2018-12-10 17:33:35 +00:00
Hugo Sales 040f3bd859 Simplified the way number parsing works 2018-12-10 01:13:58 +00:00
Hugo Sales 75cae0b25f Parsing integer numbers 2018-12-09 00:01:22 +00:00
Diogo Cordeiro 7fd64223fc dumb fake NLP stuff 2018-12-07 16:11:11 +00:00
4 changed files with 977 additions and 63 deletions

104
README.md
View File

@ -14,6 +14,88 @@ Inside the REPl, load the file
> Note: Don't forget the dot at the end of the line.
## Tests
```
:- ["polymani.pl"].
%@ true.
?- polyplay.
%@ true.
> simplify 1 plus x plus 1 plus x plus 1 plus x plus 1 plus x raised to 3 plus 5 times x raised to 3 plus 42 times x raised to 1337 plus 0
42*x^1337+6*x^3+3*x+4
> show 1 plus x plus 1 plus x plus 1 plus x plus 1 plus x raised to 3 plus 5 times x raised to 3 plus 42 times x raised to 1337 plus 0
1+x+1+x+1+x+1+x^3+5*x^3+42*x^1337+0
> multiply 2 times x squared plus 3 times x plus 5 times x raised to 17 minus 7 times x raised to 21 plus 3 times x raised to 3 minus 23 times x raised to 4 plus 25 times x raised to 5 minus 4.3 by 42
1050*x^5+210*x^17+126*x^3+126*x+84*x^2-294*x^21-966*x^4-180.6
> add 2 times x raised to 2 plus 3 times x plus 5 times x raised to 17 minus x raised to 4 plus 25 times x raised to 5 minus 4.3 to 42 times x raised to 1337 plus 0 minus 5
42*x^1337+25*x^5+5*x^17+3*x+2*x^2-x^4-9.3
> show two plus x squared
2+x^2
> multiply three by two plus x squared
3*x^2+6
> simplify two plus two plus one times y
y+4
> show two plus x squared as P1
P1 = 2+x^2
> multiply three by P1
3*x^2+6
> multiply three by P1 as P2
P2 = 3*x^2+6
> add P1 with x raised to 3
x^3+x^2+2
> show stored polynomials
P1 = 2+x^2
P2 = 3*x^2+6
> forget P1 and show stored polynomials
P2 = 6+3*x^2
> add two times x to four times x
6*x
> show two times x plus three times y raised to four
2*x+3*y^4
> show two x squared
2*x^2
> simplify polynomial five x plus 3 times x
8*x
> bye
See ya
?- poly2list(2*x^2+3*x+5*x^17-7*x^21+3*x^3+25*x^5-4.3, S).
%@ S = [-4.3, 25*x^5, 3*x^3, -7*x^21, 5*x^17, 3*x, 2*x^2].
?- simpoly_list([x*x*x, x^3, 5*x^3, 4.2*z, 2, 42.6, 42*y, 5*z, z^7, z*y^1337, 0], L).
%@ L = [44.6, 7*x^3, 9.2*z, 42*y, y^1337*z, z^7].
?- simpoly(1+x+1+x+1+x+1+x^3+5*x^3+42*x^1337+0, S).
%@ S = 42*x^1337+6*x^3+3*x+4.
?- scalepoly(2*x^2+3*x+5*x^17-7*x^21+3*x^3-23*x^4+25*x^5-4.3, 42, S).
%@ S = 1050*x^5+210*x^17+126*x^3+126*x+84*x^2-294*x^21-966*x^4-180.6.
?- addpoly(2*x^2+3*x+5*x^17-x^4+25*x^5-4.3, 42*x^1337+0-5, S).
%@ S = 42*x^1337+25*x^5+5*x^17+3*x+2*x^2-1*x^4-9.3.
```
## Command Line Interface without NLP
The user available predicates are:
1) poly2list/2
2) simpoly_list/2
@ -42,28 +124,6 @@ The polynomial resulting from the sum is in simplified form.
> Note: `foo/N` means the funciton `foo` has `N` parameters (this is known as arity).
These names are the ones requested in the assignment.
## Tests
```
:- ["polymani.pl"].
%@ true.
?- poly2list(2*x^2+3*x+5*x^17-7*x^21+3*x^3+25*x^5-4.3, S).
%@ S = [-4.3, 25*x^5, 3*x^3, -7*x^21, 5*x^17, 3*x, 2*x^2].
?- simpoly_list([x*x*x, x^3, 5*x^3, 4.2*z, 2, 42.6, 42*y, 5*z, z^7, z*y^1337, 0], L).
%@ L = [44.6, 7*x^3, 9.2*z, 42*y, y^1337*z, z^7].
?- simpoly(1+x+1+x+1+x+1+x^3+5*x^3+42*x^1337+0, S).
%@ S = 42*x^1337+6*x^3+3*x+4.
?- scalepoly(2*x^2+3*x+5*x^17-7*x^21+3*x^3-23*x^4+25*x^5-4.3, 42, S).
%@ S = 1050*x^5+210*x^17+126*x^3+126*x+84*x^2-294*x^21-966*x^4-180.6.
?- addpoly(2*x^2+3*x+5*x^17-x^4+25*x^5-4.3, 42*x^1337+0-5, S).
%@ S = 42*x^1337+25*x^5+5*x^17+3*x+2*x^2-1*x^4-9.3.
```
## Authors
* **Diogo Cordeiro** - up*201705417*@fc.up.pt

BIN
assignment-part2.pdf Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff