| View previous topic :: View next topic |
| Author |
Message |
BattY Guest
|
Posted: Wed Nov 19, 2008 7:31 pm Post subject: Search for keywords in a .txt |
|
|
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! |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Wed Nov 19, 2008 7:40 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
BattY Guest
|
Posted: Wed Nov 19, 2008 7:56 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Wed Nov 19, 2008 8:07 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
BattY Guest
|
Posted: Wed Nov 19, 2008 8:09 pm Post subject: |
|
|
Thank you, i'm gonna read about it now.
I hope i'll get it to work  |
|
| Back to top |
|
 |
BattY Guest
|
Posted: Wed Nov 19, 2008 8:14 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
BattY Guest
|
Posted: Wed Nov 19, 2008 8:25 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
BattY Guest
|
Posted: Wed Nov 19, 2008 8:26 pm Post subject: |
|
|
Like :
| Code: |
ahh = Wooahh, Vahoahh
Tie = Cattie, Tuttie, Futtie, Wootie
|
I think would be the best way. |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Wed Nov 19, 2008 8:27 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
BattY Guest
|
Posted: Wed Nov 19, 2008 8:28 pm Post subject: |
|
|
| It should be like when i search for example "god", then i'll also get the word "dog" as it contains the same letters. |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Wed Nov 19, 2008 8:39 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
BattY Guest
|
Posted: Wed Nov 19, 2008 8:43 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
peterm
Joined: 25 Jul 2006 Posts: 51
|
Posted: Wed Nov 19, 2008 9:22 pm Post subject: |
|
|
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/Anagram%20program%20instruction%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 |
|
| Back to top |
|
 |
|