Lecture 11: Parts of speech Intro to NLP, CS585, Fall 2014 http://people.cs.umass.edu/~brenocon/inlp2014/ Brendan O’Connor (http://brenocon.com) Some material borrowed from Chris Manning, Jurafsky&Martin, and student exercises 1 Tuesday, October 7, 14 • Review Next Tues. Which? • 12-1:30pm ? • 5:30-7pm ? 2 Tuesday, October 7, 14 What’s a part-of-speech (POS)? • Syntactic categories / word classes • You could substitute words within a class and have a syntactically valid sentence. • Give information how words can combine. • I saw the dog • I saw the cat • I saw the {table, sky, dream, school, anger, ...} 3 Tuesday, October 7, 14 POS is an old idea • Dionysius Thrax of Alexandria (100 BCE): 8 parts of speech • Common in grammar classes today: noun, verb, adjective, preposition, conjunction, pronoun, interjection • Many other more fine-grained possibilities https://www.youtube.com/watch? v=ODGA7ssL-6g&index=1&list=PL6795522EAD6CE2F7 4 Tuesday, October 7, 14 Open class (lexical) words Nouns Verbs Adjectives old older oldest Proper Common Main Adverbs slowly IBM cat / cats see Italy snow registered Numbers … more 122,312 one Closed class (functional) Modals Determiners the some can Prepositions to with had Conjunctions and or Particles off up … more Pronouns he its Interjections Ow Eh 5 Tuesday, October 7, 14 Open vs closed classes • Closed • Determiners: a, an, the • Pronouns: he, she, it, they ... • Prepositions: on, over, under, of, ... • Why “closed”? • Many are “grammatical function words.” • Open • Nouns, verbs, adjectives, adverbs 6 Tuesday, October 7, 14 Many tagging standards • Brown corpus (85 tags) • Penn Treebank (45 tags) ... the most common one • Coarse tagsets • Petrov et al. “Universal” tagset (12 tags) • http://code.google.com/p/universal-pos-tags/ • Motivation: cross-linguistic regularities • e.g. adposition: pre- and postpositions • For English, collapsing of PTB tags • Gimpel et al. tagset for Twitter (25 tags) • Motivation: easier for humans to annotate • We collapsed PTB, added new things that were necessary for Twitter 7 Tuesday, October 7, 14 Coarse tags, Twitter D: It's D: a A: great N: show V: catch O: it P: on D: the Proper or common? ^: Sundance Does it matter? N: channel #: #SMSAUDIO Grammatical category?? U: http://instagram.com/p/trHejUML3X/ Not really a grammatical category, but perhaps an important word class 8 Tuesday, October 7, 14 Why do we want POS? • Useful for many syntactic and other NLP tasks. • Phrase identification (“chunking”) • Named entity recognition • Full parsing • Sentiment 9 Tuesday, October 7, 14 same 80 TOEFL questions (Landauer & Dumais, some minor algebraic manipulation, if co- 1997). occurrence is interpreted as NEAR: The Pointwise Mutual Information (PMI) be- SO(phrase) = tween two words, word and word , is defined as 1 2 mantic orientation of a given phrase is calculated & Wiebe, f2o0ll0o0w; sW (Ciehbuer,c 2h0 &00 H; aWnkiesb, e1 9e8t 9a)l:. , 2001). hits(phrase NEAR “excellent”) hits(“poor”) (3) by comparing its similarity to a positive reference However, although an isolated adjective may indi- log 2 p(word & word ) 1 2 hits(phrase NEAR “poor”) hits(“excellent”) word (“excellent”) with its similarity to a negative cate subjectivity, there may be insufficient context PMI(word , word ) = log (1) 1 2 2 reference word (“poor”). More specifically, a to determine semantic orientation. For example, p(word ) p(word ) 1 2 Equation (3) is a log-odds ratio (Agresti, 1996). phrase is assigned a numerical rating by taking the the adjective “unpredictable” may have a negative To avoid division by zero, I added 0.01 to the hits. Here, p(word & word ) is the probability that mutual information between the given phrase and orientation in an autom1otive revi2ew, in a phrase I also skipped phrase when both hits(phrase word and word co-occur. If the words are statisti- the word “excellent” and subtracting the mutual such as “unpred1 ictable ste2e ring”, but it could have NEAR “excellent”) and hits(phrase NEAR cally independent, then the probability that they information between the given phrase and the word a positive orientation in a movie review, in a “poor”) were (simultaneously) less than four. co-occur is given by the product p(word ) “poor”. In addition to determining the direction of phrase such as “unpredictable plot”. Therefore the 1 These numbers (0.01 and 4) were arbitrarily cho- p(word ). The ratio between p(word & word ) and the phrase’s semantic orientation (positive or nega- algorithm extract2s two consecutive words, w1here 2 sen. To eliminate any possible influence from the p(word ) p(word ) is thus a measure of the degree tive, based on the sign of the rating), this numerical one member of th1e pair is a2n adjective or an adverb testing data, I added “AND (NOT host:epinions)” of statistical dependence between the words. The rating also indicates the strength of the semantic and the second provides context. to every query, which tells AltaVista not to include log of this ratio is the amount of information that orientation (based on the magnitude of the num- First a part-of-speech tagger is applied to the the Epinions Web site in its searches. we acquire about the presence of one of the words 3 ber). The algorithm is presented in Section 2. review (Brill, 1994). Two consecutive words are The third step is to calculate the average seman- when we observe the other. Hatzivassiloglou and McKeown (1997) have extracted from the review if their tags conform to tic orientation of the phrases in the given review POS patterns: sentiment The Semantic Orientation (SO) of a phrase, also developed an algorithm for predicting seman- any of the patterns in Table 1. The JJ tags indicate and classify the review as recommended if the av- phrase, is calculated here as follows: tic orientation. Their algorithm performs well, but adjectives, the NN tags are nouns, the RB tags are erage is positive and otherwise not recommended. 4 it is designed for isolated adjectives, rather than adverbs, an d tShOe (pVhBra stea)g =s PaMreI (vpehrrbasse., “Texhcee lsleencto”n) d Table 2 shows an example for a recommended (2) phrases containing adjectives or adverbs. This is pattern, for e x a m p l e , m e a-n PsM tIh(apth rtawseo, “cpoonosre”c) utive review and Table 3 shows an example for a not discussed in more detail in Section 3, along with words are ex•tracted if the first word is an adverb recommended review. Both are reviews of the The reference words “excellent” and “poor” were Turney (2002): identify bigram phrases useful for sentiment other related work. and the second word is an adjective, but the third Bank of America. Both are in the collection of 410 chosen because, in the five star review rating sys- The classification algorithm is evaluated on 410 word (which is naotn eaxlytrsacisted) cannot be a noun. reviews from Epinions that are used in the experi- tem, it is common to define one star as “poor” and 2 reviews from Epinions , randomly sampled from NNP and NNPS (singular and plural proper nouns) ments in Section 4. five stars as “excellent”. SO is positive when four different domains: reviews of automobiles, are avoided, so that the names of the items in the phrase is more strongly associated with “excellent” Table 2. An example of the processing of a review that banks, movies, and travel destinations. Reviews at review cannot influence the classification. and negative when phrase is more strongly associ- 6 the author has classified as recommended. Epinions are not written by professional writers; ated with “poor”. Table 1. Patterns of tags for extracting two-word Extracted Phrase Part-of-Speech Semantic any person with a Web browser can become a PMI-IR estimates PMI by issuing queries to a phrases from reviews. Tags Orientation member of Epinions and contribute a review. Each search engine (hence the IR in PMI-IR) and noting online experience JJ NN 2.253 First Word Second Word Third Word of these 410 reviews was written by a different au- the number of hits (matching documents). The fol- low fees JJ NNS 0.333 (Not Extracted) thor. Of these reviews, 170 are not recommended lowing experiments use the AltaVista Advanced local branch JJ NN 0.421 1. JJ NN or NNS anything and the remaining 240 are recommended (these Search engine5, which indexes approximately 350 small part JJ NN 0.053 2. RB, RBR, or JJ not NN nor NNS classifications are given by the authors). Always million web pages (counting only those pages that online service JJ NN 2.780 RBS guessing the majority class would yield an accu- are in English). I chose AltaVista because it has a printable version JJ NN -0.705 3. JJ JJ not NN nor NNS racy of 59%. The algorithm achieves an average NEAR operator. The AltaVista NEAR operator direct deposit JJ NN 1.288 4. NN or NNS JJ not NN nor NNS well other RB JJ 0.237 accuracy of 74%, ranging from 84% for automo- constrains the search to documents that contain the 5. RB, RBR, or VB, VBD, anything inconveniently RB VBN -1.541 bile reviews to 66% for movie reviews. The ex- RBS words wViBthNin, otre Vn BwGo rds of one another, in either located perimental results are given in Section 4. order. Previous work has shown that NEAR per- The second step is to estimate the semantic ori- other bank JJ NN -0.850 The interpretation of the experimental results, forms better than AND when measuring the entation of the extracted phrases, using the PMI-IR true service JJ NN -0.732 the limitations of this work, and future work are strength of semantic association between words Average Semantic Orientation 0.322 algorithm. This algorithm uses mutual information discussed in Section 5. Potential applications are (Turney, 2001). as a measure of the strength of semantic associa- outlined in Section 6. Finally, conclusions are pre- Let hits(query) be the number of hits returned, (plus other sentiment stuff) tion between two words (Church & Hanks, 1989). sented in Section 7. given the query query. The following estimate of PMI-IR has been empirically evaluated using 80 SO can be derived from equations (1) and (2) with 6 The semantic orientation in the following tables is calculated synonym test questions from the Test of English as 2 Classifying Reviews 10 using the natural logarithm (base e), rather than base 2. The a Foreign Language (TOEFL), obtaining a score of natural log is more common in the literature on log-odds ratio. The first step of the algorithm is to extract phrases Tu7es4d%ay, O(cTtobuerr n7 ,e 1 y4 , 2 0 0 1 ) . F o r c o m p a r i s o n , L a tent Se- Since all logs are equivalent up to a constant factor, it makes 5 mantic Ana hlyttspi:/s/ w(wLwS.Aal)ta, vaisntao.tchoemr/ ssitteast/issetairccah/la dmve asure no difference for the algorithm. containing adjectives or adverbs. Past work has of word association, attains a score of 64% on the demonstrated that adjectives are good indicators of subjective, evaluative sentences (Hatzivassiloglou 3 http://www.cs.jhu.edu/~brill/RBT1_14.tar.Z 2 4 http://www.epinions.com See Santorini (1995) for a complete description of the tags.
Description: