|
Sorry, I don't read unformatted code; you should use PRE tags as you did before.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
I have edit the code block..
|
|
|
|
|
khalidelmeknesi wrote: is not 100 % good
that is quite a diagnosis. Take some white pills every day for the next couple of weeks or months.
I haven't studied the code in detail as I don't like it from first sight. I see three nested loops, so its performance will scale terribly. I see one dictionary that probably ends up containing all substrings of all starting points and all lengths, so it is quadratic. This is a brute force approach, nowhere near what I suggested initially.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
You should be able to solve this with a suffix tree[^].
1. build the suffix tree
2. sort the list of suffixes
3. compare every entry with the adjacent ones in the list to find how many times that string is repeated - if it's repeated, then then next few entries in the sorted list will begin by the same string
It's only a draft idea and it sure needs to be refined and completed when implementing, but it should work.
Keep an eye on memory usage.
Good luck.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
modified on Sunday, September 13, 2009 3:37 AM
|
|
|
|
|
khalidelmeknesi,
I'll throw my 2 cents worth into the pot for what its worth (probably about 2 cents).
Use a sort like the Mix Software C Database Toolchest C-BTree routine to create a database (a tree).
Read the file line by line and for each line, ping pong from the front of the line using two character strings, then from the back of the line with 3 character strings, then from the front of the line with 4 character strings, etc, until a full sized line is finally entered, for each such string, add an entry to the tree, each entry containing the string, its length, and an Item (an unsigned long) with a value of 1, specifying no duplicates (if the sort detects a duplicate, it will not add a new entry but return an error, if so then read the existing entry's Item, increment the Item count, and re-save the updated Item, and as you are updating the items, save the top highest item values found in a short array of as you said "some top 5 counts so you know what to look for at the end).
When the end of the input file is reached, close it, then read each entry in the tree and delete the entry if the entry's Item is a value that is not 0 and less than the top 5 or so counts you saved. For entries in the top 5 or so, create a new entry that starts with the Item count subtracted from the maximum saved count converted to a fixed length string with a leading 1 (i.e. for an entry of "abc" with Item count of 45 with a maximum count of 50 start the string with 105, Note: all these created count strings must be the same length) then append the entry string ("abc") giving a string of "105abc", and set the new Item to a value of 0, and once this new entry is created, delete the original entry. If a tree entry is found that contains an Item with a count of 0 (an entry with a header string), then ignore it.
When you have finished modifying all of the tree entries, the tree will contain only the top 5 or so counts with the associated string snipits, all neatly sorted in ascending sequence with the highest count first, and for each high count, the snipits in ascending sequence. Note, to report the count, set a value of 1xxx where xxx is the maximum count, and subtract the leading string value, i.e. as in the example above, set the constant to 150 (1 + the maximum value) and subtract 105 (the heading string) to get a count of 45 for string "abc" (Note: the highest values would have a header string of 100 thus the count would be reported as 50).
When you are done, delete the tree file (Note: this tree file will be HUGE as it is being built).
Note: Mix software still has this excellent database available as of my last check about a year ago. I originally purchased the program and the source in 1984 or so and have recently converted it to compile under the latest Visual Studio. I also created export/import functions that could read old databases (where ints were 16 bits) and create new databases (where ints are 32 bits).
Piece of cake.
Dave.
|
|
|
|
|
|
I would make a big-big-big database containing the faces of all the world's people then ask Rajesh for a monkey (you know, the recognition task) ...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
|
kabirbdboy wrote: actually my supervisor said me first find three webside on face recognition.
If you can't find three websites with information on face recognition, you need to change majors. Good advice, take it.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
|
Try Google, that's why it exists.
|
|
|
|
|
Hi kabirbdboy!
I work very hard to earn my money and have next to no free time. Please can I do your homework for you? It is so obvious that typing www.google.com and the search term face recognition is beyond your ability. I would hate for you to fail a course in a subject that you have no aptitude for. How else will the world be able to create all the team leaders, project managers and human resources professionals that we so desperatly need and you are so destined to become?
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
thank u.i have find some popular site and some demo project and paper on face recognition.i have already done my 40% work!!
|
|
|
|
|
Keep up the good work then. If you ask a question here again that looks like all you want us to do is do your homework for you, you can expect the same kind of responses. If you have a specific question about how some detail works and you show you've actually done some work on the problem, then you may get an answer.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
I have an image with each pixel representing a value in the range 0...1 and would like to map a gradient to the range.
Values in the range 0...0.5 should be shaded from black to red, and values in the range 0.5...1 should be shaded red to white. Each colour is represented as a single unsigned int in the form AA RR GG BB with AA being redundant in this case. How would I go about doing that? I'm using C++ but at the moment psuedo code would be just fine.
|
|
|
|
|
You'd use the Color.FromArgb [^] method, iterating over the different colors
|
|
|
|
|
For each pixel:
1. If the value, v, is 0 to 0.5, R = v * 510, G = B = 0.
2. If v is .5 to 1, R = 255, G = B = (v - .5) * 510.
So, at v = 0, the pixel is black. As we go from 0 to .5, red increases to its maximum (255) as we approach .5.
From total red at v = .5, it's blended with increasing shades of white, up to total white at v = 1.
|
|
|
|
|
what is the regular expression of muliple line commment other then /* (a+n)* */ bcoz this expression donot accept /* hhhhhhhh*hhhhh*/ string ???????
|
|
|
|
|
You need to search for anything except a closing comment, including newlines.
Expresso is a great tool for testing and building regex.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
it is also conceivable to create a compiler without using any regex.
|
|
|
|
|
Just what I was going to say. Regexes are probably the least useful tool for writing a compiler. OK, a spanner is probably less useful, but you know what I mean
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
You need to remember to escape the asterisks.
/\*.*?\*/
It doesn't handle nested comments, but I understand that balancing groups could be used to cover that.
One of the problems with trying to do it with a RegEx is that you have to read the entire file into a string before you process it and then use the SingleLine option.
|
|
|
|
|
|