📄 transcriber14parser.java
字号:
} else { int num = (new Integer(nb)).intValue(); int counter = 1; if (speakersForCurrentTurn != null) { StringTokenizer tokenizer = new StringTokenizer(speakersForCurrentTurn); while (tokenizer.hasMoreTokens()) { String spkr = tokenizer.nextToken(); if (counter++ == num) { currentSpeakerId = spkr; break; } } } } } else if (qName.equals("Background")) { backgroundArrayList.add(new BackgroundRecord( attributes.getValue("time"), attributes.getValue("type"), attributes.getValue("level"))); } else if (qName.equals("Topic")) { topicHash.put(attributes.getValue("id"), attributes.getValue("desc")); } else if (qName.equals("Comment")) { if (!currentComments.equals("")) { currentComments += " "; } currentComments += ("{" + attributes.getValue("desc") + "}"); } } //startElement private void storeUtterances(String time) { String spkId = ""; String spkContent = ""; // store utterance(s) for each speaker in Turn Iterator it = currentSpeakerContents.keySet().iterator(); while (it.hasNext()) { spkId = (String) it.next(); spkContent = (String) currentSpeakerContents.get(spkId); if (!spkContent.equals("")) { utteranceRecords.add(new UtteranceRecord(spkContent, (String) speakersHash.get(spkId), lastSyncTime, time, lastTurnRecord)); } } // reset // clean currentSpeakerContents Iterator it2 = currentSpeakerContents.keySet().iterator(); while (it2.hasNext()) { spkId = (String) it2.next(); currentSpeakerContents.put(spkId, ""); } lastSectionRecord = currentSectionRecord; lastTurnRecord = currentTurnRecord; } private void storeComments(String time) { if (!currentComments.equals("")) { commentRecords.add(new CommentRecord(lastSyncTime, time, currentComments)); currentComments = ""; } } /** * ContentHandler method * * @param nameSpaceURI DOCUMENT ME! * @param name DOCUMENT ME! * @param rawName DOCUMENT ME! * * @throws SAXException DOCUMENT ME! */ public void endElement(String nameSpaceURI, String name, String qName) throws SAXException { if (qName.equals("Section") && (currentSectionRecord != null)) { // make sure last utterance is stored String time = currentSectionRecord.endTime; storeUtterances(time); storeComments(time); // store lastSyncTime = time; } } /** * ContentHandler method * * @param ch DOCUMENT ME! * @param start DOCUMENT ME! * @param end DOCUMENT ME! * * @throws SAXException DOCUMENT ME! */ public void characters(char[] ch, int start, int end) throws SAXException { if ((currentSpeakerContents == null) || (currentSpeakerId == null)) { return; } String content = (String) currentSpeakerContents.get(currentSpeakerId); if (content != null) { content += new String(ch, start, end).trim(); } currentSpeakerContents.put(currentSpeakerId, content); } /** * DOCUMENT ME! * * @param publicId DOCUMENT ME! * @param systemId DOCUMENT ME! * * @return DOCUMENT ME! */ public InputSource resolveEntity(String publicId, String systemId) { // do this to prevent an exception when a DTD is not found return new InputSource(new StringReader("")); } } /** * DOCUMENT ME! * $Id: jalopy_gnu_src_dist.xml,v 1.3 2007/02/06 13:30:33 hasloe Exp $ * @author $Author: hasloe $ * @version $Revision: 1.3 $ */ private class SectionRecord { /** Holds value of property DOCUMENT ME! */ public String type; /** Holds value of property DOCUMENT ME! */ public String startTime; /** Holds value of property DOCUMENT ME! */ public String endTime; /** Holds value of property DOCUMENT ME! */ public String topicId; /** Holds value of property DOCUMENT ME! */ public ArrayList turnRecords; /** * Creates a new SectionRecord instance * * @param type DOCUMENT ME! * @param startTime DOCUMENT ME! * @param endTime DOCUMENT ME! * @param topicId DOCUMENT ME! */ public SectionRecord(String type, String startTime, String endTime, String topicId) { this.type = type; this.startTime = startTime; this.endTime = endTime; this.topicId = topicId; turnRecords = new ArrayList(); } } /** * DOCUMENT ME! * $Id: jalopy_gnu_src_dist.xml,v 1.3 2007/02/06 13:30:33 hasloe Exp $ * @author $Author: hasloe $ * @version $Revision: 1.3 $ */ private class TurnRecord { /** Holds value of property DOCUMENT ME! */ public String startTime; /** Holds value of property DOCUMENT ME! */ public String endTime; /** Holds value of property DOCUMENT ME! */ public String mode; /** Holds value of property DOCUMENT ME! */ public String fidelity; /** Holds value of property DOCUMENT ME! */ public String channel; /** Holds value of property DOCUMENT ME! */ public String speakers; /** * Creates a new TurnRecord instance * * @param startTime DOCUMENT ME! * @param endTime DOCUMENT ME! * @param speakers DOCUMENT ME! * @param mode DOCUMENT ME! * @param fidelity DOCUMENT ME! * @param channel DOCUMENT ME! */ public TurnRecord(String startTime, String endTime, String speakers, String mode, String fidelity, String channel) { this.startTime = startTime; this.endTime = endTime; this.speakers = speakers; this.mode = mode; this.fidelity = fidelity; this.channel = channel; } } /** * DOCUMENT ME! * $Id: jalopy_gnu_src_dist.xml,v 1.3 2007/02/06 13:30:33 hasloe Exp $ * @author $Author: hasloe $ * @version $Revision: 1.3 $ */ private class UtteranceRecord { /** Holds value of property DOCUMENT ME! */ public String text; /** Holds value of property DOCUMENT ME! */ public String speaker; /** Holds value of property DOCUMENT ME! */ public String startTime; /** Holds value of property DOCUMENT ME! */ public String endTime; /** Holds value of property DOCUMENT ME! */ public TurnRecord turnRecord; /** * Creates a new UtteranceRecord instance * * @param text DOCUMENT ME! * @param speaker DOCUMENT ME! * @param startTime DOCUMENT ME! * @param endTime DOCUMENT ME! * @param turnRecord DOCUMENT ME! */ public UtteranceRecord(String text, String speaker, String startTime, String endTime, TurnRecord turnRecord) { this.text = text; this.speaker = speaker; this.startTime = startTime; this.endTime = endTime; this.turnRecord = turnRecord; } } /** * DOCUMENT ME! * $Id: jalopy_gnu_src_dist.xml,v 1.3 2007/02/06 13:30:33 hasloe Exp $ * @author $Author: hasloe $ * @version $Revision: 1.3 $ */ private class BackgroundRecord { /** Holds value of property DOCUMENT ME! */ public String time; /** Holds value of property DOCUMENT ME! */ public String type; /** Holds value of property DOCUMENT ME! */ public String level; /** * Creates a new BackgroundRecord instance * * @param time DOCUMENT ME! * @param type DOCUMENT ME! * @param level DOCUMENT ME! */ public BackgroundRecord(String time, String type, String level) { this.time = time; this.type = type; this.level = level; } } /** * DOCUMENT ME! * $Id: jalopy_gnu_src_dist.xml,v 1.3 2007/02/06 13:30:33 hasloe Exp $ * @author $Author: hasloe $ * @version $Revision: 1.3 $ */ private class CommentRecord { /** Holds value of property DOCUMENT ME! */ public String begin; /** Holds value of property DOCUMENT ME! */ public String end; /** Holds value of property DOCUMENT ME! */ public String desc; /** * Creates a new CommentRecord instance * * @param begin DOCUMENT ME! * @param end DOCUMENT ME! * @param desc DOCUMENT ME! */ public CommentRecord(String begin, String end, String desc) { this.begin = begin; this.end = end; this.desc = desc; } } /** * DOCUMENT ME! * $Id: jalopy_gnu_src_dist.xml,v 1.3 2007/02/06 13:30:33 hasloe Exp $ * @author $Author: hasloe $ * @version $Revision: 1.3 $ */ class PairComparator implements Comparator { /** * Compares pairs {String tsId, Long time}, first on basis of time, then on * basis of number part of id * * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(Object arg0, Object arg1) { ArrayList pair0 = (ArrayList) arg0; ArrayList pair1 = (ArrayList) arg1; long time0 = ((Long) pair0.get(1)).longValue(); long time1 = ((Long) pair1.get(1)).longValue(); if (time0 < time1) { return -1; } if (time0 > time1) { return 1; } if (time0 == time1) { long id0 = new Long(((String) pair0.get(0)).substring( TS_PREFIX.length())).longValue(); long id1 = new Long(((String) pair1.get(0)).substring( TS_PREFIX.length())).longValue(); if (id0 < id1) { return -1; } if (id0 > id1) { return 1; } } return 0; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -