+ (translate-files (find-ufile "MRXW_NONENG.RRF")
+ extension (noneng-lang-index-files) :force force))
+
+(defun verify-translation-file (output-path input-ufiles)
+ "Returns t if translation file exists and is correct size. Warns and deletes incomplete translation file."
+ (when (probe-file output-path)
+ (let ((translated-lines 0)
+ (input-lines 0)
+ (eof (cons nil nil)))
+ (catch 'done-counting
+ (with-open-file (ts output-path :direction :input
+ #+(and sbcl sb-unicode) :external-format
+ #+(and sbcl sb-unicode) :UTF-8
+ #+(and allegro ics) :external-format
+ #+(and allegro ics) :UTF-8
+ #+lispworks :external-format
+ #+lispworks :UTF-8
+ #+(and clisp unicode) :external-format
+ #+(and clisp unicode) charset:utf-8)
+ (do ((c (read-char ts nil eof) (read-char ts nil eof)))
+ ((eq c eof))
+ (when (eql c #\newline)
+ (incf translated-lines))))
+ (dolist (input-ufile input-ufiles)
+ (with-umls-ufile (line input-ufile)
+ (incf input-lines)
+ (when (> input-lines translated-lines)
+ (throw 'done-counting 'incomplete)))))
+ (cond
+ ((< input-lines translated-lines)
+ (format t "Translated file ~A incomplete, deleting...~%" output-path)
+ (delete-file output-path)
+ nil)
+ ((eql input-lines translated-lines)
+ (format t "Translated file ~A already exists: skipping...~%" output-path)
+ t)
+ ((eql input-lines 0)
+ (warn "The number of input lines is 0 for output file ~A." output-path)
+ nil)
+ ((> translated-lines input-lines)
+ (error "Shouldn't happen. Translated lines of ~A is ~D, greater than input lines ~D"
+ output-path translated-lines input-lines)
+ (delete-file output-path)
+ nil)))))
+
+(defun translate-files (out-ufile extension input-ufiles &key force)