preke / asg_demo

0 stars 1 forks source link

upload file #1

Open preke opened 2 years ago

preke commented 2 years ago

index.html.zip

@csrf_exempt
def upload_refs(request):
    file_dict = request.FILES
    file_name = list(file_dict.keys())[0]
    file_obj = file_dict[file_name]
    with open(DATA_PATH + file_name, 'wb+') as f:
        for chunk in file_obj.chunks():
            f.write(chunk)

    input_csv = pd.read_csv(DATA_PATH + file_name, sep = '\t')

    # handle input_csv to get the elements in the ref_list below
    '''
    code here ...
    '''

    if input_without_topics:
        ref_list = {
            'uid': "", # if have
            'topic_words': [],
            'references': [references],
            'ref_links': [ref_links],
            'ref_ids': [ref_ids]
        }
    elif input_with_topics:
        ref_list = {
            'uid':  "", # if have
            'topic_words': ['t1', 't2', 't3', ...],
            'references': [references_t1, references_t2, references_t3, ...],
            'ref_links': [ref_links_t1, ref_links_t2, ref_links_t3, ...],
            'ref_ids': [ref_ids_t1, ref_ids_t2, ref_ids_t3, ...],
        }

    ref_list = json.dumps(ref_list)
    return HttpResponse(ref_list)
StevenLau6 commented 2 years ago

Added a new branch upload_files_views. It achieves checking and parsing upload files, preprocessing the text content, keyword extraction, reference description generation, and outputting the TSV file.

Before merging the branch, we need more discussion on: 1) the global variables Survey_dict, Survey_Topic_dict, and Survey_Topic_dict 2) the returned value of upload_refs 3) the maintenance and usage of uid in this system