This article shows the text coding window from Q5.19, which is currently in an early release. If you are on an older version of Q, please see Coding Text Data in Q. If you are familiar with Q's coding workflow then you will have noticed that things have moved around a bit - responses are now on the right side, and categories (or "Themes") are on the left. You can still do all the same tasks, but the workflow should be smoother. We have added a few key features:
- You can now Filter the responses shown according to filter variables in your project.
- If you are doing Automatic categorization, the category-creation and response-assignment steps are now separate, and you can choose the number of categories to generate.
- You can now assign responses to categories by dragging-and-dropping.
- You can now Lock responses to prevent changes to that response by the automatic classification.
There are many different terms for "classify text data" such as: code open ends, categorize verbatims, cluster text responses. Whatever you call it, classifying text data into themes for further analysis is a cornerstone of text analysis. This article explains how to use the Text Categorization module to automatically create themes and then automatically classify responses into those themes.
This article is broken into the following sections:
- Create Your Classification
- Save Your Classifications
- Use Similarity Sorting to Assist with Classification
- Use Filtering to Assist with Classification
- Reuse an Existing Categorization
In this article, we describe how to go from raw text data:
To a state where the text responses have been classified and can be used for further analysis:
Requirements
You will need one or more Text variables. Text variables will have Text written in the Variable Type column of the Variables and Questions tab.
Create Your Classification
To begin:
- Go to the Variables and Questions tab.
- Select the row for a Text question.
- Right-click and select Insert Variables > Code Text > and either
- Multiple Overlapping Categories - use this when you have open-ended responses or any other case where the responses typically belong to more than one category
- Mutually Exclusive Categories - use this for things like top of mind awareness, spontaneous awareness mentions, or where each response should be assigned to a single category
The Text Coding window will open. You have the original text Responses on the right, and Themes (or categories) can be created on the left:
Creating Themes
There are several ways to add themes (categories):
- Click + Add New Theme to manually name a new theme.
- Drag and drop a text response from the right, underneath the list of themes. That response will be added to the new theme.
-
Click the Add button at the top to add many themes at the same time. You can paste in themes from outside of Q (e.g. from a spec in an Excel spreadsheet).
- Click the Create button to have Q automatically generate a set of themes. You can choose the number of themes to generate. These themes will be generated by clustering the words and phrases in the data to find the strongest signals.
Once you have added themes, either manually or using the automatic tool, the Themes pane on the left side of the screen should look like this. Themes are color-coded, and the number of Responses assigned to each theme (as well as the number of unique responses) will be shown.
Classify Text Responses
You can assign responses to themes by selecting and choosing which categories to assign them to by dragging-and-dropping or right-clicking, and you can also do a quick automatic classification by clicking the Classify button.
Classify Responses Manually
To manually assign responses you can:
- Select a response, or select many responses by holding CTRL or SHIFT and clicking.
- Drag the selected responses to a Theme on the left
- Or, if you are using the Multiple Overlapping Categories, right-click the selected responses and select one or more themes from the context menu.
Classify Responses Automatically
If you use the automatic option, responses will be matched to themes using a machine learning algorithm, and the assignments will be done for you.
- Select one or more responses (holding SHIFT or CTRL).
- Click the Classify button. Q will report the total number of selected responses.
- Click Classify to confirm.
When the classification is finished, you will see colored letters next to each text response. This corresponds with the theme it was assigned to.
No automatic classification solution will be perfect, and there are ways that you can tidy up and improve your classifications, either by using the manual classification steps above, or by doing a bulk classification described in the next section.
Classify Remaining Responses
Once you have done the main classification, you may have some unclassified data that couldn't be assigned to a specific theme. You will know if any data is left unclassified if there is a non-zero number in the "Unclassified" theme:
You will want to review any unclassified responses and classify them into an existing theme or create a new one. You can create a new theme, such as "All other responses", to capture the responses that don't fit into existing themes.
- Set the Theme filter dropdown in the Responses section to Unclassified to show all unclassified responses.
- Select all of the unclassified responses by pressing CTRL-A.
- Add the selected responses to a new theme by:
- Clicking on + Add New Theme at the bottom of the Themes list,
- Dragging a text response to the left and into the purple box at the bottom of the Themes list.
- Hovering over a response, clicking Manually classify, and typing in a new theme label.
- Give the new theme a label, e.g., "All other responses" and hit Enter.
Check Quality of Classified Responses
It's important to give any automatic classification a quality check before reporting on your analysis. A quick way of doing that is to select a theme from the Theme filter and quickly scan through for a quality check.
If there are more than a few items that you need to reclassify into an entirely different theme, drag them all to the "Unclassified" theme. Then click Classify again to re-run the automatic theme assignments. This will only classify the unclassified items; it won't reclassify things that are already assigned to a theme.
Below, I've selected the "Brand loyalty" theme and can see that there are some items, such as "drink for the enjoyment and the fun it brings", that are better placed in another theme.
You can manually reclassify responses:
- Select the text response.
- OPTIONAL: If you selected Multiple themes when you started the categorization, you can add responses to an additional theme(s). Drag and drop it into the new theme, or start typing the new theme's label and select it.
- To remove it from the current assigned theme and add it to another, click on the triple letters in the Classification column, remove the assigned theme by clicking on the X to the right of the label, start typing the correct theme, and hit Enter.
Below, "drink for the enjoyment and the fun it brings" is added to "Social perception" and removed from "Brand loyalty".
By default, when you manually classify a text response, its status is set to "locked." See the drink for the enjoyment and fun it brings and no comment responses below. If a response is unclassified its status is instead set to "unlocked" like Pay packet below. This is visible on the left of the response when you either hover over or select it.
While all locked responses can be manually classified, only unlocked responses can be automatically classified. This allows you to guarantee that any manual classification won't be re-classified when you run automatic classification afterwards. If you do wish to allow this, however, you can manually unlock a response by clicking the adjacent lock icon.
Editing Themes
To rename a theme, right-click and select Rename (F2). You can delete existing themes and reclassify them into an existing theme by right-clicking and selecting Delete and Reclassify as (and then selecting the theme to classify into), or delete a theme altogether by right-clicking and selecting Delete (Del).
Alternatively, you can add more themes manually by clicking + Add New Theme.
Save Your Classifications
Once you're happy with the classification, click Save in the bottom right corner. This will take you back to the Variables and Questions tab. A new classified Question will appear in the list below your original text variable and have "Categorized" in the name.
Use Similarity Sorting to Assist with Classification
You can use our Similarity algorithms to help you manually classify remaining text data into existing themes. This can be accessed via the Show response similarity to theme or text button:
Similarity to Text
You can enter text in the similarity filter to find responses that are similar in the unclassified data.
- Click the Show response similarity to theme or text button
.
- Enter a keyword or phrase that you want to find similar matches for in the search field.
- Click the Text that appears in the Similarity to text area:
The responses will update to show an orange bar to the left of the text. The length of the bar indicates the match level, so the longer the bar, the better the match.
In the example below, I have some text data that contains responses to what people miss about pre-pandemic life. I used the similarity algorithm to find responses that are similar to "travel":
To assign the results to an existing theme:
- Select the response(s) from the pane on the right that you want to classify.
- Either drag and drop into the appropriate theme, or hover and click Manually classify, start typing the theme's label, and then select the theme from the list.
- OPTIONAL: You can assign to multiple themes by selecting them from the list of themes using Manually classify, or dragging the text into an additional theme.
Similarity to a Theme
You can enter text in the similarity filter to find responses that are similar to themes as well. The algorithm will look at responses that have been classified to a specific theme, and then use those to find similar responses in the unclassified data. The algorithm becomes smarter as more responses are classified to a theme.
- Click the Show response similarity to theme or text button
.
- Enter a keyword or phrase that you want to find similar matches for in the search field.
- Click the theme that appears in the Similarity to theme area:
The responses will update to show an orange bar to the left of the text, and include any responses that have already been classified. The length of the bar indicates the match level, so the longer the bar, the better the match.
To assign the results to an existing theme:
- Select the response(s) from the pane on the right that you want to classify.
- Either drag and drop into the appropriate theme, or hover and click Manually classify, start typing the theme's label, and then select the theme from the list.
- OPTIONAL: You can assign to multiple themes by selecting them from the list of themes using Manually classify, or dragging the text into an additional theme.
Use Filtering to Assist with Classification
There are a number of ways that you can filter your responses within the text categorization interface.
Filter by Locked Responses
To view only locked or unlocked responses, click the Lock icon. By clicking the icon once, only the locked responses will appear. Clicking the lock again will filter to all unlocked responses. If you click the lock a third time, the sorting will be reset entirely.
Filter Responses by Text
You can search for specific text or text strings by clicking on the magnifying glass:
Then you can enter text to search for in the responses:
Filter by Theme
When you have a long theme list, you can search within or filter this list by clicking on the magnifying glass within the Themes section.
You can also filter the responses list by the assigned theme by clicking on the Theme filter in the Responses section:
Filter by Variable
An alternative to filtering by a text search term or theme is to filter by a variable in your document. Any variable that has Usable as a filter ticked under Data > Attributes in Properties can be selected in the Var filter.
This option will display responses that were made by respondents who fall under the selected filter, but if categorized, all respondents with that response will be categorized, regardless of whether they fall into the filter or not.
You see if some responses come from respondents in a different filter, when you see an "of" count next to a response, such as [1 of 2]. This indicates that only 1 of the 2 respondents who gave this response fall into the filter. If you now classify these responses into a theme, it will classify all instances of this response (2) regardless of the filter. So in this case, classifying "hugging" will apply to both responses and not just the one that falls within the selected filter.
Reuse an Existing Categorization
If you want to use existing themes from an already classified variable on an unclassified text variable and still be able to make use of features available in Q's categorization tool, you can reuse an existing categorization.
For example, I have a text variable that asks about how social life has changed due to the pandemic that I classified. Next, I want to apply the same themes to another text variable that asked about what parts of social life from pre-pandemic are missed. I can reuse the existing categorization on this other text variable.
- Go to Variables and Questions tab.
- Select the text variable that you want to classify using existing themes.
- Right-click and select Insert Variables > Code Text >
- Click one of the following options:
- Reuse by Copying Code Frame - copies an existing code frame and rules as is from a categorized variable set.
- Reuse by Sharing Code Frame - shares an existing code frame and rules from a categorized variable set, so that any additions and changes will be reflected in both.
- The text responses will appear on the right side, and the existing themes appear in the Themes pane to the left. To assign the text responses to an existing theme, click Classify.
- Repeat the steps in the Resolve Unclassified Data and Check the Quality of Classified Responses sections above as needed.
- Click Save when you are finished with classification.