« first day (4228 days earlier)      last day (727 days later) » 

3:58 AM
hi all, I am facing a problem in a program. I have two strings.
str1 = 'Australian Opposition Leader Anthony Albanese reacts after delivering'
str2 = 'Australian Opposition Leader: Labor part campaign launched after delivering speech'
in this string, 'Australian opposition leader' and 'after delivering' are two common phrases/substrings
is there a way I can get these two common phrases using difflib? I am able to do using python script, but it takes too much time for 1,000+ sentences
Or if there is any other library or any alternate method that I may use to get all the common phrases out of two strings.
Thank you all for your time!
 
4:54 AM
print([
    str1[block.a:block.a+block.size] for block in
    difflib.SequenceMatcher(None, str1, str2).get_matching_blocks()
    if block.size > 3
])
 
 
2 hours later…
6:29 AM
@Aran-Fey thanks
from this I get
['Australian Opposition Leader', ' after delivering']
but if I use
str2[block.a:block.a+block.size] for block in
['Australian Opposition Leader', 'unched after deli']
 
Then you get word salad. Do you understand what block.a is?
 
I've just started with difflib, trying to figure it out alongside
 
> Return list of triples describing non-overlapping matching subsequences. Each triple is of the form (i, j, n), and means that a[i:i+n] == b[j:j+n].
 
Okay.
Thank you
 
 
6 hours later…
12:43 PM
Sacrificed two books to create a makeshift monitor stand, and I can already feel that my neck and back are going to thank me for this. So, PSA: Make sure to adjust your display's height properly. Even a few centimeters make a difference.
 
 
7 hours later…
7:15 PM
Cool, I do that too.
I just put a third book on to get better.
 
Proving once again that paper books > e-books!
 
yeah haha
 
 
1 hour later…
8:52 PM
if i do have a date like that 2022-05-01 how to obtain the end of the month for it ? to be 2022-05-31
currently am using from calendar import monthrange but someone might have a simple way than that?
 
Did you look at things like this?
or to put it differently: monthrange seems simple enough, and it's standard library
 
9:10 PM
Thank you.
 

« first day (4228 days earlier)      last day (727 days later) »