Created
August 28, 2015 15:48
-
-
Save j3k0/ec74d1090adac68b8fed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#globals emit | |
teiAligner = require "./tei/aligner" | |
exportObject = (name, obj, funcNames) -> | |
"var #{name} = {\n" + | |
("\"#{f}\":" + obj[f] for f in funcNames).join(",\n") + | |
"\n};\n" | |
module.exports = [ | |
name: "documents" | |
views: | |
metadata: | |
map: "" + (doc) -> | |
if doc.metadata | |
emit doc._id, doc.metadata | |
alignments: | |
map: "function(doc) {\n" + | |
exportObject("aligner", teiAligner, | |
["extractSegments","mergeSegments"]) + | |
"(" + | |
((doc) -> | |
segs = {} | |
for lang, d of doc.docs | |
segs[lang] = aligner.extractSegments d | |
segments = aligner.mergeSegments segs | |
for seg in segments | |
emit [doc._id, seg.index], seg | |
) + | |
").call(this, doc);" + | |
"\n}" | |
] | |
# vim: ts=2:sw=2:et: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment