I would like to use NLP techniques to infer a process out of raw text. For example, if I have a sentence like:

Recruitment is about attracting and selecting the right person for the job.

To get the following process:

Attracting the right person.

I noticed that a very good strong step forward is to use SpaCy, tokenizing the texts and filtering them for NOUNS. But from this point on, I'm completely blank. Someone suggested to me something named "Semantic Role Labelling" (SRL) and reading about the approach I think it could work here in a good way, perhaps using the AllenNLP module.

What I would like to know though (and the whole purpose of this post) are alternatives. Besides SRL, what other approaches could suit and provide a solution to this problem? I obviously don't expect the people who reply to solve the problem, only to make suggestions on approaches that might work so I can dig upon them (as mentioned, my experience on this topic is really short).

Thanks in advance!

  • 1
    $\begingroup$ as a first question, do you have your input sentences labeled with the processes categories you want? Or you want to find out possible processes categories without knowing them in advance? $\endgroup$
    – German C M
    Commented Jun 10, 2021 at 7:32
  • $\begingroup$ The first step would be to formalize what is the expected output, i.e. what is a "process". Ideally you would have a sample of documents annotated with their corresponding processes. Fwiw I'm skeptical about SRL being the right direction, because it would lead you to exploiting the linguistic structure of the sentences and that's rarely convenient. $\endgroup$
    – Erwan
    Commented Jun 10, 2021 at 8:59
  • $\begingroup$ @GermanCM hi. To be fair I'm debating which road of the ones you mention is the easiest to achieve, I'm thinking labeling will get me faster to what I want/need despite having to re-train a model for each new label previously not taken into account. And knowing them in advance, well, it would be ideal but not sure how to do so. What would you use for each of the paths suggested? $\endgroup$ Commented Jun 10, 2021 at 15:57
  • $\begingroup$ @Erwan hi, thanks for your insight. So what you are telling me is in other words, to label data as GermanCM mentioned in his commentary right? $\endgroup$ Commented Jun 10, 2021 at 16:03
  • 1
    $\begingroup$ @Aquiles It is indeed a crucial step for a supervised ML model to have a reliable labeling in advance. But in case you suspect more "processes" labels exist and you do not know yet, you could first try to implement an unsupervised model like LDA to infer new labels but... I would suggest labeling in advance if you can, and proceed with text classification $\endgroup$
    – German C M
    Commented Jun 10, 2021 at 19:51

1 Answer 1


Following with the idea of building a classifier, one option is to use nltk library together with Keras-Tensorflow once you have a labeled dataset with the desired process categories. You can go on two main approaches:

  • bag-of-words
  • sequence-modeling

As a quick resume of the steps to implement in a text classifier with the first approach, you could follow the ones below (you can find a worked pout example here):

  • Read and check that your raw input sentences (to be used for training, validating...) have the right format and correct label, something like: enter image description here
  • Preprocess your sentences as needed, which could be these steps:
    - lowercase all your words
    - remove punctuation characters
    - tokenize your words (here, your can define if you want 1-gram tokens, 2-grams tokens...)
    - stem your words (so as to eliminate singular/plurals, verbs tenses... (this point is not always straigtforward, because some stemmers like PorterStemmer, SnowballStemmer might offer different performance depending on the selected language), more info here
    - add more steps custom for your use case, the ones above are standard ones, but you can filter sentences wich you know do not offer value for you use case
  • Once you have preprocessed your input data, you should be able top access your vocabulary, to have something like:

    enter image description here

    and you are ready to vectorize your sentences, to end up with something like: enter image description here

  • build your classifier, where you can try out different models, like a convolutional neural network, a bi-directional LSTM, a transformer model...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.