Exemple #1
0
        /// <summary>
        /// This is a custom interner that simultaneously creates and interns
        /// an IntDependency.
        /// </summary>
        /// <returns>An interned IntDependency</returns>
        protected internal virtual IntDependency Intern(IntTaggedWord headTW, IntTaggedWord argTW, bool leftHeaded, short dist)
        {
            IDictionary <IntDependency, IntDependency> map = expandDependencyMap;
            IntDependency internTempDependency             = new IntDependency(itwInterner.Intern(headTW), itwInterner.Intern(argTW), leftHeaded, dist);
            IntDependency returnDependency = internTempDependency;

            if (map != null)
            {
                returnDependency = map[internTempDependency];
                if (returnDependency == null)
                {
                    map[internTempDependency] = internTempDependency;
                    returnDependency          = internTempDependency;
                }
            }
            return(returnDependency);
        }
        //goal = (Edge)interner.intern(goal);
        protected internal virtual void Initialize <_T0>(IList <_T0> words)
            where _T0 : IHasWord
        {
            length   = words.Count;
            interner = new Interner();
            agenda   = new ArrayHeap <Item>(ScoredComparator.DescendingComparator);
            chart    = new HookChart();
            SetGoal(length);
            IList <Item> initialItems = MakeInitialItems(words);

            //    scoreDependencies();
            foreach (Item item in initialItems)
            {
                item = (Item)interner.Intern(item);
                //if (VERBOSE) log.info("Initial: "+item);
                DiscoverItem(item);
            }
        }
 // used in many methods to decrease new's
 // used to decrease new's
 public virtual void RegisterEdgeIndexes(Edge edge)
 {
     tempIndex.state = edge.state;
     tempIndex.head  = edge.head;
     tempIndex.tag   = edge.tag;
     tempIndex.loc   = edge.start;
     HookChart.ChartIndex index = (HookChart.ChartIndex)interner.Intern(tempIndex);
     builtLIndexes.Add(index);
     if (index == tempIndex)
     {
         tempIndex       = new HookChart.ChartIndex();
         tempIndex.state = edge.state;
         tempIndex.head  = edge.head;
         tempIndex.tag   = edge.tag;
     }
     //System.out.println("Edge registered: "+edge);
     tempIndex.loc = edge.end;
     index         = (HookChart.ChartIndex)interner.Intern(tempIndex);
     if (index == tempIndex)
     {
         tempIndex = new HookChart.ChartIndex();
     }
     builtRIndexes.Add(index);
 }
 public virtual ChineseCharacterBasedLexicon.Symbol Intern()
 {
     return(interner.Intern(this));
 }