sible.
// An error value has a cause if it implements the following
// interface:
//
//     type causer interface {
//            Cause() error
//     }
//
// If the error does not implement Cause, the original error will
// be returned. If the error is nil, nil will be returned without further
// investigation.
func Cause(err error) error {
	type causer interface {
		Cause() error
	}

	for err != nil {
		cause, ok := err.(causer)
		if !ok {
			break
		}
		err = cause.Cause()
	}
	return err
}


// Boost.Range library
//
//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
//  distribution is subject to the Boost Software License, Version
//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//

#ifndef BOOST_RANGE_EMPTY_HPP
#define BOOST_RANGE_EMPTY_HPP

#if defined(_MSC_VER)
# pragma once
#endif

#include <boost/range/config.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>

namespace boost 
{ 

    template< class T >
    inline bool empty( const T& r )
    {
        return boost::begin( r ) == boost::end( r );
    }

} // namespace 'boost'


#endif


import json
import pickle
import os
import re

SPLITNUM = 200

jsonfile = open('../data/example.json', 'r')


json_data=jsonfile.read()
jsondata=json.loads(json_data)
json_imgs=jsondata['images']
para_list=[]
for imgid,json_img in enumerate(json_imgs):
	for paraid,sentence in enumerate(json_img['sentences']):
		content=re.sub(' +',' ',re.sub('\.','. ',re.sub('\.+','.',sentence['raw'].encode('ascii','ignore'))))
		para_list.append({'raw':content,'imgid':imgid,'paraid':paraid})

for i in range(0,len(para_list)):
	if i % SPLITNUM == 0 and i != 0:
		fname = open('../data/example_split_'+str(i/SPLITNUM)+'.json', 'w')
		#print i,str(i/SPLITNUM)
		json.dump(para_list[i-SPLITNUM:i], fname,ensure_ascii=False)
		fname.close()
	elif i == len(para_list)-1:
		print (i/SPLITNUM)*SPLITNUM, str(i/SPLITNUM+1)
		print "Change last iterator in