Exemplo n.º 1
0
        public virtual Item getItem(string relation, float time)
        {
            string pathAndFeature;

            if (String.instancehelper_equals(relation, "Word"))
            {
                pathAndFeature = "R:SylStructure.parent.parent.R:Word";
            }
            else
            {
                if (!String.instancehelper_equals(relation, "Token"))
                {
                    string text = new StringBuilder().append("Utterance.getItem(): relation cannot be ").append(relation).toString();

                    throw new IllegalArgumentException(text);
                }
                pathAndFeature = "R:SylStructure.parent.parent.R:Token.parent";
            }
            PathExtractor pathExtractor = new PathExtractor(pathAndFeature, false);
            Item          item          = Utterance.getItem(this.getRelation(relation), time);

            if (item != null)
            {
                return(pathExtractor.findItem(item));
            }
            return(null);
        }
Exemplo n.º 2
0
 internal Relation(string text, Utterance utterance)
 {
     this.name  = text;
     this.owner = utterance;
     this.head  = null;
     this.tail  = null;
 }
Exemplo n.º 3
0
        private static Item findFromFront(Relation relation, float num)
        {
            Item item = relation.getHead();

            while (item != null && num > Utterance.getSegmentEnd(item))
            {
                item = item.getNext();
            }
            return(item);
        }
Exemplo n.º 4
0
        private static Item findFromEnd(Relation relation, float num)
        {
            Item item = relation.getTail();

            while (item != null && Utterance.getSegmentEnd(item) > num)
            {
                item = item.getPrevious();
            }
            if (item != relation.getTail())
            {
                item = item.getNext();
            }
            return(item);
        }
Exemplo n.º 5
0
        private static Item getItem(Relation relation, float num)
        {
            Item  tail       = relation.getTail();
            float segmentEnd = Utterance.getSegmentEnd(tail);

            if (num < 0f || segmentEnd < num)
            {
                return(null);
            }
            if (segmentEnd - num > num)
            {
                return(Utterance.findFromFront(relation, num));
            }
            return(Utterance.findFromEnd(relation, num));
        }
Exemplo n.º 6
0
        public static WordRelation createWordRelation(Utterance utterance, USEnglishTokenizer tokenToWords)
        {
            Relation relation = utterance.createRelation("Word");

            return(new WordRelation(relation, tokenToWords));
        }