Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1 2 
Send Topic Print
Agent query to find a word in Attributes notes (Read 12382 times)
Denise
Full Member
*
Offline



Posts: 8

Agent query to find a word in Attributes notes
Dec 06th, 2012, 4:15pm
 
What I would like it to do is search the notes of a specific attribute and find those notes that contain certain words. I do not want it to return anything that does not have that specific attribute tied to it.

For example: I have attributes called Scene, Character, Place
I want to find when I have mentioned certain words in a Scene.

All I have managed to do is a Query "Text contains" from anywhere in my Tinderbox file. But what I cannot make it do is only query the notes of anything with the attribute "Scene" for those words.

I hope that I'm making sense and this is something that can be done.

Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Agent query to find a word in Attributes notes
Reply #1 - Dec 6th, 2012, 4:32pm
 
To look for data in the 'Scene' attribute, use $Query as you would where you see examples for querying $Name or $Text. I'm assuming in the following that $Scene is a String type attribute. To find only those notes with a value in $Scene, use either of the following as a query:

$Scene
$Scene != ""


The former is simply a short (and more easily remembered) way to write the latter. More usefully, find all notes whose $Scene contains the word "Woody":

$Scene.contains("Woody")

Find all notes whose $Scene contains the word "Woody" or "Buzz":

$Scene.contains("Woody") | $Scene.contains("Buzz")

Find all notes whose $Scene contains both the word "Woody" and the word "Buzz":

$Scene.contains("Woody") & $Scene.contains("Buzz")

Find all notes whose $Scene contains the word "Woody" but not the word "Buzz":

$Scene.contains("Woody") & !$Scene.contains("Buzz")

Note in the last how the '!' before the second term flips the meaning.

If $Scene is a list, the above work but slightly differently.  For a List.contains() search the match is always to entire discrete list items rather than any substring of the overall string as with a String.contains(). also be aware of the .icontains() test which does a case insensitive search - see the referenced links in aTbRef for more.


Back to top
 
« Last Edit: Dec 6th, 2012, 4:32pm by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Denise
Full Member
*
Offline



Posts: 8

Re: Agent query to find a word in Attributes notes
Reply #2 - Dec 6th, 2012, 4:49pm
 
I think I must be going about this incorrectly. I'm using the trial version to make a decision if I should buy this.

I realize now in order to run this query I would have to go in and type a string into the Attribute field. I thought that by giving it an attribute I could have it search the actual note field for certain words or phrases.

Maybe I should just ask this. How would I go about searching in certain notes for specific text. But I do not want it to search every note.

I'm using this to help me write fiction. I would like to know what scenes I've actually had characters in certain places. When I search for those characters and places now, I am getting information about them in notes about those characters and places. I only want information returned when those characters and places show up in the actual scenes that I've written.

I hope that makes sense, because I'm getting very confused.

Thanks for the help.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Agent query to find a word in Attributes notes
Reply #3 - Dec 6th, 2012, 5:30pm
 
Quote:
in order to run this query I would have to go in and type a string into the Attribute field

Actually, most likely you run the query in an agent.

Quote:
I thought that by giving it an attribute I could have it search the actual note field for certain words or phrases.

Yes this is possible. Indeed, Note A can search for/on data stored in an attribute in Note B.

Quote:
I would like to know what scenes I've actually had characters in certain places.

A more efficient way would be to make an agent for each character. That agent would search each (scene) note for the given character and list matching scenes.

Only want to search scene notes? Restrict your query. Here are two ways to find notes whose text contains "Woody" that are scenes. First, we assume that all scenes are children of note "Scene List":

inside("Scene List") & $Text.contains("Woody")

Scene notes not so easily corralled? Make a prototype for scene notes.  Let's assume you've do so and called the prototype "pScene".

$Prototype=="pScene" & $Text.contains("Woody")

In each of the last two examples, $Text is only tested for notes that pass the first part of the query. In either case you might have 4000 notes but 20 scenes. All 4000 would be tested by the first part of the query, in both cases returning 20 matches. Only the 20 matches would then get their $Text searched.

I realise you're just starting out and this may seem complex but do show more would involve building a TBX with all these structures including specimen data and unfortunately I've not got time to do that this evening.  But do keep the questions coming. I don't think you've asked to do anything that sounds impossible.

Tinderbox doesn't force you down a path, as might a Screenwriting-only app. However, an unavoidable aspect of building a Tinderbox tailored exactly to your needs is it has to be built from scratch. Help with that is just the sort of thing the forum's for. If you do go ahead and want help on a more formal basis that's possible too (but leave the detail of that for when/if its needed).
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Denise
Full Member
*
Offline



Posts: 8

Re: Agent query to find a word in Attributes notes
Reply #4 - Dec 6th, 2012, 6:37pm
 
Thank you so much, Mark! I cannot believe the prompt answers I have received from you and an email I sent to tech support.

I'm not sure I completely understand the "Scene List". Do you mean I should create a parent named Scene List and make sure all the scenes are children of that list?

I did understand the Prototype=="pScene" I made that work! I think I can now do searches that cross reference several characters and or places at the same time. That is exactly what I needed.

I watched all the Screencasts and read through lots of the other examples I could find on Wiki. I thought I had it down, but this is a very complicated program. I'll have to make up more sample files to make sure this is going to work for me, but so far it is looking good even though it seems a little confusing.

Again, I can't thank you enough. You have been extremely helpful. I might be back in the next few days as I play around with this more.
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Agent query to find a word in Attributes notes
Reply #5 - Dec 6th, 2012, 7:48pm
 
It's only complicated when it has to be!

For example, one writer ran into a situation a lot like yours -- a character list, and a bunch of scenes.  He was writing a musical, and so he had some interesting special needs:

- he can have as many minor characters as he likes, but there are only 8 people in the chorus. So you can only have eight minor characters in a scene.

- if you're doubling parts, you have to allow time for a costume change. So, if the same actor plays Bobby and Billy, the two of them can't be in the same scene -- and need a few minutes breathing space.

Yes, Tinderbox can even handle that!  But you probably won't need to.  But it's good to know you can do it, if you need it.
Back to top
 
 
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Agent query to find a word in Attributes notes
Reply #6 - Dec 7th, 2012, 3:49am
 
Complexity is in the eye of the beholder. If you react to  choice as complexity it's only too likely you will find it complex to choose the right thing. That's not to be harsh; it's a common reaction nowadays as everything is dumbed down. Removing choice makes things simpler - but offers less choice (for instance phone apps). Simplicity is easier to do within very defined contexts. TB lets you do pretty much anything, so choice is an unavoidable necessity. On top of that, TB's constantly evolving so changing what's possible (even most minor releases add or expand something).

Quote:
I'm not sure I completely understand the "Scene List". Do you mean I should create a parent named Scene List and make sure all the scenes are children of that list?

Ah, I think you read that too literally.  In order to show you how inside() works, the action needs to refer to the name of a container note, it being the containing object within which the notes of interest lie. I just thought that a likely name for a container notes about scenes might be "Scene List" so I had a name  to use in the code example. Were you to call such a container "Something Else" the previous code example would change to

inside("Something Else") & $Text.contains("Woody")

In fact, inside() uses as its argument either the title ($Name) of a note or - if the latter isn't unique, it uses the path ($Path) of that note.

Note also the difference in scope between inside("X") - X's immediate children only - and descendedFrom("X") which looks at all X's descendants.

All that said, whether you put all scenes in one container, or perhaps in set of 'Act' containers or such, or scatter them more widely is pretty much down to personal style and whatever else you want do (e.g. export data). If you use prototypes, you can start with a scattered approach because as the plot takes more form you can use an agent to find the scenes, from wherever they are, and use the resulting list to start importing more order, e.g. my moving the notes into a more ordered layout (perhaps in order to aid export of info).

Re the wiki. Whilst there are lots of ideas discussed there, many of the code examples use what is now deprecated syntax, e.g. hash-prefixed query terms like #inside now no longer exist. Your best reference for syntax for action code is aTbRef - which I've already been linking to in answers above.
Back to top
 
« Last Edit: Dec 7th, 2012, 6:44am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Agent query to find a word in Attributes notes
Reply #7 - Dec 7th, 2012, 6:18am
 
Partly prompted by this, I've added (and linked elsewhere in aTbRef to) some new aTbRef pages:
Anyway, I've added these new pages in the Objects & Concepts section:
These might help clarify how you ask/tell Tinderbox which note(s) which you wish to query or alter via action code.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Agent query to find a word in Attributes notes
Reply #8 - Dec 7th, 2012, 9:53am
 
Had to wait for a call… so I had a chance to sketch a few things discussed above (using v5.11.2). Download my plot-sketch TBX and have a tinker.  Caution: it's not saying this is how your task must be done. Rather it's showing some methods to do do the things you've raised.  I realise now that I was thinking screenplay rather than fiction but frankly it doesn't alter anything.



I won't try and explain everything but I will mention some things you might not guess:
  • The Prototypes container disabled rules and display expressions. I've found by experience this is normally what you want. Look up $RuleDisabled to see what this implies.
  • The action for the agent is too long to type in the box on the rename dialog. So we use a trick usually referred to as a 'code note' (see more) to write the code in another note that then sets the query correctly.  Can you find where I've stored that code?.
  • That same query uses a quite complicated - for TB code - method to list and update the characters used in a scenes text via the '.each()' operator. Alos see the use of values().
  • If you re-order acts or scenes notice how they are renumbered.
  • Using .icontains() allows us to test for a character's name case insensitively. IOW, "Woody" will match "woody", WOODY", etc.
  • Make sure to check out the $OnAdd code for some containers
In closing I repeat, this is just a demo of some technique and to give a reference for discussion. Some things here require a certain layout but most don't.

Separately, don't feel you can't start writing actual prose/dialogue before you've figured the structural elements like above. Tinderbox is atypically forgiving of adding structure late in the game.
Back to top
 
« Last Edit: Dec 7th, 2012, 10:50am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Sumner Gerard
Full Member
*
Offline



Posts: 359

Re: Agent query to find a word in Attributes notes
Reply #9 - Dec 7th, 2012, 12:42pm
 
Just wanted to express appreciation to Mark A for that example TBX.  It's a gem for understanding ways to harness Tinderbox's power.
Back to top
 
 
  IP Logged
Denise
Full Member
*
Offline



Posts: 8

Re: Agent query to find a word in Attributes notes
Reply #10 - Dec 7th, 2012, 4:18pm
 
Wow, I am just floored. My mind was already heading down the road to find a way to list all the characters in a scene, and you beat me to it. Which isn't that difficult, because I can't even pretend that I understand all that code. I know I couldn't have done half of that while waiting on a call.

So this is what I think I understand about what is happening in that file:
* I know you are calling on the cCharacter_in_Text somehow. I think you have stored the value of $Text there, but I could be completely wrong about that.
* I believe that the agent is what fills in the "Characters" column with the characters who appear in each scene. A very helpful little trick.

The trial is telling me that I cannot add anything else to this sample file of yours, so I can't play around with it too much. I'm assuming that a few more items could be added so that you could do the same thing with Locations like you have done for character.

Would there be a way to have it place those values somewhere besides the column? Something that could be stored as it's own piece of data, another note perhaps? And I'm probably asking too much, but I'm assuming that the number of times a character appears in a scene could be added as a count? I did look over some of the Tinderbox Reference file you linked to, and some of the commands there seem to open up amazing potential. The only thing holding me back is my own ignorance.

You do not have to answer all my questions with the actual code, unless of course you want to! I would love to look at it. I'm just trying to make a decision on if I could actually make use of all of this potential if I purchased Tinderbox. I'll never be accused of being a ninja code monkey.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Agent query to find a word in Attributes notes
Reply #11 - Dec 7th, 2012, 4:51pm
 
The 'code note' trick is we store a long/involved bit of code in a note and use its rule (take) a look) to set an attribute in another note - in this case a query in an agent.

Quote:
The trial is telling me that I cannot add anything else to this sample file of yours

Oh dear no!  Experiment away, add to it as you like. What I was trying to say is don't feel obliged to use that as a base. I was implying that you should instead just borrow (copy!) the ideas to use in your own file. But, please don't feel you can't just build off my file if that's what you want.  I just knocked it up as an example - it's free there for you or anyone to use as they choose. The point in copying the code to use elsewhere is simply so my random ideas don't constrain your own creativity.  Smiley

Quote:
Would there be a way to have it place those values somewhere besides the column?

Look up column view. It's simply a turn on/of method - in Outline view - of showing data. It doesn't store anything. rather, it just displays the values of what every you choose to show in that column. In the screen grab I used it as a quick & dirty tell-back of whether my code was setting the $Characters attribute value correctly.

Don't be cowed by your perceived ignorance - really, we all start somewhere. Just start trying things. As I've probably said, start small. Try little things first. Don't be afraid to make a new file - you don't even need to save it - to try a new technique. If the new idea doesn't work, at worst you get some frustration but nothing breaks.

Ah - the demo mode. Yes, it limits you to (IIC) 20 new notes. But, you can edit existing notes. So, by editing the notes already in the document (and adding a few more) you should have more than enough to test your ideas within the demo. Want to try 2 different ideas in the demo  and running out of notes? Try one idea in one file then start over to try the other idea. It's not that big a constraint (and as a fellow user I've no control over what the demo offers). I accept that in demo mode you can't easily start writing your actual content as that likely will fill up the allowed note limit.  Mea culpa - I forgot you were using the demo.

Location?  Yes, that was there as a prod that you can use the same concept it used with characters with other aspects of your plot.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Sumner Gerard
Full Member
*
Offline



Posts: 359

Re: Agent query to find a word in Attributes notes
Reply #12 - Dec 7th, 2012, 5:57pm
 
Quote:
I'm just trying to make a decision on if I could actually make use of all of this potential if I purchased Tinderbox.

I'm a nontechnical user who puzzles through Mark A's code examples like this one to figure out how they do what they do.  After some years of use, I've realized I'll never feel confident I'm using all of Tinderbox's power. I suspect other users may have the same feeling. But I've concluded that the parts I can use are worth the price. Most are quite simple, possible in other Mac applications, but not as easy or flexible there.  Timeline View is a good example.

An important part of Tinderbox's value proposition is the quality of the detailed, practical answers that appear seemingly before finishing an email to support or a post to this forum. Smiley
Back to top
 
 
  IP Logged
Denise
Full Member
*
Offline



Posts: 8

Re: Agent query to find a word in Attributes notes
Reply #13 - Dec 7th, 2012, 6:16pm
 
Thanks again, Mark. I was able to take what you did and transfer it to another document that I created. I had columns listing both the characters and the locations for each scene. Very fancy.

I have not had a chance to try to collect that data into a file or add the counts that characters appear per scene. Hopefully I'll have time to look at that this weekend.

I did like your sample file. I think that would be a nice template to start with until learning more of the code.
Back to top
 
 
  IP Logged
Denise
Full Member
*
Offline



Posts: 8

Re: Agent query to find a word in Attributes notes
Reply #14 - Dec 7th, 2012, 6:26pm
 
Sumner, I must agree with you on the quality of support via email or the forum. I have never had such rapid fire responses packed full of information.

I'm glad to hear I'm not the first one approaching this software feeling a little overwhelmed and wondering if I could actually make use of it. Do you think there are enough examples online that can be found to sort of "borrow or strip" the code out of? I'm not sure I could ever come up with what Mark put into that simple file he slapped together. That makes me wonder if I would just give up on the program in frustration shortly after purchasing it. I think with enough sample files maybe I could wrangle a few useful building blocks for myself. Have you found helpful examples that helped you grow your own files?
Back to top
 
 
  IP Logged
Pages: 1 2 
Send Topic Print