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

Alphabetized Autocomplete #188

Closed
15 tasks done
andrewtavis opened this issue Aug 9, 2022 · 82 comments · Fixed by #206
Closed
15 tasks done

Alphabetized Autocomplete #188

andrewtavis opened this issue Aug 9, 2022 · 82 comments · Fixed by #206
Assignees
Labels
-next release- Included in the next release feature New feature or request help wanted Extra attention is needed

Comments

@andrewtavis
Copy link
Member

andrewtavis commented Aug 9, 2022

Terms

Description

This issue is to add an initial auto-suggest feature to Scribe, and is the first part of #3. Work for this will be done in relation to #187 for the Wikimania Hackathon.

This issue comprises:

  • Finding resources for a function to find the next words alphabetically
  • Figuring out which words should be suggested to the user
    • At the start, just nouns
  • Removing the command bar unless the keyboard is in command mode
    • Annotations need to show up after a user presses space still
    • The coloration likely needs to change to keyboardBgColor, as making it clear would prevent annotations from being presented
  • Fixing the coloration of characters on annotations to match the new background
  • Properly styling the Scribe key corners/shadow when the command bar is removed
  • Putting two lines between the command buttons to delineate them when they have no background (@andrewtavis)
    • Add the lines to the .xib file
    • Create functions that allow them to be added and removed
    • Removing the left line if an annotation of long enough length is being shown
      • This needs to be done in the function to show the lines
      • Checking the length of the text in the command bar is the likely method for this
  • Make the command buttons user interactable when an autocomplete would be possible
    • The buttons work now, and are conditionally deactivated if an annotation is happening based on the length of the annotation
  • The creation of a function to find the three next words in alphabetical order to the currently typed word in the proxy
  • Assigning those three words to the command buttons
  • Running the function and doing the assignment each time a key is pressed (within loadKeys())
  • Inserting the word on a button to the text field when a user presses an auto suggest button

Contribution

I'll be working on this with @SaurabhJamadagni :)

@andrewtavis andrewtavis added feature New feature or request good first issue Good for newcomers help wanted Extra attention is needed -priority- High priority labels Aug 9, 2022
@andrewtavis andrewtavis changed the title Alphabetized Auto Suggest Alphabetized Auto Complete Aug 11, 2022
@andrewtavis andrewtavis changed the title Alphabetized Auto Complete Alphabetized Autocomplete Aug 11, 2022
@andrewtavis
Copy link
Member Author

@SaurabhJamadagni, I added something to the above, as we need to remember that even though the command bar won't be on the screen always, we're still going to need to use it to do noun and preposition annotations. Here's again the picture of eventual coloration in autocomplete:

https://user-images.githubusercontent.com/24387426/182542168-f8e337f4-4709-413c-86e4-e6ded470eed7.png

For annotation we're going to want to remove the lines, and then we can use the command bar with a transparent background to still do annotation as before (none of the command buttons would appear). Remember that the difference here is that annotation happens after space, so we won't be showing suggestions at this point yet (that's autosuggest, rather than autocomplete).

@SaurabhJamadagni
Copy link
Collaborator

@andrewtavis, I'm not clear on what you mean by annotations after space. Could you give me an example? Do you mean that the word suggestions will show up alphabetically even if the user just adds a space at the start?

@andrewtavis
Copy link
Member Author

Hi @SaurabhJamadagni :) What I mean by this is the noun genders that are shown to the user after they press space. So as the user is typing a word we want to show them autocomplete suggestions, and after they’ve pressed space we show them annotations as we do now. Rather than being “on the command bar,” they’ll be next to the Scribe key and still will be the bar text, but the command bar will be transparent.

@SaurabhJamadagni
Copy link
Collaborator

Ohhh I understand! So basically, we are just going to make the command bar transparent. When the user is typing, the suggestions will be shown with the vertical dividers. At other times, our prompts will be shown like we have right now. Is that correct @andrewtavis?

@SaurabhJamadagni
Copy link
Collaborator

