Search – SpokenMedia https://spokenmedia.mit.edu Transcripts for Lecture Video Mon, 23 May 2016 13:11:39 +0000 en-US hourly 1 https://wordpress.org/?v=4.5.3 Customizing the Google Search Appliance for Greenfield OCW https://spokenmedia.mit.edu/2010/08/customizing-the-google-search-appliance-for-greenfield-ocw/ Tue, 24 Aug 2010 14:58:16 +0000 http://spokenmedia.mit.edu/?p=794 MIT’s OpenCourseWare uses MIT’s Google Search Appliance (GSA) to search its content.  MIT supports customization of GSA results through XSL transformation.  This post describes how we plan to use GSA to search lecture transcripts and return results containing the lecture videos that the search terms appear in.  Since OCW publishes static content, it doesn’t incorporate an integral search engine.  Search is provided through MIT’s Google Search Appliance (GSA) which indexes all OCW content and provides a familiar search paradigm to users.  For the purpose of searching lecture transcripts though the default behavior is unsatisfactory.  The reason is that searching for words that appear in a lecture transcript will return not only pages containing transcripts containing the words, it will return every occurrence of the words in the OCW site.  In addition, the current pages that contain lecture transcripts provide no way to see the portion of the lecture video where the words occur.  Changing the way GSA returns its results is one way to remedy this situation without changing the static nature of the OCW content.

The target use case, then, is searching for words that occur in lecture transcripts with the search results conveniently allowing a user to see and hear the lecture at the point that the word occurs.  We can make this happen by integrating a number of independent processes.

  • Obtain or generate a transcript for the lecture video.
  • Format the transcript so that it is an appropriate target for GSA search.
  • Modify the default Google XSL transformation so that it returns our custom results page.
  • Modify a video player so that it plays the lecture from near the point that the search term occurs.

Generate a Transcript for a Lecture Video

Generating transcripts from lecture videos is described here.

Format a Transcript as a GSA Search Target

The speech recognition process produces a variety of transcript files.  Some are just text, some are text and time codes.  None of the generated files include metadata describing the transcript they contain.  For the transcripts to serve as search targets they must include additional data that the XSL can use to produce the search results page.  This metadata is the minimum that the search target must include:

  • path to lecture video file
  • speaker
  • order of lecture within its course
  • video title

Customize Google Search XSL

Google returns its search results as a structured document that contains no presentation markup.  Each page that contains a search input control also specifies an XSL transformation to present the search results.  This is an example of the markup that appears in the page:

<input name="proxystylesheet" type="hidden" value="/oeit/OcwWeb/search/google-ocw.xsl" />

The default transformation creates the familiar Google search results page, but this transformation may be customized.  This is our strategy; our custom transformation will use GSA to search the transcripts and return the hits in a page that will allow viewing the lectures.

Edit Video Lecture Pages

GSA indexes pages by following links.  Since we will add a page to the site for each lecture transcript

Global Changes to Google search textbox

Google provides a XSL stylesheet for customizing the search results page.  Substitute your own custom xsl page for Google’s default stylesheet and change the reference to the stylesheet on every page that contains a search box to cause your customization take effect.

These command line commands makes this change.  (A Unix-like OS is assumed.)  Each command line follows a similar pattern.  They first use the find utility to create a list of the files to change.  This list is passed to the grep utility to filter the file list down to those files that contain the text to change.  This filtered list is passed to the perl utility to perform the change by performing a global substitution.

The first changes the XSL file from the default to your customized XSL.  Note that the argument to grep simply identifies those files that contain a search box.  (This argument could as easily have been ‘google-ocw.xsl’ which would been simpler and as effective.)

find .  -name '*.htm*' | xargs grep -l '<input type="hidden" value="ocw" name="site">' | xargs perl -p -i.bak -w -e 's/google-ocw.xsl/google-greenfield.xsl/g'

[update: the replacement above is incorrect. It fails to update the enough of the URL. Here’s a fix if you ran that replace script.]
find . -name 'index.htm' | xargs grep -l 'http://ocw.mit.edu/search/google-greenfield.xsl' | xargs perl -p -i.bak -w -e 's|http://ocw.mit.edu/search/google-greenfield.xsl|http://greenfield.mit.edu/oeit/OcwWeb/search/google-greenfield.xsl|g'

The next changes the name of the site to search.  You may not have to change this value.  In our case, we created our own Google search “collection” that contained our copy of the OCW site.

find . -name '*.htm*' | xargs grep -l '<input type="hidden" value="ocw" name="site">' | xargs perl -p -i.bak -w -e 's/input type="hidden" value="ocw" name="site"/input type="hidden" value="oeit-ocw" name="site"/g'

The last specifies the URL of our Google search engine.  The reason for this change is that the courses in our OCW instance were collected by using the “download course materials” zip that many OCW courses provide.  Since these are intended for download, their search feature is disabled.

find . -name '*.htm*' | xargs grep -l 'form method="get" action="(../){1,3}common/search/AdvancedSearch.htm"' | xargs  perl -p -i.bak -w -e 's|form method="get" action="(../){1,3}common/search/AdvancedSearch.htm"|form method="get" action="http://search.mit.edu/search"|g'


