- Pages:
- 1
- 2
| Good news! | |
|---|---|
| Topic Started: Feb 2 2008, 06:12 PM (954 Views) | |
| Jesin | Feb 2 2008, 06:12 PM Post #1 |
|
The Small Fish
![]() ![]() ![]()
|
Hey, I have some great news! I may actually have something decent to contribute by the end of next [IRL] year. I plan to test out of [IRL] so I can do something worthwhile and fun next year, like AI. BTW, techwizrd edited this because of various IRL related things. Edited by Jesin, Feb 3 2008, 11:54 AM.
|
![]() |
|
| techwizrd | Feb 2 2008, 11:30 PM Post #2 |
![]()
Magister ex Machina
![]() ![]() ![]() ![]() ![]()
|
Oh AI? I see. I actually recently wrote an intelligent chatbot that argues with you (like in the Argument Clinic sketch). I am using it to teach myself how to use the finer aspects of regex in Python. BTW, BobTheFerret edited this because TechWizrd failed to edit out the IRL things in his quotation. Edited by Jesin, Feb 3 2008, 11:55 AM.
|
My DeviantArt user page Please comment and add me to your favorites!
| |
![]() |
|
| techwizrd | Feb 3 2008, 01:38 AM Post #3 |
![]()
Magister ex Machina
![]() ![]() ![]() ![]() ![]()
|
Oh yeah, I forgot. NO MENTIONING IRL-RELATED THINGS! |
My DeviantArt user page Please comment and add me to your favorites!
| |
![]() |
|
| BobTheFerret | Feb 3 2008, 09:07 AM Post #4 |
|
It's The End Of The World As We Know It
![]() ![]() ![]() ![]()
|
Cool, Techy! Show me the [source|tutorial]! |
| It is dark. You are likely to be eaten by a grue. | |
![]() |
|
| techwizrd | Feb 3 2008, 11:30 AM Post #5 |
![]()
Magister ex Machina
![]() ![]() ![]() ![]() ![]()
|
The source? Sure! BTW. I wrote this from scratch. It's not even done yet. I know the code for the regex is very bad, especially as I have never used regular expressions in python and have only had a small dealing with them in Perl. If you guys can suggest any fixes or any optimizations, I would be very happy. ArgueBot.py :
|
My DeviantArt user page Please comment and add me to your favorites!
| |
![]() |
|
| Jesin | Feb 3 2008, 12:00 PM Post #6 |
|
The Small Fish
![]() ![]() ![]()
|
Come on. Am I really not allowed to say "I plan to test out of FOOBAZ"? A determined stalker could easily find out a lot about me just given that I use the name Jesin everywhere and that it is connected to my email address in some of those places. |
![]() |
|
| techwizrd | Feb 3 2008, 12:14 PM Post #7 |
![]()
Magister ex Machina
![]() ![]() ![]() ![]() ![]()
|
Yarr, he might be able to. But, I still hold up the rules. If the Administrators don't follow them, the users won't. As they say in Mother Russia, "The fish rots from the head". Anyway, how do make regular expressions only match if a certain word is after it. I am trying to use it(?=is) to match it is, but it is not working. Arghh! |
My DeviantArt user page Please comment and add me to your favorites!
| |
![]() |
|
| Jesin | Feb 3 2008, 12:15 PM Post #8 |
|
The Small Fish
![]() ![]() ![]()
|
What do you think re.compile does? You have it backwards. You don't compile a string and then search it with regexes, you compile a regex and use it to search strings. You're doing the equivalent of this: instead of this:
|
![]() |
|
| Jesin | Feb 3 2008, 12:18 PM Post #9 |
|
The Small Fish
![]() ![]() ![]()
|
That matches itis but not it is. Someadvice:neverforgetaboutwhitespace. |
![]() |
|
| techwizrd | Feb 3 2008, 12:30 PM Post #10 |
![]()
Magister ex Machina
![]() ![]() ![]() ![]() ![]()
|
OH! THX! What if a I put in a \b meta character before and after it and is? Wouldn't that do it? According to what I remember, all strings end with a null value, and that might potentially screw it up... Anyway, I'll try that and post back if it works. |
My DeviantArt user page Please comment and add me to your favorites!
| |
![]() |
|
| techwizrd | Feb 3 2008, 12:34 PM Post #11 |
![]()
Magister ex Machina
![]() ![]() ![]() ![]() ![]()
|
Okay. it does not work. Can anyone show me a regular expression that matches "it" only if "it" is followed by the word "is". Should I just try and let the program look for the entire pattern "it is", or what? |
My DeviantArt user page Please comment and add me to your favorites!
| |
![]() |
|
| Jesin | Feb 3 2008, 01:14 PM Post #12 |
|
The Small Fish
![]() ![]() ![]()
|
No, you fool. You're thinking in C. When it says \b matches the null string, it means the empty string, as in ''. You don't worry about null values in Python strings unless you're extending it in C. What you're doing matches it if and only if there is a non-alphanumeric character after it and the next two characters after it are is. That means, match the string it if it is part of the string itis and i is a non-alphanumeric character. That won't match anything. What you're looking for is this:
|
![]() |
|
| techwizrd | Feb 3 2008, 02:00 PM Post #13 |
![]()
Magister ex Machina
![]() ![]() ![]() ![]() ![]()
|
Actually, the computer understands and divides strings like this:"|C| |i|s||a| |g|r|e|a|t| |l|a|n|g|u|a|g|e|\0". It divides every single character and has a null value at the end of a line. This is who the processor knows how the terminating point of a string. I am not thinking in C, I am thinking in terms of how computers parse strings and handle them from a dynamic standpoint. I suggest you go check your facts before you call me a fool. Anyway, your solution is correct, and I am thankful. BTW, I still think C is the one of best languages out there. When you need something powerful, portable, and speedy, you use C. I wrote a parser that reads and writes bytes from an EEPROM and executes commands based on custom built scripting language (by me). The processor is 8-bit and we are given 512 bytes of non-volatile memory to use. C is a language not be be underestimated. On the other hand, if I actually want to be able to read my code, maintain it, and debug it easily, I go with lovely Python. Now if I want horrible looking spaghetti code, ugly references, forced use of bad code, slow code, and horrible debugging, maintenance problems, I go with *shudder Java. Edited by techwizrd, Feb 3 2008, 02:05 PM.
|
My DeviantArt user page Please comment and add me to your favorites!
| |
![]() |
|
| BobTheFerret | Feb 3 2008, 02:13 PM Post #14 |
|
It's The End Of The World As We Know It
![]() ![]() ![]() ![]()
|
You didn't close your expression. I can't parse that sentence. Oh, and you also made a typo. Fixed that for you.
For reference, Java is the one that actually *tells* you if you've gotten types incorrect or put arguments in the wrong order; Python is the one where you don't notice until it borks on you at runtime. I can see why you're so hard on Python's "debugging". Edited by BobTheFerret, Feb 3 2008, 02:13 PM.
|
| It is dark. You are likely to be eaten by a grue. | |
![]() |
|
| Jesin | Feb 3 2008, 03:14 PM Post #15 |
|
The Small Fish
![]() ![]() ![]()
|
About checked exceptions: Let's say method foo throws the checked exception SomeException. You want to call foo from bar, bar from baz, and baz from qux. Then you want to call qux from barbaz and catch SomeException in barbaz. Here you have two options: add "throws SomeException" to bar, baz, qux, and any other method that calls them but doesn't catch SomeException, or put this in bar:This misses the point of exception handling. Exceptions exist so you don't have to check for errors everywhere they could possibly occur, but instead you can handle them wherever it makes the most sense. With checked exceptions, you have to toss it from method to method, instead of just throwing it to the method that knows how to catch it. |
![]() |
|
| Jesin | Feb 3 2008, 04:07 PM Post #16 |
|
The Small Fish
![]() ![]() ![]()
|
Stop misquoting people. It itches. Edited by Jesin, Feb 3 2008, 04:49 PM.
|
![]() |
|
| Jesin | Feb 3 2008, 04:22 PM Post #17 |
|
The Small Fish
![]() ![]() ![]()
|
No, computers do not understand strings as 0-terminated character arrays. Computers do not understand strings at all. Computer programs understand strings. In Python, you don't think about memory blocks. Also, Python strings are not null-terminated. See? If you don't believe me, try it. Yes, I know C is not to be underestimated. I'm just saying that when you see the term "null string" in Python, it doesn't mean what it does in C. |
![]() |
|
| techwizrd | Feb 3 2008, 05:04 PM Post #18 |
![]()
Magister ex Machina
![]() ![]() ![]() ![]() ![]()
|
In Python, it does not matter in arguments are in the wrong order. In Python, you don't run into ambiguous situations because of constructors. In Python:
Produces the exact same output as:
Not only is it easier to read, you don't have to define a constructor for each and every possibility. In Java:
Don't get me wrong. I love Java';s naming scheme with the functionName and the ClassName but I hate the syntax, declare and typecast, and the overloading of constructors and classes. It is CONFUSING. Edited by techwizrd, Feb 3 2008, 06:34 PM.
|
My DeviantArt user page Please comment and add me to your favorites!
| |
![]() |
|
| techwizrd | Feb 3 2008, 05:07 PM Post #19 |
![]()
Magister ex Machina
![]() ![]() ![]() ![]() ![]()
|
Jesin, computers store strings as character arrays that are terminated by null characters. Here is an example. How do text editors know where the lines ends. An EOL character (or CLRF of LF). Strings are terminated by null characters. It woudn't matter anyway, as the original implementation of Python was written in C |
My DeviantArt user page Please comment and add me to your favorites!
| |
![]() |
|
| techwizrd | Feb 3 2008, 05:13 PM Post #20 |
![]()
Magister ex Machina
![]() ![]() ![]() ![]() ![]()
|
Well, after modifying the source to my ArgueBot, here is the newer code: BTW, the forum code does not display the indentation Spoiler: click to toggle Now, here is a pseudo-intelligent conversation I just had with it: Spoiler: click to toggle
Edited by techwizrd, Feb 3 2008, 05:34 PM.
|
My DeviantArt user page Please comment and add me to your favorites!
| |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| Go to Next Page | |
| « Previous Topic · General Discussion · Next Topic » |
- Pages:
- 1
- 2





![]](http://z3.ifrm.com/static/1/pip_r.png)




12:48 PM May 20