Also @andrewtavis, while playing around with the command bar, I came across a bug right now. Can you check if you are experiencing it too? Basically the prompt that says what the command does, doesn't change colour when you switch appearance modes. But if you exit command mode and go back again, then it works fine. The placeholder text does change colour though.

Steps to replicate it:

  1. Select any command.
  2. Change from light to dark mode or vice-versa without typing so that the prompt stays.

Images:
Before changing appearance mode:
IMG_2957

After changing appearance mode:
IMG_2958

After pressing 'x' and choosing the command again:
IMG_2959

Seems like a minor bug which we could get to later. Unless it's just a my device glitch 😅

@andrewtavis
Copy link
Member Author

Ohhh I understand! So basically, we are just going to make the command bar transparent. When the user is typing, the suggestions will be shown with the vertical dividers. At other times, our prompts will be shown like we have right now. Is that correct @andrewtavis?

Exactly :) Sorry for being a bit confusing in the explanation! Hard to wrap around all the little things to change.

Per bug that you found, I can reproduce as well. It's likely something simple like making sure that the colors are being changed within checkDarkModeSetColors. Dark and light mode switching was the first major bugs for Scribe - basically didn't work 🤦‍♂️🤣 Not surprised that there's an issue, and we should definitely fix it, but then it's also very unlikely that a user will experience it.

Do you want to make the issue, or should I? If you come across something, feel free to open a bug. If you're seeing it, then it should at least be checked, which is worth an issue 😊

@SaurabhJamadagni
Copy link
Collaborator

Dark and light mode switching was the first major bugs for Scribe - basically didn't work 🤦‍♂️🤣 Not surprised that there's an issue, and we should definitely fix it

I see 😂 Let's fix it but definitely not a priority.

Do you want to make the issue, or should I? If you come across something, feel free to open a bug. If you're seeing it, then it should at least be checked, which is worth an issue 😊

I'll create the issue. A little experience with that too. Never raised an issue before haha. Thanks for confirming! 😊

@andrewtavis
Copy link
Member Author

@SaurabhJamadagni, here are some directions based on what I've been working on:

I think the function to assign the buttons should be called within conditionallySetAutoActionBtns, which is ran after each key press. The function should find the next three nouns, and that function will assign the words to the buttons that need to be set. I'll look into making case "AutoAction1", etc conditions within executeKeyActions so that we're ready when the function's up and running :) That should be pretty simple 😊

@andrewtavis
Copy link
Member Author

@SaurabhJamadagni, I think that the above is about as much as I should do on this to make sure that you can have a substantial contribution :) 3dc751d allows the keys to be assigned labels in conditionallySetAutoActionBtns, and there are now cases in executeKeyActions to insert the key text, add a space, and check for annotation 😊

If we can't check in before the presentation (I think that what we have so far is presentable btw), then I'm seeing in the schedule that the open hacking space is available right after. We can jump in there and talk things over, or also do a call on Google Meet :) :)

Hope you're having a nice time with your family!

@SaurabhJamadagni
Copy link
Collaborator

Thanks @andrewtavis! You were able to get so much done 🤯

I was playing around in Playgrounds to test out different approaches to the function and I think I have something that might work. I'll get to making that addition. Thanks for all the changes you made! I'll check back in once the changes are made. If I am not wrong, I have to checkout the feature branch you have created and push my commits to the same branch right? Or do I create a new branch? Again, sorry for these doubts right now. They are definitely not adding to the productivity 😅

@andrewtavis
Copy link
Member Author

Welcome and thank you, @SaurabhJamadagni! It was nice to really code in here agin 😇

Checking out the feature branch and pushing your commits to the same one is exactly what you should do :) Not sure if you need/want to, but you can also review/accept the changes in the PR if you want to understand the changes I made. Up to you, as we can just test later and figure it out!

Looking forward to the function! I doubt that I'll add that into the presentation given timing, but if we can get it done by the showcase, then that'd be 🔥

Let me know if you have questions or need any help!

@SaurabhJamadagni
Copy link
Collaborator

