コード例 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: static<T> void walk(util.fst.FST<T> fst) throws java.io.IOException
        internal static void walk <T>(FST <T> fst)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.ArrayList<util.fst.FST.Arc<T>> queue = new java.util.ArrayList<>();
            List <FST.Arc <T> > queue = new List <FST.Arc <T> >();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.BitSet seen = new java.util.BitSet();
            BitArray seen = new BitArray();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final util.fst.FST.BytesReader reader = fst.getBytesReader();
            FST.BytesReader reader = fst.BytesReader;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final util.fst.FST.Arc<T> startArc = fst.getFirstArc(new util.fst.FST.Arc<T>());
            FST.Arc <T> startArc = fst.getFirstArc(new FST.Arc <T>());
            queue.Add(startArc);
            while (queue.Count > 0)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final util.fst.FST.Arc<T> arc = queue.remove(0);
                FST.Arc <T> arc = queue.Remove(0);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long node = arc.target;
                long node = arc.target;
                //System.out.println(arc);
                if (FST.targetHasArcs(arc) && !seen.Get((int)node))
                {
                    seen.Set((int)node, true);
                    fst.readFirstRealTargetArc(node, arc, reader);
                    while (true)
                    {
                        queue.Add((new FST.Arc <T>()).copyFrom(arc));
                        if (arc.Last)
                        {
                            break;
                        }
                        else
                        {
                            fst.readNextRealArc(arc, reader);
                        }
                    }
                }
            }
        }
コード例 #2
0
                /// <summary>
                /// Load frame for sibling arc(node) on fst </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: Frame loadNextFrame(Frame top, Frame frame) throws java.io.IOException
                internal Frame loadNextFrame(Frame top, Frame frame)
                {
                    if (!canRewind(frame))
                    {
                        return(null);
                    }
                    while (!frame.fstArc.Last)
                    {
                        frame.fstArc   = fst.readNextRealArc(frame.fstArc, fstReader);
                        frame.fsaState = fsa.step(top.fsaState, frame.fstArc.label);
                        if (frame.fsaState != -1)
                        {
                            break;
                        }
                    }
                    //if (TEST) System.out.println(" loadNext frame="+frame);
                    if (frame.fsaState == -1)
                    {
                        return(null);
                    }
                    return(frame);
                }
コード例 #3
0
        // Use the builder to create:
        private NormalizeCharMap(FST <CharsRef> map)
        {
            this.map = map;
            if (map != null)
            {
                try
                {
                    // Pre-cache root arcs:
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.lucene.util.fst.FST.Arc<org.apache.lucene.util.CharsRef> scratchArc = new org.apache.lucene.util.fst.FST.Arc<>();
                    FST.Arc <CharsRef> scratchArc = new FST.Arc <CharsRef>();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.lucene.util.fst.FST.BytesReader fstReader = map.getBytesReader();
                    FST.BytesReader fstReader = map.BytesReader;
                    map.getFirstArc(scratchArc);
                    if (FST.targetHasArcs(scratchArc))
                    {
                        map.readFirstRealTargetArc(scratchArc.target, scratchArc, fstReader);
                        while (true)
                        {
                            Debug.Assert(scratchArc.label != FST.END_LABEL);
                            cachedRootArcs[Convert.ToChar((char)scratchArc.label)] = (new FST.Arc <CharsRef>()).copyFrom(scratchArc);
                            if (scratchArc.Last)
                            {
                                break;
                            }
                            map.readNextRealArc(scratchArc, fstReader);
                        }
                    }
                    //System.out.println("cached " + cachedRootArcs.size() + " root arcs");
                }
                catch (IOException ioe)
                {
                    // Bogus FST IOExceptions!!  (will never happen)
                    throw new Exception(ioe);
                }
            }
        }
コード例 #4
0
	  // Use the builder to create:
	  private NormalizeCharMap(FST<CharsRef> map)
	  {
		this.map = map;
		if (map != null)
		{
		  try
		  {
			// Pre-cache root arcs:
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.lucene.util.fst.FST.Arc<org.apache.lucene.util.CharsRef> scratchArc = new org.apache.lucene.util.fst.FST.Arc<>();
			FST.Arc<CharsRef> scratchArc = new FST.Arc<CharsRef>();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.lucene.util.fst.FST.BytesReader fstReader = map.getBytesReader();
			FST.BytesReader fstReader = map.BytesReader;
			map.getFirstArc(scratchArc);
			if (FST.targetHasArcs(scratchArc))
			{
			  map.readFirstRealTargetArc(scratchArc.target, scratchArc, fstReader);
			  while (true)
			  {
				Debug.Assert(scratchArc.label != FST.END_LABEL);
				cachedRootArcs[Convert.ToChar((char) scratchArc.label)] = (new FST.Arc<CharsRef>()).copyFrom(scratchArc);
				if (scratchArc.Last)
				{
				  break;
				}
				map.readNextRealArc(scratchArc, fstReader);
			  }
			}
			//System.out.println("cached " + cachedRootArcs.size() + " root arcs");
		  }
		  catch (IOException ioe)
		  {
			// Bogus FST IOExceptions!!  (will never happen)
			throw new Exception(ioe);
		  }
		}
	  }