find . -name '*.htm' | xargs perl -p -i.bak -w -e 's|<input type="hidden" name="proxystylesheet" value="/oeit/OcwWeb/search/google-ocw.xsl" />|<input type="hidden" name="proxystylesheet" value="http://greenfield.mit.edu/oeit/OcwWeb/search/google-greenfield.xsl" />|g'

]]>
Towards cross-video search https://spokenmedia.mit.edu/2010/06/towards-cross-video-search/ Mon, 21 Jun 2010 14:30:57 +0000 http://spokenmedia.mit.edu/?p=551 Here’s a workflow diagram I put together to demonstrate how we’re approaching the problem of searching over the transcripts of multiple videos and ultimately returning search results that maintain time-alignment for playback.

Preparing Transcripts for Search Across Multiple Videos
Source: Brandon Muramatsu

Preparing Transcripts for Search Across Multiple Videos

You’ll notice I included using OCW on lecture slides to help in search and retrieval–this is not an area we’re currently focusing on, but we have been asked about it. A number of researchers and developers have looked at this area–if/when we include it, we’d work with folks like Matterhorn (or perhaps others) to integrate the solutions that they’ve implemented.

]]>
Using Lucene/Solr for Transcript Search https://spokenmedia.mit.edu/2010/06/using-lucenesolr-for-transcript-search/ Wed, 16 Jun 2010 20:36:19 +0000 http://spokenmedia.mit.edu/?p=525 Overview

In any but a trivial implementation, searching lecture transcripts presents challenges not found in other search targets.  Major among them is that each transcript word requires its own metadata (start and stop times).  Solr, a web application that derives its search muscle from Apache Lucene, has a query interface that is both rich and flexible.  It doesn’t hurt that it’s also very fast.  Properly configured, it provides an able platform to support lecture transcript searching.  Although Solr is the server, the search itself is performed by Lucene so much of the discussion will address Lucene specifically.  The integration with the server will be discussed in a subsequent posting.

Objective

We want to implement an automated work flow that can take a file that contains all the words spoken in the lecture, along with their start and stop times and persist them into a repository that will allow us to:

  • search all transcripts for a word, phrase, or keyword with factored searches, word-stemming, result ranking, and spelling correction.
  • Have the query result include metadata that will allow us to show a video clip mapping the word to the place in the video where it is uttered.
  • Allow a transcript editing application to modify the content of the word file, as well as the time codes, in real-time.
  • Dependably maintain mapping between words and their time codes.

Technique

The WRD file contains the transcript for a single lecture, one word to a line.  Preceding each word on its line is its start and stop time in milliseconds.  We call this format a WRD file[1] and you can see a snippit of it below.

To use Lucene/Solr, the first task is loading the data.  Lucene reads the data and creates an index.

The first transformation of the workflow is to convert the WRD file into a format that may be easily POST’ed into Solr.  (Solr allows uploading documents by passing a URL to the Solr server with an appended query string specifying the upload document.)  I’m currently performing the transformation from WRD to the required XML format manually in an editor.  I’m taking a series of lines like this:

...
6183 6288 in
6288 6868 physics
7186 7342 we
7342 8013 explore
9091 9181 the
9181 9461 very
9461 9956 small
10741 10862 to
10862 10946 the
10946 11226 very
11226 11686 large
...

to this:

...
<field name="trans_word">In</field>
<field name="trans_word">physics</field>
<field name="trans_word">we</field>
<field name="trans_word">explore</field>
<field name="trans_word">the</field>
<field name="trans_word">very</field>
<field name="trans_word">small</field>
<field name="trans_word">to</field>
<field name="trans_word">the</field>
<field name="trans_word">very</field>
<field name="trans_word">large</field>
...

Automating the transformation as shown above will be trivial, especially since there are libraries available for a variety of programming language.  What you will have noticed is that the uploaded content doesn’t include the time codes.  Snap!

So it seems that it is easy to use Lucene/Solr to perform a full featured search of transcripts, and it’s easy to use a database to search for single transcript words and retrieve their timecodes, but there isn’t a tool that allow me to integrate these two requirements out-of-the-box.

Ideally, we want to store the word together with its time codes while still permitting Solr to work its search magic.

There are a couple of ways to perform this integration as an additional step, which isn’t my preference.[2]  Once uploaded, I can use a test tool to return character offsets for words in transcripts.  That’s the raw data I need to work with individual words and still have useful full-text searching, now I’ve got to figure out what to do with it.
Here’s what the data looks like for the word “yes” in Lewin’s first lecture:
...
<lst name="yes">
<int name="tf">3</int>
<lst name="offsets">
<int name="start">6402</int>
<int name="end">6405</int>
<int name="start">20045</int>
<int name="end">20048</int>
<int name="start">22858</int>
<int name="end">22861</int>
</lst>
<int name="df">1</int>
</lst>
...

tf” is term frequency
offsets” are the start and end position in characters.

Lucene Payloads

Lucene has an advanced feature that stores additional metadata with each indexed token (in our case, that is a transcript word).  The payload feature is usually used to influence the ranking of search results, but it can be used for other purposes as well.[3]  What recommends it for our use is that it stores the data in the index, so it is readily available as part of the search result.  The preparation of the transcript would change also.  Using the WRD file example from the Technique section above, we would produce this file:

" in|6183 physics|6288 we|7186 explore|7342 the|9091 very|9181 small|9461 to|10741 the|10862 very|10946 large|11226 "


[1] The .WRD extension is an artifact of previous development and has no relationship to desktop software applications that may use this same file extension.

[2] The reason I don’t favor integrating these two as an extra step is that I would need to maintain referential integrity between two independent datastores.  (Remember, that we also have the requirement of editing both transcript words timecodes.)

[3] Update: Lucene has a feature called payloads which will allow me to store the timecodes with the words.  Here is a link to a blog post that explains the technique.

]]>