ESpringer Posted July 1, 2004 Posted July 1, 2004 At first I assumed it must be a piece'o'cake... I'd like to make a "commonsense key" for a biblio database by concatenating author's LName and the longest word in the title -- a pretty likely way to alert myself to matches between incoming pasted references and my existing records (given variations of citation style that would make a full concat unreliable). I know how to find *how long* the longest word is, but not how to get FM to return *it* (the longest word, or one among the set tied for longest) with a calculation (vastly prefer calcs to scripts, but colud be persuaded to bend here perhaps...). I can begin to concoct some convoluted and grizzly calcs, but before embarking I thought I'd ask for any tips from sharper minds... Thanks! (Once the problem is solved, I suppose I could make an FM7Dev "custom function" out of this: LongestWord(field)... Hm! )
-Queue- Posted July 1, 2004 Posted July 1, 2004 Well, I couldn't figure out how to do it with fewer than 4 extra fields, but here it is. Longword.zip
ESpringer Posted July 1, 2004 Author Posted July 1, 2004 Geee Tanks Queue! You've essentially tucked a related table for the title's words into repeated calcs... I hadn't thought of appealing to repetitions for that. I'm guessing that the "Let" function will enable me to generate something compact. If i understand it right (though I haven't used it much), it's basically there to allow all those calcs-along-the-way to stay tucked inside the ultimate destination calc... but it doesn't do repetitions, so... I'll play around a bit. It's impressive to have a cyber-connected solution that quick!
-Queue- Posted July 1, 2004 Posted July 1, 2004 True, you could use let to make Word: Let( p = Position( " " & Extend(title); " "; 0; Get ( CalculationRepetitionNumber ) ); Middle( Extend(title); p; Position( Extend(title) & " "; " "; 0; Get ( CalculationRepetitionNumber ) ) - p ) ). Any time you need to parse numbers or text individually or into separate groups, repeating fields can be highly useful, unless you prefer to use a script, of course.
ESpringer Posted July 1, 2004 Author Posted July 1, 2004 Gee, is that possible? ... Still not getting your Let version to work, may try later... I basically got a solution by turning the title words into return-delimited list of words with two-digit length numbers in front, so they sort in order of length, then getting my LongestTitleWord calc to look at that value list (via self-join) and pick the right-most value there (filtering out all but alpha)... but the calc simply will not refresh itself except when I tinker with the field definition... On to other tasks for now, alas.
-Queue- Posted July 1, 2004 Posted July 1, 2004 Yes, it should work. I just tested it, although I am working on the trial version at work. But I would hope v2 didn't break it. Is your calc unstored? Sometimes working with value list calcs requires a 'refresh' of going to the next record and back or entering find mode and going back to browse mode.
The Shadow Posted July 2, 2004 Posted July 2, 2004 This sort of thing is much easier done using a custom function, as you can use recursion to loop over the words: GetLongestWord( text ) = Let ( wordCnt = WordCount(text); Case ( wordCnt = 0; ""; wordCnt = 1; LeftWords( text; 1 ); Let ( [ firstWord = LeftWords( text; 1 ); rest = RightWords( text; wordCnt - 1 ); longest = GetLongestWord(rest) ]; If ( Length(firstWord) >= Length(longest); firstWord; longest )))) In English, if the number of words is zero or one, the answer is easy, otherwise compare the length of the first word with the length of the longest word in the remainder of the text.
ESpringer Posted July 2, 2004 Author Posted July 2, 2004 Shadow, This is just the kind of power I suspected was under the hood in FM7D. Thanks!!
ESpringer Posted July 2, 2004 Author Posted July 2, 2004 (Queue, I *was* able to get the Let function to produce the functionality of your Word field (which was all you had claimed actually), it was just getting the additional repeat variables to adhere to that first variable, within the same Let calc, that wasn't working out on my tries...)
Leader Posted July 9, 2004 Posted July 9, 2004 A couple of thoughts as to your original premise: I don't know how many bibliographies you intend to index, but if it's a large number, would the name and longest word be sufficient? Would the addition of a date help? For a truly unique index, the name, title, and date run through a CRC (cyclical redundancy check) generator would be ideal, except FM would probably take forever doing what assembler code normally does. An alternative might be a hash algorithm, not wholly unique but close. FYI: Depending upon how sophisticated your DB becomes, IBM used to be the 2nd largest publisher in the world, and for years used something they called KWIC, keyword in context, a way of indexing key phrases that could be looked up in their thousands of manuals. That might be useful for a sideways lookup.
Recommended Posts
This topic is 7783 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now