Data4Democracy / internal-displacement

Studying news events and internal displacement.
43 stars 27 forks source link

Number-like entities to integers #109

Closed simonb83 closed 7 years ago

simonb83 commented 7 years ago

Prior to saving reports to database quantities need to be converted to integers.

In some cases this is trivial (i.e. 500, 684), however there are other cases that need more work for example 'thousand', 'hundreds' etc.

Probably the best place to implement the conversion is in Report.__init__

frenski commented 7 years ago

Hi @simonb83 , I used this solution (https://github.com/ghewgill/text2num/blob/master/text2num.py) and improved it to accept also numbers and lists as input. This should do the work, right? Should I put it directly in the model init?