Jump to content

Stata/Natural Language Processing

From Wikibooks, open books for an open world

Reading a text file

[edit | edit source]

If lines are short (less than the 244 string characters), one can use insheet. This command will read the text file into Stata's memory.

. insheet using toto.txt, clear

String functions

[edit | edit source]

First have a look at the list of string functions already included in Stata.

. h string functions

Regular Expressions

[edit | edit source]

Stata includes commands for regular expressions regexm(), regexr() and regexs().

Wordscores

[edit | edit source]

Ken Benoit, Michael Laver and Will Lowe have developed wordscores, a set of Stata command which read textfiles, count the frequency of each word and compute some index of similarity between texts.