public byte process(Target target) { Element segment = navigator.getElement(target); if (segment == null) return values.get(pauseSymbol); if (!segment.getTagName().equals(MaryXML.PHONE)) return values.get(pauseSymbol); String ph = segment.getAttribute("p"); if (!values.contains(ph)) return values.get("0"); return values.get(ph); }
public byte process(Target target) { Element segment = navigator.getElement(target); if (segment == null) return values.get(pauseSymbol); if (!segment.getTagName().equals(MaryXML.PHONE)) return values.get(pauseSymbol); String ph = segment.getAttribute("p"); if (!values.contains(ph)) return values.get("0"); return values.get(ph); }
/** * @param target * the item to process * @return a guess at the part-of-speech for the item */ public byte process(Target target) { Element word = navigator.getElement(target); if (word == null) return values.get("0"); String pos = word.getAttribute("pos"); if (pos == null) return values.get("0"); pos = pos.trim(); if (values.contains(pos)) return values.get(pos); return values.get("0"); } }
/** * @param target * the item to process * @return a guess at the part-of-speech for the item */ public byte process(Target target) { Element word = navigator.getElement(target); if (word == null) return values.get("0"); String pos = word.getAttribute("pos"); if (pos == null) return values.get("0"); pos = pos.trim(); if (values.contains(pos)) return values.get(pos); return values.get("0"); } }
public byte process(Target target) { if (!(target instanceof HalfPhoneTarget)) return 0; HalfPhoneTarget hpTarget = (HalfPhoneTarget) target; String value = (hpTarget.isLeftHalf() ? "L" : "R"); return values.get(value); } }
public byte process(Target target) { if (!(target instanceof HalfPhoneTarget)) return 0; HalfPhoneTarget hpTarget = (HalfPhoneTarget) target; String value = (hpTarget.isLeftHalf() ? "L" : "R"); return values.get(value); } }
public byte process(Target target) { Element segment = navigator.getElement(target); if (segment == null) return values.get("0"); String ph; if (!segment.getTagName().equals(MaryXML.PHONE)) { ph = pauseSymbol; } else { ph = segment.getAttribute("p"); } String value = phoneSet.getPhoneFeature(ph, phonesetQuery); if (value == null) return values.get("0"); return values.get(value); } }
public byte process(Target target) { Element segment = navigator.getElement(target); if (segment == null) return values.get("0"); String ph; if (!segment.getTagName().equals(MaryXML.PHONE)) { ph = pauseSymbol; } else { ph = segment.getAttribute("p"); } String value = phoneSet.getPhoneFeature(ph, phonesetQuery); if (value == null) return values.get("0"); return values.get(value); } }
/** * For the given syllable item, return its tobi accent, or 0 if there is none. */ public byte process(Target target) { Element syllable = navigator.getElement(target); if (syllable == null) return 0; String accent = syllable.getAttribute("accent"); if (accent.equals("")) { return 0; } return values.get(accent); } }
/** * For the given syllable item, return its tobi accent, or 0 if there is none. */ public byte process(Target target) { Element syllable = navigator.getElement(target); if (syllable == null) return 0; String accent = syllable.getAttribute("accent"); if (accent.equals("")) { return 0; } return values.get(accent); } }
public byte process(Target target) { if (!(target instanceof HalfPhoneTarget)) return 0; HalfPhoneTarget hpTarget = (HalfPhoneTarget) target; Element segment = target.getMaryxmlElement(); String phoneLabel; if (segment == null) { phoneLabel = pauseSymbol; } else if (!segment.getTagName().equals(MaryXML.PHONE)) { phoneLabel = pauseSymbol; } else { phoneLabel = segment.getAttribute("p"); } if (phoneLabel.equals("")) return values.get("0"); String unitLabel = phoneLabel + (hpTarget.isLeftHalf() ? "_L" : "_R"); return values.get(unitLabel); } }
public byte process(Target target) { Element s = target.getMaryxmlElement(); if (s == null) { return 0; } if (!s.getTagName().equals(MaryXML.PHONE)) return 0; while ((s = MaryDomUtils.getNextSiblingElement(s)) != null) { String ph = s.getAttribute("p"); if ("+".equals(phoneSet.getPhoneFeature(ph, "vc"))) { return values.get("onset"); } } return values.get("coda"); } }
public byte process(Target target) { Element s = target.getMaryxmlElement(); if (s == null) { return 0; } if (!s.getTagName().equals(MaryXML.PHONE)) return 0; while ((s = MaryDomUtils.getNextSiblingElement(s)) != null) { String ph = s.getAttribute("p"); if ("+".equals(phoneSet.getPhoneFeature(ph, "vc"))) { return values.get("onset"); } } return values.get("coda"); } }
@Test public void smallListCompareString() { Assert.assertEquals(t10.get((byte) 5), "a" + 5); }
@Test public void maxListCompareString() { Assert.assertEquals(tMax.get((byte) (ByteStringTranslator.MAXNUM - 1)), "b" + (ByteStringTranslator.MAXNUM - 1)); }
@Test public void maxListCompareString2() { Assert.assertEquals(tMax.get("b" + (ByteStringTranslator.MAXNUM - 1)), (byte) (ByteStringTranslator.MAXNUM - 1)); }
public byte process(Target target) { String style = null; Element segment = target.getMaryxmlElement(); if (segment != null) { Element prosody = (Element) MaryDomUtils.getClosestAncestorWithAttribute(segment, MaryXML.PROSODY, styleTagName); if (prosody != null) { style = prosody.getAttribute(styleTagName); } } if (style == null || style.equals("")) style = "0"; if (values.contains(style)) { return values.get(style); } else { // silently ignore unknown values return 0; } } }
public byte process(Target target) { String style = null; Element segment = target.getMaryxmlElement(); if (segment != null) { Element prosody = (Element) MaryDomUtils.getClosestAncestorWithAttribute(segment, MaryXML.PROSODY, styleTagName); if (prosody != null) { style = prosody.getAttribute(styleTagName); } } if (style == null || style.equals("")) style = "0"; if (values.contains(style)) { return values.get(style); } else { // silently ignore unknown values return 0; } } }
@Test public void testToStringValues() { String[] values = processor.getValues(); ByteStringTranslator translator = new ByteStringTranslator(values); for (String expected : values) { byte feature = translator.get(expected); FeatureVector vector = new FeatureVector(new byte[] { feature }, new short[] {}, new float[] {}, 0); String actual = computer.toStringValues(vector); assertEquals(expected, actual); } }
@Test public void testToStringValues() { String[] values = processor.getValues(); ByteStringTranslator translator = new ByteStringTranslator(values); for (String expected : values) { byte feature = translator.get(expected); FeatureVector vector = new FeatureVector(new byte[] { feature }, new short[] {}, new float[] {}, 0); String actual = computer.toStringValues(vector); assertEquals(expected, actual); } }