-
Notifications
You must be signed in to change notification settings - Fork 1
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
Make reverse
recursive
#33
Comments
@xrotwang, would you agree with this? I would agree, since reverse has a direct use in morpheme segmentation (whwere we use the new classes). |
I wouldn't say that either type of reversing is more intuitive, but the clear use case of "going through the list backwards" seems to favor @arubehn 's idea. |
I think if we say that slicing only goes for the elements that are addressed, we can have a reverse() function that does a full reverse. But the case of w = Word.from_segments("a b c + d e f")
w[::-1] should probably yield: ["d", "e", "f"], ["a", "b", "c"] |
Oh, wait. What |
I was thinking about |
What about an independent function that just reverts a TypedSequence? It is really for the Word(Morpheme) case, so we can have some short cut: def revert(word: linse.Word):
return [morpheme[::-1] for morpheme in word[::-1] |
|
I'd suggest making the
reverse
function recursive; since I think that is the most common use case. For an exemplary Worda b + c d
,reverse()
would make itc d + a b
, swapping the order of the morphemes, but not the segments inside the morphemes. I think, in the regular use case, you would rather want to end up withd c + b a
.If you agree and think this is useful, I would quickly implement that; as it should be fairly simply.
The text was updated successfully, but these errors were encountered: