Open Side Menu Go to the Top

09-29-2019 , 10:38 PM
pkill universe
ps aux | grep universe
kill -9 000069
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
09-30-2019 , 05:25 PM
What is the keyword I should be looking for...

I have a large number of phrases - say, 10k to 100k. Each phrase is short, just a few words, probably all of them are under 50 characters.

I have a big chunk of text, say 100k. I want to know which of my phrases are in the text.

Alternately, if it helps, let's say I've tokenized the text into smaller bits, like paragraphs, sentences, and in some cases like table cells - that is, I've taken advantage of the fact that the text blob is html to make some inferences about the text - for example I don't need to find matches of phrases that start in one sentence and end in another, or start in one table cell and end in another, etc, it's fine to assume that these entities are independent
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-30-2019 , 05:28 PM
My first thought is maybe... bloom filter? Let's say all my phrases are 1, 2 or 3 words. I could make a bloom filter for len=1, len=2 and len=3. I could tokenize my text into all the sequential 1, 2 and 3 word phrases and check their existence in the bloom filter. I'd use some normalized version of the phrases (like all lower case, punctuation removed, etc)

I suspect even this will be too slow - this is in an interactive element so needs to complete in a few seconds, and it's already doing a ton of other text processing
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-30-2019 , 05:57 PM
Sounds like an interview question. You have 30 minutes Rusty
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-30-2019 , 07:22 PM
Which parts of this can you pre-process? Like are the phrases all known ahead of time and the text is entered at run time?

Assuming so - then yeah make 3 sorted sets out of the 1, 2 and 3 word phrases.

Walk though the text once - checking the sorted sets for each word, combination of 2 and combination of 3 - tracking duplicates to be ignored (or have a count incremented). The sorted set lookup should be pretty fast.

I guess you could do a sorted hash - where the value is any other shorter phrases included within this phrase. So say if your 3-word phrase is "I'll be back" and you have a 2-word phrase of "be back" - then no need to include "be back" in your 2-word sorted set, or search for "be back" when you find "I'll be back" in the text. You would just increment accordingly from the result.

Although the coding is a little tricky because you need to make sure your three word phrase walk through is far enough ahead that it doesn't miss any 2 word sets. Then if you have 2 word phrases not found in 3 word lookup results, and not dupes, you look them up in the 2-word sorted sets. And same concept for single words.

Not sure if that makes any sense.

Last edited by suzzer99; 09-30-2019 at 07:35 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-30-2019 , 08:40 PM
I mean I know how to make something like you're describing, but I'm almost sure it won't be fast enough - what I'm looking for is what I should search for to find algorithms that are going to be better. Like... ngram indexing and searching is way faster than anything you're likely to come up with on your own when doing full text search.

The phrases are known in advance, the text is arbitrary.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-30-2019 , 08:53 PM
Quote:
Originally Posted by goofyballer
Code:
while (IsOut()) {
  BuyMilk();
}
I was expecting a more misogynic joke.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-30-2019 , 09:30 PM
Are you sure it’s not fast enough? If you had a map of starting word to set of phrase completions you’d be able to do a relatively fast constant time operation for every word in the given text.

Definitely possible there’s something out there that’s super clever but hard to believe it’s going to be significantly faster when you can’t know the text in advance.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
09-30-2019 , 11:47 PM
I am a total React/javascript dunce, I need help with something.

There's a experimental feature called Wed MIDI Api and I want to use it. If I open up the console I can run
navigator.requestMIDIAccess() and it returns a promise. Great.

If I try to add this to a React app, requestMIDIAccess doesn't exist on the navigator object.

I'm using webpack and babel to build the app. I assume that babel is compiling my code to some kind of sanitized environment that is expected to run on a variety of browsers, and since some of them wouldn't support the feature I want, it isn't included.

Can I... make it include it? I'm using @babel/preset-env and some of the options seem like they'd work but no combination of them has worked so far.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2019 , 12:32 AM
Ugh maybe I'm either testing this wrong or it's something else, because I removed babel entirely from the situation and it's still not working
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2019 , 10:16 AM
10-01-2019 , 11:21 AM
Quote:
Originally Posted by suzzer99
Yeah I don't think it's that.

If I open a new tab in chrome and open the JS console, I can run the function fine. If I open my app in the same browser, my app can't run the function. If I open the console in that tab, then I can't run the function there either. I really suspect that something is replacing the navigator object for my "own good"

BTW this seems to work ok in browserfy, so I am suspecting it's webpack that's screwing me.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2019 , 11:26 AM
Are you using use strict?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2019 , 11:33 AM
Yeah, pretty sure webpack adds that. You think that's interfering?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2019 , 11:34 AM
It might be. Try a web page w/o webpack and turn use strict on and off.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2019 , 11:36 AM
Quote:
Originally Posted by suzzer99
It might be. Try a web page w/o webpack and turn use strict on and off.
Doesn't seem to make a difference
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2019 , 11:38 AM
Quote:
Ok, I managed to remove this error by doing this instead:


navigator["requestMIDIAccess"]
Try that.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2019 , 11:39 AM
Sounds like it could be this: https://stackoverflow.com/questions/...ged-to-console
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2019 , 11:44 AM
So my testing methodology sucks - not that I have an answer.

Specifically navigator.requetMIDIAccess exists in the console - if I'm on, say, a google page, or this one. But say I open a new tab and then go to a nonsense address like localhost:9999 - then it does NOT exist.

So it actually seems like it's not enabled or working by default and *some* built javascript packages turn it on. Weird man.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2019 , 11:48 AM
Hoy ****, your first link was right I think. I had assumed that because the function worked in (most) contexts except mine, that mine was the odd one out. But I checked the flags and I had the experimental stuff off. Turn that on, restart chrome and load my app, and it works.

So I guess my question is - there are projects out there just like mine that work out of the box, how are those doing it? And like I said even before I enabled this flag it worked with browserfy but not webpack.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2019 , 12:28 PM
Oh wait - google.com and other places it works (including my browserfy example) are probably polyfilling it in, aren't they. I "got around" that by enabling the flag but probably I could have also found a way to polyfill it.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2019 , 08:17 PM
Let's say you're going to have a typical site with a hamburger menu that expands to a vertical list of selections for mobile - and permanently showing menu items horizontally across the header for desktop. But you're not going to use bootstrap or any other prepackaged nav components. Total roll your own. Obviously the look and feel is completely different in each case.

Would you:

a) Build one component - but use media queries (or react device detection or whatever) to create basically two versions of the CSS with a few things in common but mostly different?

b) Just create two separate components with their own styles - and feed each an array of menu items?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2019 , 08:18 PM
I wish i understood anything you guys talk about. Where the C/linux nerds at
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-01-2019 , 09:34 PM
Quote:
Originally Posted by jmakin
I wish i understood anything you guys talk about. Where the C/linux nerds at
Technically that's me. I do JS for my side projects because it's 2019 and no one is going to download a desktop app from me unless it's super ****ing awesome.

ETA: I haven't done C professionally in over 10 years though, C++ and python.

Last edited by RustyBrooks; 10-01-2019 at 09:46 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-02-2019 , 07:32 PM
suzzer, I've been lazy and pressed for time on my last few projects so have done more B than A, but if I have time to do it right I do A.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

      
m