AutoHotkey Community

It is currently May 26th, 2012, 1:10 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: November 19th, 2008, 8:31 pm 
Hello,

How do i make a function that searches for keywords in a .txt file and return the results?
if anyone could make a simple example I would appreciate it :-)

Thanks!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 8:40 pm 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
What do you mean by "keywords". Are you talking about look for words in a list - like you have dog, cat, moose on a list and want to find them, or do you mean hotstrings, or something else? Please elaborate.

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 8:56 pm 
Sry i havent really figured out how to make it. But the thing that I wanna make is like:

The .txt file:
Code:
Cattie
Tuttie
Futtie
Wootie
Wooahh
Vahoahh


Hehe, like a lot of words, where some of them have something in common, like "ahh" or "tie".
Then I want thease words, like an output that I can use in another script.

I hope you understand, my english isn't very good.

Thanks for replies.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 9:07 pm 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
Your english is fine. We're just trying to figure out what you're trying to do.

So you have a list of words, such as what you gave, Would you then have a list of "keywords" - "ahh", "tie", and the goal is to say which words in the list have the given keyword?

So the output would be something like

Code:
[Ahh]
Wooahh
Vahoahh
[Tie]
Cattie
Tuttie
Futtie
Wootie


Am I on the right track? If so, regexmatch is the way to go - in my opinion.

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 9:09 pm 
Thank you, i'm gonna read about it now.
I hope i'll get it to work :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 9:14 pm 
animeaime wrote:
Your english is fine. We're just trying to figure out what you're trying to do.

So you have a list of words, such as what you gave, Would you then have a list of "keywords" - "ahh", "tie", and the goal is to say which words in the list have the given keyword?

So the output would be something like

Code:
[Ahh]
Wooahh
Vahoahh
[Tie]
Cattie
Tuttie
Futtie
Wootie


Am I on the right track? If so, regexmatch is the way to go - in my opinion.



Yes thats right. Then i want the words retrived.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 9:25 pm 
I got an idear of making it now. I know this is maybe a stupid way to do it but that's all i know of. :?

I'm thinking about something like:
Code:
; The word i wanna find
Inputbox, Search

Line = 0
Start:
Line += 1
FileReadLine, Word, List.txt, %Line%
%%% Function that checks if %Line% contains any of letters from the %Search% variable.

; Im properly in a document so..
Send %%% The output from that function%%%
goto start


I hope you can understand. I haven't learn't any more effective way yet.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 9:26 pm 
Like :

Code:
ahh = Wooahh, Vahoahh
Tie = Cattie, Tuttie, Futtie, Wootie


I think would be the best way.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 9:27 pm 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
Use a file parsing loop if you plan to look through an entire file

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 9:28 pm 
It should be like when i search for example "god", then i'll also get the word "dog" as it contains the same letters.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 9:39 pm 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
So you're doing anagrams then?? Nevermind regex isn't the best way to do it then.

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 9:43 pm 
I'm sorry.
I just want a function which checks if A contains the letters from B. If it does it could return 1 or something and if it doesn't it could return 0.

Is there something for that?

I'm getting a little confused now.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 10:22 pm 
Offline

Joined: July 25th, 2006, 9:06 am
Posts: 51
Not sure where you end solution is going but my Anagram program will do what you want.
program here
http://www.autohotkey.net/~peterm/My_Anagram-V6j.ahk

Simle instructions are here.
http://www.autohotkey.net/~peterm/Anagr ... 20file.rtf

dictionary if required is at
http://www.autohotkey.net/~peterm/Words.db

Too make the program do what you want.
Start program
Menu/dictionary/make new dictionary
This will ask for your text file.
It willl create a new file called New_Dictionary.txt
Now use
Menu/dictionary/Change dictionary
Select the New_Dictionary.txt file
Now type the letters you want into edit box e,g, HH.
Select command "All words with these letters"
and it will find you VAHOAHH and WOOAHH
Click Save Words and you have a text file alled Saved_words.txt.

A bit round about but perhaps does what you want (I think).

P


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Amandaville, Exabot [Bot], patgenn123, poserpro, Yahoo [Bot] and 20 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group