-
Notifications
You must be signed in to change notification settings - Fork 5
Add fancier ways to get item names #3
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
base: main
Are you sure you want to change the base?
Conversation
…lities#2) * Fix facilities * Use itemsExtractor to get tool ids * Filter out nulls
…-osrs; branch 'main' of github.com:Flipping-Utilities/parsed-osrs into main-item-names
| private hasUnterminatedParenthesis(input: string): boolean { | ||
| let openParenthesisCount = 0; | ||
| let closeParenthesisCount = 0; | ||
|
|
||
| for (const char of input) { | ||
| if (char === '(') { | ||
| openParenthesisCount++; | ||
| } else if (char === ')') { | ||
| closeParenthesisCount++; | ||
| } | ||
| } | ||
|
|
||
| return closeParenthesisCount < openParenthesisCount; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this works, there are "cleaner" solutions IMO.
I would personally replace it with a regex to test for unmatched parenthesis, something like:
return !/^[^()]*(?:\([^()]*\)[^()]*)*$/.test(input);But that's a fairly ugly regex.
To keep it code-based, I would augment it to match the parenthesis "depth" to ensure this )( doesn't pass either:
let depth = 0;
for (const char of input){
if(char === '('){
depth += 1;
} else if(char === ')'){
depth -=1;
if(depth < 0){
return true;
}
}
return depth !== 0;
}|
Fyi: Aliases are built from the list of wiki redirects to this page, hence the inconsistent amount and quality of these: This isn't a reliable mechanism to find names, but it is good enough for most typos and meme names. |
| const score = | ||
| Number(item.isInMainGame) * 3 + | ||
| Number(item.isOnGrandExchange) + | ||
| Number(item.isTradeable); | ||
| const otherScore = | ||
| Number(otherItem.isInMainGame) * 3 + | ||
| Number(otherItem.isOnGrandExchange) + | ||
| Number(otherItem.isTradeable); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is getting repeated few additional times, I'd extract it in a weightItemScore method so it's easier to tweak in the long run
|
@AntonyGarand This diff is adding Nettle tea (milky) which we find via the image. |
|
This might have been a lofty endeavor, a lot more edge cases than I thought. |
Occasionally the alias list for the item does not have the closing parenthesis. I opted for this approach rather than figure out how to fix the initial alias list parsing because I was having trouble figuring out where it was coming from.
Similarly, sometimes the alias list just doesn't have the descriptive name, but usually the image name does follow the correct pattern we expect from the recipe info.