Difference between revisions of "Ltarlin1/Final Project"

From LING073
Jump to: navigation, search
Line 94: Line 94:
 
Once you add the line <code>\usepackage{tikz-dependency}</code> to a blank Latex file, you can add this code and get the resulting image:
 
Once you add the line <code>\usepackage{tikz-dependency}</code> to a blank Latex file, you can add this code and get the resulting image:
  
−
asdf
+
[[File:Lee-graph.png|800px|Dependency tree of "The resulting graph after running the original CG dependency file through my program.]]
 +
 
  
 
== Evaluation ==
 
== Evaluation ==
 
it works, i promise
 
it works, i promise
−
 
−
 
  
  
 
[[Category:sp17_FinalProjects]]
 
[[Category:sp17_FinalProjects]]

Revision as of 07:03, 5 May 2017

The Problem

For my final project, I decided to create an autoglosser that would automatically convert the universal dependency files we worked with in class into visual form in Latex. There is a Latex package called tikz-dependency that allows for quick input of sentences and its corresponding dependencies, but it still requires the user to manually select each dependency. Therefore, my code automatically generates Latex code that fits the expected format for the tikz-dependency package and therefore can easily be displayed in a graph, as in the following example image:

Dependency tree of "An example output of the tikz-dependency latex package.


Previous Work

As discussed in the above section, the tikz-dependency package uses the tikz interface to facilitate the graph-making process. The syntax of a dependency in this format is strikingly similar to that which we saw in class (i.e. #4->6) because both refer to the "from word" and the "to word" using offset from the beginning of the sentence.

Theoretically, I would be able to also convert input files in the conllu format (as well as the CG format we worked with in class) to appropriate Latex code, but I do not fully understand this format yet. I will continue to learn about the conllu format and hopefully have it up and running in a few days.

Users

This tool would be useful for linguists who want to speed up the visual-making process when working with universal dependencies. It does not have much of an application outside the technical linguistics domain because generating the input files to my program requires knowledge of universal dependencies.

The Solution

My autoglosser parses each line of the CG file and separates it into the relevant portions--the words that make up the sentence, the other word that it depends on, and the type of dependence relationship. The other information belonging to that word, such as part of speech, are included in the parse but ignored at this point.

Therefore, a CG file like the one we looked at in class

"<The>"
	"The" det def sp @det #1->4
"<quick>"
	"quick" adj sint @amod #2->4
"<brown>"
	"brown" adj @amod #3->4
"<fox>"
	"fox" n sg @nsubj #4->5
"<jumps>"
	"jump" vblex pres p3 sg @root #5->0
"<over>"
	"over" pr @case #6->9
"<the>"
	"the" det def sp @det #7->9
"<lazy>"
	"lazy" adj sint @amod #8->9
"<dog>"
	"dog" n sg @obl #9->5
"<in>"
	"in" pr @case #10->13
"<the>"
	"the" det def sp @det #11->13
"<green>"
	"green" adj sint @amod #12->13
"<fields>"
	"field" n pl @obl #13->5
"<.>"
	"." sent

is turned into something like this:

words = ['The', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog', 'in', 'the', 'green', 'fields', '.']

info = [
['"The"', 'det', 'def', 'sp', '@det', '#1->4'], 
['"quick"', 'adj', 'sint', '@amod', '#2->4'], 
['"brown"', 'adj', '@amod', '#3->4'], 
['"fox"', 'n', 'sg', '@nsubj', '#4->5'], 
['"jump"', 'vblex', 'pres', 'p3', 'sg', '@root', '#5->0'], 
['"over"', 'pr', '@case', '#6->9'], 
['"the"', 'det', 'def', 'sp', '@det', '#7->9'], 
['"lazy"', 'adj', 'sint', '@amod', '#8->9'], 
['"dog"', 'n', 'sg', '@obl', '#9->5'], 
['"in"', 'pr', '@case', '#10->13'], 
['"the"', 'det', 'def', 'sp', '@det', '#11->13'], 
['"green"', 'adj', 'sint', '@amod', '#12->13'], 
['"field"', 'n', 'pl', '@obl', '#13->5'], 
['"."', 'sent']]

The next step that my program takes is using string formatting to extract the relevant aspects of this "info"--namely the "from word", the "to word", and the type of dependency (indicated by the '@' symbol). Once I have all of this information, I can simply plug it into the corresponding locations in the desired format. Therefore, the final Latex code outputted by my program is

\begin{dependency}
	\begin{deptext}[column sep=0.2cm]
		The \& quick \& brown \& fox \& jumps \& over \& the \& lazy \& dog \& in \& the \& green \& fields \& ROOT \\ 
	\end{deptext}
	\depedge{4}{1}{det}
	\depedge{4}{2}{amod}
	\depedge{4}{3}{amod}
	\depedge{5}{4}{nsubj}
	\depedge{14}{5}{root}
	\depedge{9}{6}{case}
	\depedge{9}{7}{det}
	\depedge{9}{8}{amod}
	\depedge{5}{9}{obl}
	\depedge{13}{10}{case}
	\depedge{13}{11}{det}
	\depedge{13}{12}{amod}
	\depedge{5}{13}{obl}
\end{dependency}

Once you add the line \usepackage{tikz-dependency} to a blank Latex file, you can add this code and get the resulting image:

Dependency tree of "The resulting graph after running the original CG dependency file through my program.


Evaluation

it works, i promise