Thank you all for the replies thus far. 

For MM - I'm using Photo Mechanic, yes, although the hierarchy was 
recognized by Capture One when I imported it as a test as well. The keyword 
list is just saved as a .txt file, and the tab/bracket hierarchy for a 
structured keyword list such as this is pretty standardized. I actually 
can't speak for Lightroom because I don't use it a lot, but I imagine it 
would be similar, if not identical. Merging into JSON would maintain the 
existing hierarchy? Could you recommend a program or method to do this? 
Also out of my wheelhouse.

For Bruce - To clarify on what I'd like to happen, I'd like this, my 
original list - 

        ambition
            {ambitious}
        ancient
        train
        ancient civilization
        apex
            {#1}
            {number 1}
        appetizing
        apprehend
        approach
            {approaching}
        approachable
        approval
            {approve}
            {approving}
        email
        embryonic
        emotion
            {emotional}
            {emotions}
            affection
                devotion
                fondness
                love
                passion
                sympathy
                tenderness
                warmth
            agitated
                {agitation}
                flustered
                frantic
            amusement
                {amused}
                {amusing}
        ego
        elegance
        embarrassment
        emergence
        empathy
        emphasis
        enchantment
        encouragement
        ending
        endurance
        energy
        enhancement
        enjoyment
        ennui
        enthusiasm
        envy
        equality

to become the below - ego, elegance, embarrassment and emergence have moved 
upward into the list on the same 'level' and filed in the appropriate place 
alphabetically. The 'top level' is the one furthest to the left. Layers 
tabbed in one level are the next level. And so forth. 

I believe sorting while maintaining white space indentation would solve my 
issue, yes. The indentations on this list are all tabs. I want to force 
only the top 'level' into alphabetical order while making sure that 
subsequent layers remain children to their parents. For example, 'apex' is 
in my list with two synonyms, {#1} and {number 1}. If apex needs to be 
moved to another location on the list, I need those two bracketed items to 
go along with it. That will keep my hierarchy intact.

Some layers need shifted to make the top levels 'match' between the two 
lists, but I've figured that out myself in BBEdit. I've prepped things so 
nothing needs to be shifted during the sort. Does this clarify things?

        ambition
            {ambitious}
        ancient
        train
        ancient civilization
        apex
            {#1}
            {number 1}
        appetizing
        apprehend
        approach
            {approaching}
        approachable
        approval
            {approve}
            {approving}
        ego
        elegance
        email
        embarrassment
        embryonic
        emergence
        emotion
            {emotional}
            {emotions}
            affection
                devotion
                fondness
                love
                passion
                sympathy
                tenderness
                warmth
            agitated
                {agitation}
                flustered
                frantic
            amusement
                {amused}
                {amusing}
        empathy
        emphasis
        enchantment
        encouragement
        ending
        endurance
        energy
        enhancement
        enjoyment
        ennui
        enthusiasm
        envy
        equality

For Greg - there may be more than two indents. Yeah, I just noticed elegant 
myself as I typed this reply. That was my mistake when copy/pasting 
earlier, there aren't any mistakes like that in the actual list itself. 
I'll definitely look into your approach as well, it's much appreciated.

On Saturday, October 8, 2022 at 6:37:19 PM UTC-4 gjrice wrote:

> This is a pedestrian solution from a non-coder, just done step by step, so 
> I can check if I’m getting the expected result and backing up if not. 
> Fortunately BBEdit is zippy quick and believes in CMD-Z. I’m sure someone 
> who has actual skills will supply a more elegant solution.
>
> convert spaces to tabs - email text has spaces
> replace ^\t\t with nothing - (strips out the 2 leading tabs at the 
> beginning of each line)
> replace \t\t with \t@ - all remaining double tabs reduced to one tab and @
> replace \n\t with @ - all indented items are now in the line following the 
> term to be alphabetized, with the indentation tier coded as @s
> sort lines - as it says on the tin
> replace @@ with @\t - decodes second-tier terms by one tab
> replace @ with \n\t - finishes replacing the tabs and puts terms back on 
> their own lines
>
> This assumes that there ar no more than two indented levels, and that the 
> indented terms are wanted in their existing order. Doing the alphabetizing 
> on those levels would have to deal with disregarding the brackets, and I 
> suspect that a clever data structure would help. Note that input data 
> errors do exist: "elegant" should probably be on its own line, unindented, 
> for example, so you may have a few more things to account for.
>
> Greg
>
> > On Oct 8, 2022, at 5:22 PM, Media Mouth <[email protected]> wrote:
> > 
> > Following. Sure is an interesting challenge.
> > 
> > It'll be cool of someone with mad GREP skills has a brilliant solution.
> > What seems like might work more easily would be to convert the lists to 
> JSON data, merge them, then sort, then convert back to the tabbed format of 
> your example.
> > 
> > Out of curiosity, what system is making use of keyword formatting in 
> your example. Photo Mechanic? Wondering if it's mostly proprietary or if 
> it's a standard keyword categorization system that's in wider use.
> > 
> > - MM
> > 
> > 
> > 
> >> On Oct 8, 2022, at 1:57 PM, Matthew Bender <
> [email protected]> wrote:
> >> 
> >> Hi all,
> >> 
> >> I'm a photographer, and my experience sorting with GREP is incredibly 
> minimal. If this can't be done - apologies! 
> >> 
> >> I'm building a structured hierarchal keyword list for stock photography 
> purposes. I aquired two separate pre-assembled lists. Both did certain 
> things better than the other. I want to combine keyword groups across these 
> two lists into one large, alphabetized group that maintains the established 
> hierarchy. 
> >> 
> >> Most keywords are simply words, but a few involve numbers (#1, for 
> example.). Being hierarchal, it's been built out using tabs to communicate 
> nested levels and curly brackets to communicate synonyms. An example is 
> below, the spaces are all tabs.
> >> 
> >> ambition
> >> {ambitious}
> >> ancient
> >> train
> >> ancient civilization
> >> apex
> >> {#1}
> >> {number 1}
> >> appetizing
> >> apprehend
> >> approach
> >> {approaching}
> >> approachable
> >> approval
> >> {approve}
> >> {approving}elegant
> >> email
> >> embryonic
> >> emotion
> >> {emotional}
> >> {emotions}
> >> affection
> >> devotion
> >> fondness
> >> love
> >> passion
> >> sympathy
> >> tenderness
> >> warmth
> >> agitated
> >> {agitation}
> >> flustered
> >> frantic
> >> amusement
> >> {amused}
> >> {amusing}
> >> ego
> >> elegance
> >> embarrassment
> >> emergence
> >> empathy
> >> emphasis
> >> enchantment
> >> encouragement
> >> ending
> >> endurance
> >> energy
> >> enhancement
> >> enjoyment
> >> ennui
> >> enthusiasm
> >> envy
> >> equality
> >> 
> >> This example shows what I'd like to do - I want to merge the bottom set 
> (ego to equality, this came from one list) into the top set (ambition to 
> emotion, this came from the other list) alphabetically while maintaining 
> the synonyms and nested structure. Is there a way to just sort data on the 
> 'top layer' alphabetically (and accounting for the 1% of kewords that are 
> things like #1 and the special characters like the curly brackets) while 
> maintaining the established hierarchy? My attempts so far leave things 
> alphabetically ordered, but the nested layers and top layers get all 
> jumbled together and the structure is completely broken. It alphabetizes 
> every single word, which isn't what I want at all.
> >> 
> >> Any help or tips would be much appreciated. 
> >> 
> >> Thanks,
> >> -Matt
> >> 
> >> 
> >> -- 
> >> This is the BBEdit Talk public discussion group. If you have a feature 
> request or need technical support, please email "[email protected]" 
> rather than posting here. Follow @bbedit on Twitter: <
> https://twitter.com/bbedit>
> >> --- 
> >> You received this message because you are subscribed to the Google 
> Groups "BBEdit Talk" group.
> >> To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected].
> >> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/bbedit/d43d48c6-3181-457c-a29b-53f7a8ca5f8fn%40googlegroups.com
> .
> > 
> > 
> > -- 
> > This is the BBEdit Talk public discussion group. If you have a feature 
> request or need technical support, please email "[email protected]" 
> rather than posting here. Follow @bbedit on Twitter: <
> https://twitter.com/bbedit>
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups "BBEdit Talk" group.
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected].
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/bbedit/E6A4757E-1078-4F2B-8CCE-F5FECB95292C%40gmail.com
> .
>
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/968e00ad-fa55-49b5-a73d-e4688ed735aan%40googlegroups.com.

Reply via email to