Re: BOOL takeStupidRoad = NO (search app design question)
Re: BOOL takeStupidRoad = NO (search app design question)
- Subject: Re: BOOL takeStupidRoad = NO (search app design question)
- From: David Yamartino <email@hidden>
- Date: Mon, 23 Mar 2009 22:09:27 +1000
Thanks, Izidor, for these suggestions.
Regarding the Spotlight API, several people have suggested this, however my
understanding is that Spotlight indexes at the file level - that is, it
knows that the word "perpendicular" is contained in File X, File Y, and File
Z. However, I need to know the exact 11 locations where the word appears in
these files, which I don't think Spotlight does.
Then again, I guess I could use Spotlight to locate the proper files, and
then focus on them for finding the position of the words and then getting
the words around them for the snippets, etc.
OK - I'll do my best to proceed like this (or otherwise make it work) then
optimize if needed.
I really appreciate your help,
David
On Mon, Mar 23, 2009 at 8:08 PM, Izidor Jerebic <email@hidden>wrote:
> Hello, David,
>
> there is nothing wrong with your aproach. For this amount of data and for
> its first version the program should be ok.
>
> However, if you find out later that your search needs to be faster/consume
> less memory/work with more files, you will need to optimize the application.
>
> Note that this is the correct approach. First make the application work.
> Optimize later, when/if necessary.
>
> If you structure your application well (ObjectOriented design), then you
> will be able to switch new search code and snippet generation into
> application without changing the rest of application. This is the main and
> most important design issue - how to structure your application so you can
> improve it with as little work as possible.
>
> Search optimization can take many forms, from using SearchKit or some other
> search library to build your private index, or using Spotlight API, or some
> other search tool (such as programmatically running the command like 'grep'
> and parsing its output). The software will become more complicated, because
> the generation of snippets may or may not be supported by the search code
> you will use, so you may need to generate them yourself, separately from
> search.
>
>
> izidor
>
>
>
> On 21.3.2009, at 11:24, David Yamartino wrote:
>
> Hi All,
>>
>> I have a general design question. I'm going through the latest Hillegass
>> and
>> Kochan programming books for the purpose of writing a simple search app. I
>> think I've figured out a way to do this, but having no experience in
>> programming, I have no idea if my approach is good or bad. I'd rather not
>> take the stupid road if I can avoid it, so I'm hoping someone may be able
>> to
>> set me straight before I go too far down the road.
>>
>> So if you're inclined to take a few minutes to consider what I've written
>> below, I'd appreciate it.
>>
>> In any case, good luck with your projects,
>>
>> David
>>
>>
>> --------------------------------------------------------------------------------------------
>>
>> *APPLICATION DESCRIPTION:*
>> I have a library of about 1,500 text files, about 93 MB total.
>>
>> The application window opens with two views: left view shows the hierarchy
>> of folders/files, and when you click on a file, the text of the file
>> appears
>> in the right view, where you can read, scroll, etc.
>>
>> The user inputs a term into the search field, and when the search is
>> executed, the folders/files on the left view disappear and the view is
>> repopulated with a new hierarchy showing only the folders/files where the
>> search term appears. Below each file will be snippets of where the term
>> appears within the text. Click on a snippet and the right view will show
>> the
>> entire text of the file zoomed to where the snippet appears.
>>
>> For example, if the search term is "child education":
>>
>> *Book X*
>> The *child education* conference focused on two age groups: 5-7 years,
>> and 8-10 years.
>> . . . because the *child* wasn't receiving the needed attention in
>> her *education*, her parents decided . . .
>> . . . and over the years the *child education* policy was broadened
>> to include moral education and . . .
>>
>>
>> *MY APPROACH*:
>> I can load the text of the 1,500 files into 1500 NSStrings with something
>> like
>>
>> stringWithContentsOfFile
>>
>>
>> Then I can search the 1,500 NSStrings to locate the position of the search
>> term within each string, then extract a range (including some words before
>> and some words after) to make the snippets. Using
>>
>>
>> rangeOfString
>>
>> NSMakeRange
>>
>> etc.
>>
>>
>>
>> *QUESTION:*
>>
>> Would this be a workable approach? Or is it a really stupid idea to have
>> to
>> load 93 MB of files into 1,500 NSStrings every time the program starts up?
>> If not this approach, what would be more efficient?
>>
>>
>> Thanks.
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden