Skip to content

Instantly share code, notes, and snippets.

@veer66
Last active August 29, 2015 14:01
Show Gist options
  • Save veer66/e86cc7fc7a8707820c2f to your computer and use it in GitHub Desktop.
Save veer66/e86cc7fc7a8707820c2f to your computer and use it in GitHub Desktop.
reading expanded (Apertium) dix
module LDIX
class Parser
def initialize
end
def parse_tag(raw)
if raw.nil?
[]
else
raw.map{|t| t[1..-2]}
.select{|t| not t.nil?}
end
end
def parse_col(col)
if col.empty?
nil
else
toks = col.split(/(<\w+>)/)
{headword: toks[0],
tags: parse_tag(toks[1..-1])}
end
end
def parse_line(line)
line
.chomp
.split(/:[<>]:|:/)
.map{|col| parse_col(col)}
end
end
end
@veer66
Copy link
Author

veer66 commented May 19, 2014

Use /:|:[<>]:/ to split left and right as Unhammer recommended

@veer66
Copy link
Author

veer66 commented Oct 14, 2014

/:|:[<>]:/ didn't work
/:[<>]:|:/ do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment