0

I have an app that takes a text (string) as input (copy-pasting and manually writing text), cleans it, and generates questions. Python and FastAPI are used. It is implemented like this:

-app

  • api
    • model
      • Python scripts for type of question, question generation parameters, question generation parameters request
    • init file, index file, and a question generation script that uses inject, Provide, API Router
  • core
    • preprocessing
      • here there is an init file and a script that contains the text cleaning code
    • other folders regarding question generation that are more complicated and only have to do with machine learning
  • model
    • again, some transformer configuration

-init, cotainers and main file

I want to make it possible to upload a .txt file (so not just copy-paste input), clean it the same way, and generate questions.

The code for text upload and preprocessing is simple, in my Jupyter notebook it's just:

import string
with open(r'C:\\mypath\\example.txt', 'r', encoding="utf8") as infile:
    data = infile.read()
    # the same code that is used in the app for text cleaning
    # it tansforms this data into new_data
with open(r'C:\\mypath\\example_edited.txt', 'w', encoding="utf8") as outfile:
    outfile.write(new_data)

But now I don't know where in the app it should be. I looked here and here, and I don't figure it out. I am new to FastAPI and devops in general and a hint would be more than helpful.

  • 1
    Have you managed so far to succesfully upload the file, as described [here](https://stackoverflow.com/a/70657621/17865804)? – Chris Jan 17 '22 at 07:33
  • @Chris thank you for the link! I understand what's done there, but I don't know where to place this file in the project and how to "connect" it to the preprocessing file, so that it's cleaned. – futuredataengineer Jan 17 '22 at 07:40

0 Answers0