jurafsky&martin_3rdEd_17 (1).pdf

Words are about 24 characters long on average a

Info icon This preview shows pages 23–26. Sign up to view the full content.

View Full Document Right Arrow Icon
Words are about 2.4 characters long on average. A simple algorithm that does re-
Image of page 23

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
24 C HAPTER 2 R EGULAR E XPRESSIONS , T EXT N ORMALIZATION , E DIT D ISTANCE markably well for segmenting Chinese, and often used as a baseline comparison for more advanced methods, is a version of greedy search called maximum match- ing or sometimes MaxMatch . The algorithm requires a dictionary (wordlist) of the maximum matching language. The maximum matching algorithm starts by pointing at the beginning of a string. It chooses the longest word in the dictionary that matches the input at the current position. The pointer is then advanced to the end of that word in the string. If no word matches, the pointer is instead advanced one character (creating a one- character word). The algorithm is then iteratively applied again starting from the new pointer position. Fig. 2.11 shows a version of the algorithm. function M AX M ATCH (sentence, dictionary D) returns word sequence W if sentence is empty return empty list for i length (sentence) downto 1 firstword = first i chars of sentence remainder = rest of sentence if InDictionary( firstword , D ) return list (firstword, MaxMatch(remainder,dictionary) ) # no word was found, so make a one-character word firstword = first char of sentence remainder = rest of sentence return list (firstword, MaxMatch(remainder,dictionary D) ) Figure 2.11 The MaxMatch algorithm for word segmentation. MaxMatch works very well on Chinese; the following example shows an appli- cation to a simple Chinese sentence using a simple Chinese lexicon available from the Linguistic Data Consortium: Input : ÷ y + ú " ¨ - “He especially likes Peking duck” Output : ÷ y + ú " ¨ - He especially likes Peking duck MaxMatch doesn’t work as well on English. To make the intuition clear, we’ll create an example by removing the spaces from the beginning of Turing’s famous quote “We can only see a short distance ahead”, producing “wecanonlyseeashortdis- tanceahead”. The MaxMatch results are shown below. Input : wecanonlyseeashortdistanceahead Output : we canon l y see ash ort distance ahead On English the algorithm incorrectly chose canon instead of stopping at can , which left the algorithm confused and having to create single-character words l and y and use the very rare word ort . The algorithm works better in Chinese than English, because Chinese has much shorter words than English. We can quantify how well a segmenter works using a metric called word error rate . We compare our output segmentation with a perfect word error rate hand-segmented (‘gold’) sentence, seeing how many words differ. The word error rate is then the normalized minimum edit distance in words between our output and the gold: the number of word insertions, deletions, and substitutions divided by the length of the gold sentence in words; we’ll see in Section 2.4 how to compute edit distance. Even in Chinese, however, MaxMatch has problems, for example dealing
Image of page 24
2.3 T EXT N ORMALIZATION 25 with unknown words
Image of page 25

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 26
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern