Processing Natural Language for the Spotify API Are Sophisticated Natural Language Processing Algorithms Necessary When Processing Language in a Limited Scope?

Processing Natural Language for the Spotify API Are Sophisticated Natural Language Processing Algorithms Necessary When Processing Language in a Limited Scope?

EXAMENSARBETE INOM TEKNIK, GRUNDNIVÅ, 15 HP STOCKHOLM, SVERIGE 2016 Processing Natural Language for the Spotify API Are sophisticated natural language processing algorithms necessary when processing language in a limited scope? PATRIK KARLSTRÖM ARON STRANDBERG KTH SKOLAN FÖR DATAVETENSKAP OCH KOMMUNIKATION Processing Natural Language for the Spotify API Bearbetning av Naturligt Spr˚aktill Spotifys API Authors Patrik Karlstr¨om Aron Strandberg Group 75 Supervisor Michael Minock Examiner Orjan¨ Ekeberg 2016-05-11 1 English Abstract Knowing whether you can implement something complex in a simple way in your application is always of interest. A natural language interface is some- thing that could theoretically be implemented in a lot of applications but the complexity of most natural language processing algorithms is a limiting factor. The problem explored in this paper is whether a simpler algorithm that doesn’t make use of convoluted statistical models and machine learning can be good enough. We implemented two algorithms, one utilizing Spotify’s own search and one with a more accurate, o✏ine search. With the best precision we could muster being 81% at an average of 2,28 seconds per query this is not a viable solution for a complete and satisfactory user experience. Further work could push the performance into an acceptable range. 2 Swedish Abstract Att kunna implementera till synes komplexa funktioner till sitt program p˚a ett simpelt s¨att ¨aralltid av intresse. Ett gr¨anssnitt f¨ornaturligt spr˚ak¨arn˚agot som teoretiskt s¨att g˚aratt implementera i m˚anga applikationer men komplex- iteten i de flesta bearbetningalgoritmerna f¨ornaturligt spr˚ak¨aren begr¨ansande faktor. Problemet som presenteras ¨aratt utforska huruvida en simplare algoritm som inte anv¨ander sig av komplicerade statistiska modeller och maskininl¨arning kan vara tillr¨ackligt bra. Vi implementerade tv˚aalgoritmer, en som anv¨ander sig at Spotifys egna s¨oksamt en med en noggrannare, lokal s¨okning. F¨oren komplett och tillfredsst¨allande anv¨andarupplevelse ¨ardetta inte en duglig l¨osning. Den b¨asta precisionen hamnade p˚a81% och d˚amed 2,28 sekun- der som genomsnittligt tid per fr˚aga.Fortsatt arbete kan f¨orb¨attra prestandan till n˚agotmer acceptabelt. 3 Contents 1 Introduction 5 1.1 Problemstatement.......................... 5 1.2 Purpose and Motivation . 6 2 Background 7 2.1 Natural Language Processing . 7 2.1.1 Precison and Recall . 7 2.1.2 The Gold Standard for Named Entity Recognition . 7 2.2 TheAPI................................ 7 3Method 9 3.1 Interacting with the Spotify API . 9 3.2 Application . 9 3.3 Corpus................................. 9 3.4 Algorithm . 9 3.4.1 Basic Algorithm . 9 3.4.2 Extended Algorithm . 10 3.5 Evaluating the results . 10 4 Result 12 4.1 ResultsWithEntireCorpus . 12 4.2 Results With Subsets of Corpus . 12 4.2.1 Without Queries for Albums . 12 4.2.2 Without Queries for Neither Albums nor Artists . 12 5 Discussion 13 5.1 General Discussion . 13 5.2 Basic Algorithm . 13 5.3 Extended Algorithm . 14 6 Conclusion 15 References 16 A Corpus 17 4 1 Introduction The current trend in technology as a whole is to move away from input methods that require the user to adapt to the computer and instead create I/O that adapts to the user. In other words you should be able to talk to your computer like you would another person. A Natural Language Interface acts as interpreter between the user and the computer and allows users to read, write and modify data through the use of a natural language. A common application of an NLI is to let the computer listen via a microphone and process spoken language. This is very common in today’s smartphones, for example Google Now and Apple’s Siri. Another approach is to let the user enter the query into a text field and then the computer tries to parse the question or command as intuitively as possible. An important aspect of processing natural language is to accurately deter- mine what is the most likely wanted result given the input. In natural language there are usually more than one interpretation for every given statement, the correct one is usually derived from factors such as context and emphasis. These factors are difficult for a computer to process and handle correctly and thus the risk of being misunderstood is even greater when talking to a computer than it is talking to another human. The computer must therefore be able to guess what result the user would be most satisfied with, which isn’t a trivial thing to do. Named entities are words or phrases that identifies an item, e.g a location or a person. An important subtask of Natural Language Processing is to reliably recognize and extract these named entities. Two main approaches to Named- entity Recognition are either rule-based NER, which relies on pre-made rules such as grammar, or machine-learning NER. A third approach is a hybrid be- tween the two using only the strong points from each one (Mansouri et al. 2008). Today a few main solutions exists for NLP. One of them is developed by the Stanford Natural Language Processing Group and their Stanford Named Entity Recognizer is based on a statistical model and use machine-learning to contex- tually extract entities (Standford Natural Language Processing Group 2015). Another popular software is the Apache OpenNLP which is a hybrid; Using both grammatical rules and machine learning to process the input (Apache 2014). Constructing an API call given an natural language string is not trivial. It depends heavily on the API itself. Di↵erent APIs can expect di↵erent queries. What every implementation has in common is that in the input string there will be a number of named entities. What exactly constitues a named entity will vary. For example in a NLI for hotels ”Imagine” would probably not be a named entity while in a NLI for a database of music tracks it would. A main focal point of finding suitable parameters is therefore NER. 1.1 Problem statement A lot of NLP testings are done on huge datasets with thousands of sentences (Sang and Meulder 2003). When working with such huge datasets the appli- cation of statistical models has been very successful (MUC-7 2001). However, when processing natural language for an API call you rarely handle input that large. Instead you are looking at one or maybe two sentences. 5 The problem to be explored is whether it is beneficial to apply sophisticated grammatical rules and/or statistical models when parsing natural language into an API call rather than implementing an algorithm that simply checks all the reasonable combinations of the input. In such a small scope is the di↵erence in performance even noticeable? 1.2 Purpose and Motivation In an ideal world there would exist a general solution of NLP that could be implemented for any application and work with close to human-like accuracy while stile being computationally fast. Although there are NERs with human- like accuracy (MUC-7 2001) the general case of NLPs are unfortunately not ideal. Along with furthering the research of NLP, the algorithms are also becoming more advanced and require deeper and deeper understanding of statistical the- ories and models. Writing, customizing and maintaining such algorithms is not an easy task and is not a reasonable option for a lot of developers. Fortunately for a lot of developers they don’t really need to be able to parse thousands of sentences efficiently and accurately most of the times. Instead they would only need to parse one sentence. They would also have the benefit of instant feed- back. If the Spotify has the track the search should be successful. In such a case there would be many benefits to a basic, essentially brute force, algorithm as long as it’s good enough. The time investment, and thus the financial investment, of implementing the simpler algorithm is on a completely di↵erent scale compared to the more sophisticated ones. Especially if you wish to in any way customize the latter ones. Realistically not many employees would posses the necessary expertise to implement the more sophisticated ones and from a business perspective you would rather not rely on that one employee to maintain your code forever. If there would be a way to make a simpler, more basic algorithm feasible given a limited context that would enable a great deal more flexibility for developers wishing to implement a simple NLI for their application. It would also make it easier for other developers to understand and maintain that code. 6 2 Background 2.1 Natural Language Processing A natural language is a human language that has not been specifically con- structed but rather evolved naturally through human interaction and social- ization, in other words almost every spoken language (Lyons 1991). Natural Language Processing is the field of study that explores interaction between a computer and a such a language. The field of NLP is a very broad one that has a lot of major subtasks, some examples being optical character recognition (determine text on a picture) and machine translating (translating one human language to another). As previously stated, an important subtask of NLP that is of particular weight for our thesis is Named Entity Recognition, where in our case the named entities are songs, artists and albums. 2.1.1 Precison and Recall One way to measure the accuracy of a pattern recognizing algorithm (such as named entity recognition) is to use precision and recall. Precision being the fraction of the retrieved material that is in fact relevant and recall being the proportion of relevant material actually retrieved (Rijsbergen 1979).

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    20 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us