Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ordinal trees #22

Open
wants to merge 8 commits into
base: next
Choose a base branch
from
Open

Conversation

PeterHovanec
Copy link

Added support for ordinal trees

@tuplle tuplle changed the base branch from master to next November 14, 2024 22:46
@tuplle tuplle self-requested a review November 14, 2024 22:47
@tuplle tuplle added the enhancement New feature or request label Nov 14, 2024
@tuplle
Copy link
Owner

tuplle commented Nov 14, 2024

As I understand, ordinal trees are called ordinal because nodes are ordered by some logic.
Like here https://www.researchgate.net/publication/338911954/figure/download/fig1/AS:852883809501184@1580354754405/An-ordinal-tree-preorder-labeled-Sequences-top-Balanced-parentheses-sequence-BP.png

In your implementation, I see that every node has some value but I do not see the condition or some algorithm that sorts children of a node.
I think there could be an attribute of a tree class that is a function that compares two node's values. This function could be as parameter of the tree class.

Copy link
Owner

@tuplle tuplle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see any changes that are addressing my comment from last week ⬆️

@PeterHovanec
Copy link
Author

Hi! I apologize for my lack of communication.

As you noticed, I adapted what I had already done to the changes in the repository. I'm working on the implementation, and there should be relevant changes added by Monday.

I'm working on a way of organizing the values by pattern and repetition.
For example:

OT("((()", "repeat")

This would always add the fourth value to the left, causing the tree to skew.
Another example:

OT("((()", "bounce")

This would create the pattern: "((() )((( ((() )((("

When left empty, the values will simply be added in order.

If you have any further suggestions, I'll gladly work them in or adjust my approach.

@PeterHovanec
Copy link
Author

Hello! I have updated my approach.

Patterns are now specified as arrays of characters, for example:
["d", "q", "R"]

This pattern defines the order of children for each node, giving precedence to the specified characters. Words beginning with the letter "d" will always appear on the leftmost side of the tree.

If a word does not match the specified pattern, it will be ordered alphabetically, with preference given to uppercase letters.

I have also made it possible to define custom patterns for specific words. These custom patterns are combined with the global pattern. For example:

If the global pattern is ["d", "q", "R"]and you add a word with the pattern ["g"], the active pattern for that word will become ["d", "q", "R", "g"].

If you have any additional requests, please feel free to let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants