I am using the NLTK toolkit, and I am using the text.concordance() function. I would like to append the results of this function to a list, in order to get a list of the string-sentences the function outputs.

Example Output of Concordance

I have tried to define the function as a variable and tried to append this to the variable list.

I have tried to define the variable as the function itself:

sim_col_inst = text.concordance("column")

type(sim_col_inst)
NoneType

Alternatively, I have tried to append this:

sim_col_inst.append(text.concordance("column"))

type(sim_col_inst)
list

However, the variables are always empty.

1 Answers

1
L3viathan On

The concordance method of nltk.text.Text only prints the concordance, and then returns None.

You can use the method concordance_list instead to get a list.