⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 acm23transcriptionstore.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * File:     ACM23TranscriptionStore.java * Project:  MPI Linguistic Application * Date:     02 May 2007 * * Copyright (C) 2001-2007  Max Planck Institute for Psycholinguistics * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */package mpi.eudico.server.corpora.clomimpl.dobes;import mpi.eudico.server.corpora.clom.Annotation;import mpi.eudico.server.corpora.clom.DecoderInfo;import mpi.eudico.server.corpora.clom.EncoderInfo;import mpi.eudico.server.corpora.clom.Tier;import mpi.eudico.server.corpora.clom.TimeOrder;import mpi.eudico.server.corpora.clom.TimeSlot;import mpi.eudico.server.corpora.clom.Transcription;import mpi.eudico.server.corpora.clom.TranscriptionStore;import mpi.eudico.server.corpora.clomimpl.abstr.AlignableAnnotation;import mpi.eudico.server.corpora.clomimpl.abstr.Parser;import mpi.eudico.server.corpora.clomimpl.abstr.ParserFactory;import mpi.eudico.server.corpora.clomimpl.abstr.RefAnnotation;import mpi.eudico.server.corpora.clomimpl.abstr.SVGAlignableAnnotation;import mpi.eudico.server.corpora.clomimpl.abstr.TierImpl;import mpi.eudico.server.corpora.clomimpl.abstr.TimeOrderImpl;import mpi.eudico.server.corpora.clomimpl.abstr.TimeSlotComparator;import mpi.eudico.server.corpora.clomimpl.abstr.TimeSlotImpl;import mpi.eudico.server.corpora.clomimpl.abstr.TranscriptionImpl;import mpi.eudico.server.corpora.clomimpl.chat.CHATEncoder;import mpi.eudico.server.corpora.clomimpl.shoebox.ShoeboxEncoder;import mpi.eudico.server.corpora.clomimpl.type.Constraint;import mpi.eudico.server.corpora.clomimpl.type.IncludedIn;import mpi.eudico.server.corpora.clomimpl.type.LinguisticType;import mpi.eudico.server.corpora.clomimpl.type.SymbolicAssociation;import mpi.eudico.server.corpora.clomimpl.type.SymbolicSubdivision;import mpi.eudico.server.corpora.clomimpl.type.TimeSubdivision;import mpi.util.CVEntry;import mpi.util.ControlledVocabulary;import java.util.ArrayList;import java.util.Collections;import java.util.HashMap;import java.util.Iterator;import java.util.Locale;import java.util.Vector;import java.util.logging.Logger;/** * A TranscriptionStore that corresponds to EAF v2.3.<br> * Version 2.3 extends v2.2 by adding support for LinkedFileDescriptors and * for a new Constraint stereotype, INCLUDED_IN, which is a subdivision with gaps. * * @see EAF22TranscriptionStore * * @author Hennie Brugman * @author Han Sloetjes * @version jun 2004 * @version Aug 2005 Identity removed * @version Feb 2006 LinkedFileDescriptor and Included_In added */public class ACM23TranscriptionStore implements TranscriptionStore {    /** Holds value of property DOCUMENT ME! */    private static final Logger LOG = Logger.getLogger(ACM23TranscriptionStore.class.getName());    // we want the XML to be saved to a file    // HS 19-11-2002: "private final" changed to "public" to enable automatic    // backup (if fileToWirteXMLinto is not null, then the transcription will    // be written to that file    /** Holds value of property DOCUMENT ME! */    public java.io.File fileToWriteXMLinto = null;    private boolean debug = false;    /**     * Creates a new ACM23TranscriptionStore instance     */    public ACM23TranscriptionStore() {        super();        //debug = true;    }    /*    // File lacks println: here we add it.    // TO DO: put this somewhere in mpi.alt    public PrintWriter addPrintln(File f) {        try {            java.io.FileWriter fileWriter1 = new java.io.FileWriter(f);            return new PrintWriter(fileWriter1, true);        } catch (IOException ioe) {            // return null is all we say.        }        return null;    }    */    /**     * Requests to save the specified Transcription to a file.<br>     * The path to the file is taken from the Transcription.     *     * @param theTranscription the Transcription to save     * @param encoderInfo additional encoder information     * @param tierOrder the preferred ordering of the tiers     * @param format the document / file format     */    public void storeTranscription(Transcription theTranscription,        EncoderInfo encoderInfo, Vector tierOrder, int format) {        if (theTranscription instanceof TranscriptionImpl) {            String pathName = ((TranscriptionImpl) theTranscription).getPathName();            if (!pathName.substring(pathName.length() - 4, pathName.length() -                        3).equals(".")) {                pathName += ".eaf";            } else { //always give it extension eaf                pathName = pathName.substring(0, pathName.length() - 3);                pathName = pathName + "eaf";            }            storeTranscriptionIn(theTranscription, encoderInfo, tierOrder,                pathName, format);        }    }    /**     * Requests to save the specified Transcription to a file.<br>     * The path to the file is specified by the given pathName.     *     * @param theTranscription the Transcription to save     * @param tierOrder the preferred ordering of the tiers     * @param pathName the path to the file to use for storage     */    public void storeTranscription(Transcription theTranscription,        EncoderInfo encoderInfo, Vector tierOrder, String pathName, int format) {        if (theTranscription instanceof TranscriptionImpl) {            //String pathName = ((DobesTranscription) theTranscription).getPathName();            if (!pathName.substring(pathName.length() - 4, pathName.length() -                        3).equals(".")) {                pathName += ".eaf";            } else { //always give it extension eaf                pathName = pathName.substring(0, pathName.length() - 3);                pathName = pathName + "eaf";            }            storeTranscriptionIn(theTranscription, encoderInfo, tierOrder,                pathName, format);        }    }    /**     * Writes to the file specified by given path, unless the field     * <code>fileToWriteXMLinto</code> is not null.     *     * @param theTranscription the Transcription to save (not null)     * @param tierOrder the preferred ordering of the tiers     * @param path the path to the file to use for storage     */    public void storeTranscriptionIn(Transcription theTranscription,        EncoderInfo encoderInfo, Vector tierOrder, String path, int format) {        switch (format) {        case TranscriptionStore.EAF:            if (this.fileToWriteXMLinto != null) {                path = fileToWriteXMLinto.getAbsolutePath();            }            new EAF23Encoder().encodeAndSave(theTranscription, null, tierOrder,                path);            break;        case TranscriptionStore.CHAT:            new CHATEncoder().encodeAndSave(theTranscription, encoderInfo,                tierOrder, path);            break;        case TranscriptionStore.SHOEBOX:            new ShoeboxEncoder(path).encodeAndSave(theTranscription,                encoderInfo, tierOrder, path);            break;        default:            break;        }    }    /**     * Creates a template file using the given path, unless the field     * <code>fileToWriteXMLinto</code> is not null.     *     * @param theTranscription the Transcription to use for the template (not null)     * @param tierOrder the preferred ordering of the tiers     * @param path the path to the file to use for storage     */    public void storeTranscriptionAsTemplateIn(Transcription theTranscription,        Vector tierOrder, String path) {        if (this.fileToWriteXMLinto != null) {            path = fileToWriteXMLinto.getAbsolutePath();        }        new EAF23Encoder().encodeAsTemplateAndSave(theTranscription, tierOrder,            path);    }    /**     * Loads the Transcription from an eaf file.     *     * @param theTranscription the Transcription to load     */    public void loadTranscription(Transcription theTranscription) {        loadTranscription(theTranscription, null);    }    /**     * Loads the Transcription from an eaf file.     *     * @param theTranscription the transcription to load     * @param decoderInfo the info object for the decoder or parser     */    public void loadTranscription(Transcription theTranscription,        DecoderInfo decoderInfo) {        //	System.out.println("EAFTranscriptionStore.loadTranscription called");        TranscriptionImpl attisTr = (TranscriptionImpl) theTranscription;        String trPathName = attisTr.getPathName();        String lowerPathName = trPathName.toLowerCase();        Parser parser = null;        if (lowerPathName.endsWith("cha")) {            parser = ParserFactory.getParser(ParserFactory.CHAT);        } else if (lowerPathName.endsWith("txt")) { // Shoebox            parser = ParserFactory.getParser(ParserFactory.SHOEBOX);            parser.setDecoderInfo(decoderInfo);        } else if (lowerPathName.endsWith("trs")) { // Transcriber            parser = ParserFactory.getParser(ParserFactory.TRANSCRIBER);            parser.setDecoderInfo(decoderInfo);        } else if (lowerPathName.endsWith("imdi")) { // CGN            parser = ParserFactory.getParser(ParserFactory.CGN);        } else {            parser = ParserFactory.getParser(ParserFactory.EAF23);        }        long beginTime = System.currentTimeMillis();        // NOTE: media file is not used by either Elan 1.4.1 or Elan 2.0        // Instead MediaDescriptors are introduced. Mediafile is temporarily maintained        // for compatibility of EAF 2.1 with Elan 1.4.1        // set media transcription's media file        String mediaFileName = parser.getMediaFile(trPathName);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -