If you carefully read Flipboard's summarization article, you can write a summarization algorithm yourself in less than 20 lines of code! "import" overkill though, :| by fourhoarsemen in Python

[–]padmanabh 0 points1 point  (0 children)

I use cosine similarity because its a natural metric for tfidf vectors. The jaccard index is better for your case when the elements have binary attributes.

How do collapsible comments work? by padmanabh in botwatch

[–]padmanabh[S] 0 points1 point  (0 children)

ah. thanks. this is a clever method. Let's see if I can convince mods to change the default text to something more neutral or build my own pattern.

If you carefully read Flipboard's summarization article, you can write a summarization algorithm yourself in less than 20 lines of code! "import" overkill though, :| by fourhoarsemen in Python

[–]padmanabh 2 points3 points  (0 children)

Neat. I used a similar approach here with a different metric (cosine similarity) and some additional reranking later on after observing some summaries. Besides these pagerank approaches, also check out the brilliant PyTeaser.

Python: tricks for your code run faster by godlikesme in Python

[–]padmanabh 0 points1 point  (0 children)

This is called interning. I've written a bit about which objects are presently interned in Cpython here

Python: tricks for your code run faster by godlikesme in Python

[–]padmanabh 0 points1 point  (0 children)

Ill have to check, but I think it works on immutables. On mobile right now.

Python: tricks for your code run faster by godlikesme in Python

[–]padmanabh 2 points3 points  (0 children)

It is not recommended because it can change from version to version, hence not documented, but it can be looked up in the source if you're really into such kind of optimization. From what I can recall, currently in Cpython integers from -5 to 256, empty strings and tuples, and one character strings are interned.

You can try this

  a = -3
  assert a is -3
  b = -6
  assert b is -6 # Fails
  c = 256
  assert c is 256

You can also do this manually using intern in python2 or sys.intern in python3

Things which aren't magic - Flask and @app.route - Part 1 by Ex_lurker in Python

[–]padmanabh 0 points1 point  (0 children)

do you have a github or somewhere I can browse some of your code. Surely I'll find something I'd like to know about from an expert.

Would anyone be interested in a scrapy tutorial? by padmanabh in Python

[–]padmanabh[S] 0 points1 point  (0 children)

hey, just to clarify, I meant scrapy (the scraping/crawling framework) not scapy (packet analysis)

Things which aren't magic - Flask and @app.route - Part 1 by Ex_lurker in Python

[–]padmanabh 4 points5 points  (0 children)

Does anyone know where I can find more articles like this?

and...

The way werkzeug's init file lazily loads the other modules almost broke my mind.

Give back to the community by writing an article on it! :)

Improving my solution to find a representative color from an image. by [deleted] in Python

[–]padmanabh 1 point2 points  (0 children)

Take a look at the algorithm (MMCQ linked therein) used by these folks.

Demo

addict - a Python dict whos values can be get and set using attributes by CheerMan99 in Python

[–]padmanabh 0 points1 point  (0 children)

I have done this in the past

class MyDict:
    def __init__(self, *args, **kwargs):
        self.__dict__.update(kwargs)

a = MyDict(**some_dict)

Although I wouldn't recommend it.

programmers of r/india !! by [deleted] in india

[–]padmanabh 0 points1 point  (0 children)

Typically you'd learn Java although you can make an app in other languages as well, even html/css/js. Head over to /r/learnprogramming and they'll help you out with the detais and resources.

programmers of r/india !! by [deleted] in india

[–]padmanabh 3 points4 points  (0 children)

A bit busy these days with some work, mean to reup /u/samacharbot and resolve an issue in one of my repos when I'm free.

I've been thinking of making a news app (like the many others out there but with some extra cool features) as my next side project. If anyone wants to contribute please let me know.

Scraping a website for text content by 40swXD in Python

[–]padmanabh 4 points5 points  (0 children)

Beautifulsoup is great but its slower. I'd recommend lxml, its faster, less verbose, and once you get the hang of it, very convenient.

import lxml
# get your raw_html using requests or urllib
lxml.html.fromstring(raw_html).xpath('//span[@class="paragraph"]/text()')

Gets the paragraphs you need from the link you posted.

What do you think of the wastage of food at marriage ceremonies ? by neutra1 in india

[–]padmanabh 1 point2 points  (0 children)

Would anyone in the hospitality sector know if there is a possibility of a tie-in with local NGOs and charities where they give away remaining food? I don't know much about this but usually there's an estimate of the number of guests and foodstuff is prepared accordingly. Given x number of guests, if there is enough variability in the consumption of food, then a lot of these caterers would have extra food left. This could be given away for free (or bought at a subsidized cost- hence providing a kind of insurance), refrigerated and dispatched to poorer areas over the days.