Chris TCC
❔ store data like a filesystem
I'm working on an app, where the data structure is as follows:
Group -> subgroup -> values
The user can create groups, name them, and add subgroups inside them. The subgroups can have names too, and contain a list of int values. The app will then do some comparisons and list the smallest int value given some conditions etc. (That part isn't too important)
How I currently do this is by using a triple layered list, but it is quite messy and is difficult for me to trace myself relative to the hierarchy, such as knowing when a subgroup is added etc. I use events and subscriptions to broadcast adding and removing groups/subgroups/values to the parents and grandparents, and when processing the data I use a for loop to loop through each branch of this hierarchy, comparing them with an if statement to get the value needed. Is there any more efficient way to do this?
Sorry if the explanation is bad, I'm not good at doing this.
I'm also fully self taught so pls be gentle with me 😅
74 replies
❔ how to make an API call
I have tried looking up tutorials but they ended up making me more confused. I want to take a string, generate an API call from that, then download the response.
The API takes a URL-encoded string, and returns a link to a wav file, which I'd like to download. Is that possible?
here's the link to the API I'd like to try using:
https://tts.cyzon.us/
https://github.com/calzoneman/aeiou/blob/master/docs/usage-guidelines.md
206 replies
❔ regex spamfilter
I'm trying to make a spam filter using regex. It's quite the undertaking, is anyone able to give me some pointers?
Currently, I'm working on a repeat word filter. These are the conditions:
- word repeated more than 3 times
- group of words repeated more than 3 times
- return false when the repeats have other irrelevant words imbetween
some examples:
currently I've got this
(\b\w+\b)\s+\b\1\b\s\b\1\b
but it considers the 2nd case as false - it can't detect multiple word groups.16 replies
❔ trim string according to regex
I've got this regex string,
^(?:\b\w+\b[\s\r\n]*){1,25}$
which is supposed to verify the string doesn't have more than 25 words.
How do I use this regex (or modifications of it) to trim the string to 25 words if it's longer than that? (when the regex check fails)89 replies
✅ learning tree data structure
I've got some data that I'd like to store for a unity app. The data is perfect for a 3-level tree, but I have never used that data structure before. Currently I'm using a triple layered list, and my code is a MESS.
Does anyone know any good tutorials for me to research? Currently I've tried but can only find tutorials on actual trees, and tutorials explaining how the data structure works, but not how to write the code.
57 replies
✅ help with regex
I'm trying to learn regex, have watched multiple tutorials and checked multiple websites, but can't fully grasp how to use it for my specific situation.
I want to find and retrieve a certain part out of a string: the word that follows an @.
currently I have this:
^@[a-zA-Z0-9]+$
Here are some example cases:
word @something
-> true
@something
-> true
word@something
-> false
I'd like to be able to retrieve the @something
from those examples, whilst ignoring the rest. Would my regex work? I've tried it with this website (https://regexr.com) but it doesn't seem to work...44 replies
list that holds 2 values each
I want to have a way to store a dynamic amount of data, where each entry holds a string and an int. What is the best way to handle this?
I'm thinking along the lines of a 2d list, or if that's not possible, maybe just 2 lists where I use code to compare the values imbetween them (values stored at the same index)
64 replies
❔ ✅ filtering, dissecting a string for processing
Not sure how to search for this online, so I'm asking here. I have a user input system, and I want to figure out how to dissect the string in code. Basically, there are different types of inputs the user can give. Examples would be:
<Text>
@text
#textand3numbers
General messages with symbols
I'd like to be able to differentiate these types of inputs, and do different actions.
I was thinking maybe using Contains(); but it can't differentiate a @text from a regular string that includes the @ symbol. Is that even possible to do this without overcomplicating things?
30 replies