Jump to content

This topic is 7512 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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! wink.gif )

Posted

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!

Posted

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. wink.gif

Posted

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.

Posted

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. shocked.gif

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.

Posted

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.

Posted

Shadow,

This is just the kind of power I suspected was under the hood in FM7D. Thanks!!

Posted

(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...)

Posted

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.

This topic is 7512 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.