The AISOP recipe

The AISOP webapp is a service built as the result of various training and configurations.
This recipe explains how to extract the content fragments, annotate them, and create model trained on it. This will let us create a pipeline and a seminar on which we can analyse portfolios.

Basic Terms

The context of the AISOP-web-app usage is that of a course at learning institution which typically has fixed students and fixed contents. A course can contain multiple courses or modules.

  • AISOP Web-app: The nodeJS server that interfaces with the portfolio-composing system.
  • Portfolio: the content written by a student in order to represent his or her progress, learning and knowledge using a textual and graphical form. Generally expressed in HTML, can be embedded in various web-pages.
  • Course-contents: The set of slides, their annotations, the videos and handouts that normally read by students and teachers.
  • Analysis: The set of programmes that recognize and measure the contents of a portfolio. Often also the name of the resulting interactive presentation (which can feature summaries or enriched portfolio views).
  • Composition Platform: A space where the portfolio is written. Normally a web-space. In AISOP we have focussed on the classical e-portfol;io composition platform Mahara (a PHP server).

1) Data Preparation

1.1: Make a Concept Map

Employing tools such as CMapTools, create a graphical concept map that represents the topics of the course. This concept map can be familiar with the teachers and learners of this course as a way to show the paths through the content.

From the concept map, extract a .cxl file which carries the same information and will be presented on the web-page.

From the concept map, also extract a hierarchy of topics, assuming there is more than (approx) 10 topics in the map. The hierarchy should be a text file with a label per line and the label indented to the right in case of children relation as in the following example:

Algorithmization
    Flow Charts
    Programming
        Programming Paradigm
            Imperative Programming
Data-Structure
    ....
Operating System
    ....

We'll name this file labels-all-depths.txt. From this text file, extract a text file with only the top labels (in the extract above only Algorithmization, Data-Structure and Operating System), named labels-depth1.txt.

1.2: Extract Text of the Course Content

In order for the topic recognition to work, a model needs to be trained that will recognize the words used by the students to denote a part or another of the course. This allows to create relations between the concepts of the course and the paragraphs of the portfolio and offer these in the interactive dashboards. The training is the result of annotating fragments of texts which, first, need to be extracted from their media, be them PDF files, PowerPoint slides, scanned texts or student works. These texts will not be shared so that even protected material or even personal-information carrying texts can be used.

Practically:

  • Make all documents accessible for you to open and browse (e.g. download them or get the authorized accesses)
  • Install and launch the clipboard extractor which will gather the fragments in a text file
  • Go through all contents and copy each fragment. A fragment is expected to be the size of a paragraph so this is what you should copy.
  • The extractor should have copied all the fragments in one file. Which we shall call extraction.json.
  • The least amount of content to be extracted is the complete set of slides and their comments. We recommend to use past students' e-portfolios too. We had rather good experience with about 1000 fragments for a course.
  • If interrupted, the process may create several JSON files. You can combine them using the merge-tool.

1.2.1: Extract Text from PDF or PNG (PDF → PNG → Text)

Text extraction from PDFs is sometimes faulty. Additionally, many PDFs contain images. To capture this text, Tesseract can be used. A brief explanation of how to use it is provided here.

Prerequisites

1. Tesseract must be installed

tesseract --version

2. Poppler must be installed

brew install poppler

Code

for pdf in *.pdf; do
# Extract the base name of the PDF without the extension
basename="${pdf%.pdf}"

# Convert PDF to PNGs
pdftoppm -png "$pdf" "$basename"

# Create a text file with the same name as the PDF.
for png in "$basename"-*.png; do
    tesseract "$png" stdout -l deu --oem 1 | tr '\\n' ' ' | sed 's/  */ /g' >> "$basename.txt"
    echo -e "\\n\\n---\\n\\n" >> "$basename.txt"
done
done
rm *.png

Explanation

1. for pdf in *.pdf; do ...; done

• Loops through all PDF files in the directory.

2. basename="${pdf%.pdf}"

• Extracts the filename of the PDF without the .pdf extension.

3. pdftoppm -png "$pdf" "$basename"

• Converts the PDF into PNG images, named in the format BASENAME-1.png, BASENAME-2.png, etc.

4. for png in "$basename"-*.png; do ...; done

• Processes only the PNG files generated from the current PDF.

5. tesseract "$png" stdout -l deu --oem 1

• Performs OCR on the PNG file.

6. tr '\n' ' '

• Replaces line breaks with spaces.

7. sed 's/  */ /g'

• Reduces multiple spaces to a single space.

8. >> "$basename.txt"

• Appends the recognized text to a text file with the same name as the PDF.

9. echo -e "\n\n---\n\n" >> "$basename.txt"

• Adds a separator line (---) after each page.

Result

• A separate text file is created for each PDF, e.g.:

• file1.txt for file1.pdf

• file2.txt for file2.pdf

• The OCR results of all pages from the respective PDF are written into this text file.

• Each page is separated by a separator line (---).