Function to find the next three words

func getAutocompleteWords() {
  let keysOfNouns = Array(nouns!.keys).sorted()
  if let inString = proxy.documentContextBeforeInput {
    let stringOptions = keysOfNouns.filter { item in
         let stringMatch = item.lowercased().range(of: inString.lowercased())
        return stringMatch != nil ? true : false
    }
    
    if stringOptions.count <= 3 {
        completionWords = [String](stringOptions)
    } else {
        var i = 0
        var threeWords = [String]()
        while i < 3 {
            threeWords.append(stringOptions[i])
            i += 1
        }
        completionWords = threeWords
    }
  }
}

@andrewtavis
Copy link
Member Author

Sorry for what likely are some confusing PR notifications, @SaurabhJamadagni :) It's all figured out now. Next time I'll know to first merge your branch into mine and then go from there.

As I mentioned, before tomorrow I'm going to try to work on the latency a bit by creating a sorted array with words that lack hyphens. I'm thinking that doing that might speed up the assignment a bit, as as of now we're creating and sorting a very large array every time we want to update the keys. It'd also be good if we always assign the "next thing in the list" even if there's nothing that comes after. Would be good to basically just fill in the next word in the list in this case.

If you have suggestions, then I'd be happy to hear them! Thanks again and again 😊

@andrewtavis
Copy link
Member Author

Just played around some more 😊 This is so great! 🥳

@andrewtavis
Copy link
Member Author

@SaurabhJamadagni, a5ea9ea is a lot of refactoring that was long overdue, and does fix some issues with invalid messages not being presented properly, but we still have the unfinished points I mentioned here before we can close this. A lot closer though with how much easier checking flows should be!

@SaurabhJamadagni
Copy link
Collaborator

A lot closer though with how much easier checking flows should be!

Couldn't agree more @andrewtavis! Sorry for the slow responses. These are a lot of changes combining all the three issues we are currently working on. I was just taking the time to process them and make a game plan for myself.

On a slightly unrelated note, can you explain me what the issue #201 that you have created would do? I tried to go through the documentation on UILexicon but I did not understand that clearly. Is it basically like the user creates a key 'tbh' which automatically gets expanded to 'to be honest'?

andrewtavis added a commit that referenced this issue Sep 4, 2022
#188 refactoring incl commandState to enum
@andrewtavis
Copy link
Member Author

These are a lot of changes combining all the three issues we are currently working on. I was just taking the time to process them and make a game plan for myself.

Yes, I agree that it's kind of a lot right now, and I'm sorry for that. I'm very much looking forward to when this is all done and we can look at the issues and be like, "Which small issue that's not really related to the others would we like to work on now?" 😄😊

@andrewtavis
Copy link
Member Author

I think that getting this one done will be a big weight off, @SaurabhJamadagni. As soon as we're done here, #194 should be straight forward. You again can start working on that if you'd like :)

@andrewtavis
Copy link
Member Author

andrewtavis commented Sep 4, 2022

We're now down to these last two issues, @SaurabhJamadagni! 🥳

  • Fix a bug where delete at the start of the proxy now crashes the keyboard
  • Fix a likely related bug where once a user starts typing in a command delete will end the command/crash the keyboard

As I said in the above PR, if you can get these bugs that'd be really great 😊 Let me know on all this :)

@SaurabhJamadagni
Copy link
Collaborator

Yes @andrewtavis, I am currently working on the above. I'll try to share a small code snippet by evening that I wrote for #194 that selects the next three words from the common words array which will be a part of the JSON. I am currently reading a few articles on debugging to help me get tracking the above two bugs. I'll have an update soon hopefully 😅

andrewtavis added a commit that referenced this issue Sep 5, 2022
#188 #194 autocomplete bug fix and autosuggest placeholders
@andrewtavis
Copy link
Member Author

andrewtavis commented Sep 5, 2022

Sounds great, @SaurabhJamadagni! Feel free to share what you learn when we do the next call 😊

And just FYI, the structure of the autosuggest array will be the following:

{
"word": ["option", "option", "option"],
"word": ["option", "option", "option"],
...
}

@SaurabhJamadagni
Copy link
Collaborator

Hey @andrewtavis, two more minor bugs that I noticed that could be added to the list are:

  1. Long words stop getting the ... for some words.

image

  1. We can't select a bunch of text and delete it all at once. It leads to the bobbing of the keyboard just like with the delete crash.

image

I think I will need your help with the delete crash issue. I read up on debugging and some of the things are very clever but when I run the project, the code just won't stop at the breakpoints. I think it's not letting me run in debug executable mode. Trying to figure it all out. Sorry for taking so much time to fix this bug. Hoping to get it soon.

@andrewtavis
Copy link
Member Author

Hi @SaurabhJamadagni, no stress on timing! I wouldn't have had time to review this week anyway as I've been very busy for work. To the above:

  1. I noticed this as well, but it's going to be fixed in Update Annotation Formatting #197, as the words won't be showing anymore at all :)
  2. Noted, and thanks for finding it! I'll add it to the list above so we remember to check for it.

I also tried a bit to figure out debugging, and it also wasn't stopping at the breakpoints... Take your time on all this - we'll get it soon! 😊

My plan is to work a bit on #197 in a branch tomorrow. I'll start by removing the current UI elements in the .xib, and then I'll rewrite the functions to generate the annotation icons without the words. I'll be in the US visiting friends and family from the 16th to the 25th, but I should still have time to work on all this. My personal goal is to have v2.0.0 released by around the 25th, so two weeks :)

@andrewtavis
Copy link
Member Author

@SaurabhJamadagni, on second thought, the second point below is a feature that was never implemented :) Good work on finding it! I'll make a separate issue for it :)

@andrewtavis
Copy link
Member Author

andrewtavis commented Sep 10, 2022

@SaurabhJamadagni, hope it's ok that I went ahead and made these fixes :) I was checking the delete codes to maybe fix the issue with selected text deletion as you suggested, and then realized the issues d69bad8 wants to address. Figured since I'm looking at it, just see if I can get it done 😊

Hopefully merging #206 will complete this, and then we can shift to the annotation fixes and autosuggest 🚀

@SaurabhJamadagni
Copy link
Collaborator

hope it's ok that I went ahead and made these fixes :)

Absolutely @andrewtavis! I'll review the PR in a bit. I definitely want to know what was the problem as this bug really got under my skin haha! Thanks 😊

@SaurabhJamadagni
Copy link
Collaborator

@SaurabhJamadagni, on second thought, the second point below is a feature that was never implemented :) Good work on finding it! I'll make a separate issue for it :)

Thanks! I think this works in the production version though that is currently in the app store. I think it stopped working during all the changes that we created. Can you check if that's the case? 😅

@andrewtavis
Copy link
Member Author

Thanks! I think this works in the production version though that is currently in the app store. I think it stopped working during all the changes that we created. Can you check if that's the case? 😅

Yes, you're right, @SaurabhJamadagni :) It works on my phone on the current version. I just checked and d69bad8 removes that bug as well. I guess I just figured that we'd need to implement something to have the selected text be deleted, but there's something going on under the hood to replace it :) I'll delete #205 😊

andrewtavis added a commit that referenced this issue Sep 11, 2022
#188 fix to delete crash + minor template change
@andrewtavis
Copy link
Member Author

Well, @SaurabhJamadagni, that was quite the issue 😊 Glad to have it done, and our path to v2.0.0 is a lot more clear :) You're welcome to start working more on functions needed for #194 (I'll write a bit in there now), and I'll start on #197 :)

@SaurabhJamadagni
Copy link
Collaborator

Glad to have it done, and our path to v2.0.0 is a lot more clear :) You're welcome to start working more on functions needed for #194 (I'll write a bit in there now), and I'll start on #197 :)

Awesome @andrewtavis! I am super excited about finishing this issue as well! On to the next 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-next release- Included in the next release feature New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants