当前位置: 首页>>代码示例>>Java>>正文


Java ParseException类代码示例

本文整理汇总了Java中com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException的典型用法代码示例。如果您正苦于以下问题:Java ParseException类的具体用法?Java ParseException怎么用?Java ParseException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ParseException类属于com.sun.org.apache.xerces.internal.impl.xpath.regex包,在下文中一共展示了ParseException类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException; //导入依赖的package包/类
@Override
public void read(File file) throws IOException {

	try {
		Document doc = db.parse(file);

		NodeList nlTimeSlots = (NodeList) xp.evaluate(
				"/ANNOTATION_DOCUMENT/TIME_ORDER/TIME_SLOT", doc,
				XPathConstants.NODESET);

		HashMap<String, Double> timeSlots = new HashMap<String, Double>();

		for (int i = 0; i < nlTimeSlots.getLength(); i++) {
			Element timeSlot = (Element) nlTimeSlots.item(i);
			String id = timeSlot.getAttribute("TIME_SLOT_ID");
			int time = Integer
					.parseInt(timeSlot.getAttribute("TIME_VALUE"));
			timeSlots.put(id, time / 1000.0);
		}

		String txt;
		NodeList nlSegments = (NodeList) xp
				.evaluate(
						"/ANNOTATION_DOCUMENT/TIER/ANNOTATION/ALIGNABLE_ANNOTATION",
						doc, XPathConstants.NODESET);

		double segment_start, segment_end;
		String segment_text;

		for (int i = 0; i < nlSegments.getLength(); i++) {
			Element elSegment = (Element) nlSegments.item(i);

			txt = elSegment.getAttribute("TIME_SLOT_REF1");
			if (!timeSlots.containsKey(txt))
				throw new RuntimeException("Missing time slot: " + txt);
			segment_start = timeSlots.get(txt);

			txt = elSegment.getAttribute("TIME_SLOT_REF2");
			if (!timeSlots.containsKey(txt))
				throw new RuntimeException("Missing time slot: " + txt);
			segment_end = timeSlots.get(txt);

			segment_text = (String) xp.evaluate("ANNOTATION_VALUE",
					elSegment, XPathConstants.STRING);
			segment_text = segment_text.toLowerCase()
					.replaceAll("[\\p{Punct}]+", " ")
					.replaceAll("\\s+", " ").trim();

			addSegment(0, segment_start, segment_end, segment_text);
		}
	} catch (ParseException | SAXException | XPathExpressionException e) {
		throw new IOException(e);
	}
}
 
开发者ID:danijel3,项目名称:KaldiJava,代码行数:55,代码来源:EAF.java


注:本文中的com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。