• Temporary PNG files are deleted at the end.

1.3: Annotate Text Fragments

It is time to endow the fragments with topics so that we can recognize students' paragraphs' topics. In AISOP, we have used the (commercial) prodigy for this task in two steps which, both, iterate through all fragments to give them topics.

The first step: top-level-labels: This is the simple "text classifier" recipe of prodigy: we can invoke the following command for this: prodigy textcat.manual the-course-name-l1 ./fragments.jsonl --label labels-depth1.txt  which will offer a web-interface on which each fragment is annotated with the (top-level) label. This web-interface can be left running for several days.
Then extract the content into a file: prodigy db-out the-course-name-l1 > the-course-name-dbout.jsonl

The second step is the hierarchical annotation custom recipe (link to become public soon): The same fragments are now annotated with the top-level annotation and all their children. E.g. using the command python -m prodigy subcat_annotate_with_top2 the-course-name-l2 \
  the-course-name-dbout.jsonl labels-all-depths.txt  -F ./subcat_annotate_with_top2.py
.

The resulting data-set can be extracted out of prodigy using the db-out recipe, e.g. prodigy db-out the-course-name-l2 the-course-name-l2-dbout.


2) Deployment

Most of the steps below contribute to creating an _AISOP-domain_, a directory with all of the subject-specific information. This directory contains runtime information; it can be first composed as a source directory with all the annotated and source documents. The AISOP-domain should be possible to share.

2.1 Train a Series of Recognition Models

The annotation process above will collect all annotations in a single JSONL file. It needs to be split for the different trainings.

For the level 1, one creates a recognition model by training on the annotated dataset:

For differentiating among topics of the level 1: 

prodigy train the-course-name-l1 --base-model de_core_news_sm --lang de  --textcat-multilabel the-course-name label-stats

This outputs a directory called the-course-name with the latest and the best models. Choose one as the chosen model to be copied inside `l1-model` of the domain.

Then, for each of the L1 topic, you need to separate the annotations (??? Pierre ???) to individual files which you then involve in a training. E.g. here for Error-Correction:

prodigy train the-course-name-l2-Error-Correction --base-model de_core_news_sm --lang de  --textcat-multilabel the-course-name-Error-Correction label-stats

Inspecting the output statistics is an effective way to prevent low-quality results for some of the contents.

Copy each of the produced best models into the domain's `l2-models` directory.

The two models directories should be put inside `domains` at the root of the AISOP-webapp.

2.2 Create a Pipeline

... write down the configuration JSON of the pipeline, get inspired pipeline-medieninderlehre.json

The pipeline is the central configuration information referencing the models and the scripts (found in the `scripts/python` directory). After changing the pipeline and copying it inside the domain, the web-application should be restarted.

2.3 Test

A simple tool to analyze pasted sentences is available using the following schema:
https://app-url/debug-classifier/model-l1/model-l2/?text=theText##. This allows to verify that the analysis of expected classical sentences performs correctly. The formulation a URLs containing all information allows creators of domains to collect a series of tests that they can perform again after each adjustments (e.g. after a change of hyperparameter of the training or a change of the annotations).

2.4 Create a Seminar and Import Content

Now that the pipeline is effective, we can create, within a group, a new seminar which defines the pipeline and the associated views from within all views accessible to the group administrators.

The button analyze should the be visible to you. Consider that analyzing all portfolios within a seminar can take time. We have experienced several hours for some cases.

2.4 Interface with the composition platform

The app installation is concluded with the configuration of the service for the Mahara platform: the instructions of the aisop-oauth apply here.


3) Usage

Make sure that the users who are going to be revising others' e-portfolios are group-administrator within Mahara.

3.1 Invite Users

Within a learning management, announce to the expected users of the AISOP-webapp, the availability of the web-app URL. They will login by authorising the app to download from Mahara. The invitation should contain a little description of the expected function.

The AISOP-webapp is likely able to support the students' writing process.

3.2 Verify Imports and Analyses

Once a sufficient amount of portfolios is available among the views of the seminars. It is possible launch global analyses.  These make output synthetic graphs expressing the covergage of each topic. These graphs can be used in classroom to reflect on the course.

3.3 Observe Usage and Reflect on Quality

The AI-based observation can be used and, for each Mahara view, a portfolio-explorer and global-dashboard is available. They both can be the opportunity to observe the e-portfolios quality. They can also reveal classifications' flaws and, most probably, the appearance of topics that don't fit well any of the classification.

3.4 Gather Enhancements

As a first feedback after the use of the web-app. Multiple refinements of the e-portfolios could be suggested. Several such can be discussed in class.

Further enhancements can be obtained from the web-app usage: if the proportion of allocated content matches the expectation from the course, if the students' understanding has been suffering for particular contents, or if some content parts are particularly popular.

Finally, enhancements can be reflected upon for the subsequent issues of the course: Enhancements to the classification, to the contents, to the annotation sources or to the web-app and processes.

Tags:
    

Need help?

If you need help with XWiki you can contact: