Ejemplo n.º 1
0
 public virtual bool IsEmpty()
 {
     lock (this)
     {
         return(sequences.IsEmpty());
     }
 }
Ejemplo n.º 2
0
 public bool IsEmpty()
 {
     lock (locker)
     {
         return(sequences.IsEmpty());
     }
 }
Ejemplo n.º 3
0
        public bool IsEmpty()
        {
            _lock.EnterReadLock();
            var retVal = sequences.IsEmpty();

            _lock.ExitReadLock();
            return(retVal);
        }
        private void ExtractGoldMentions(ICoreMap s, IList <IList <Mention> > allGoldMentions, ACEMentionExtractor.EntityComparator comparator)
        {
            IList <Mention> goldMentions = new List <Mention>();

            allGoldMentions.Add(goldMentions);
            IList <EntityMention>   goldMentionList         = s.Get(typeof(MachineReadingAnnotations.EntityMentionsAnnotation));
            IList <CoreLabel>       words                   = s.Get(typeof(CoreAnnotations.TokensAnnotation));
            TreeSet <EntityMention> treeForSortGoldMentions = new TreeSet <EntityMention>(comparator);

            if (goldMentionList != null)
            {
                Sharpen.Collections.AddAll(treeForSortGoldMentions, goldMentionList);
            }
            if (!treeForSortGoldMentions.IsEmpty())
            {
                foreach (EntityMention e in treeForSortGoldMentions)
                {
                    Mention men = new Mention();
                    men.dependency = s.Get(typeof(SemanticGraphCoreAnnotations.CollapsedDependenciesAnnotation));
                    if (men.dependency == null)
                    {
                        men.dependency = s.Get(typeof(SemanticGraphCoreAnnotations.EnhancedDependenciesAnnotation));
                    }
                    men.startIndex = e.GetExtentTokenStart();
                    men.endIndex   = e.GetExtentTokenEnd();
                    string[] parseID = e.GetObjectId().Split("-");
                    men.mentionID = System.Convert.ToInt32(parseID[parseID.Length - 1]);
                    string[] parseCorefID = e.GetCorefID().Split("-E");
                    men.goldCorefClusterID = System.Convert.ToInt32(parseCorefID[parseCorefID.Length - 1]);
                    men.originalRef        = -1;
                    for (int j = allGoldMentions.Count - 1; j >= 0; j--)
                    {
                        IList <Mention> l = allGoldMentions[j];
                        for (int k = l.Count - 1; k >= 0; k--)
                        {
                            Mention m = l[k];
                            if (men.goldCorefClusterID == m.goldCorefClusterID)
                            {
                                men.originalRef = m.mentionID;
                            }
                        }
                    }
                    goldMentions.Add(men);
                    if (men.mentionID > maxID)
                    {
                        maxID = men.mentionID;
                    }
                    // set ner type
                    for (int j_1 = e.GetExtentTokenStart(); j_1 < e.GetExtentTokenEnd(); j_1++)
                    {
                        CoreLabel word = words[j_1];
                        string    ner  = e.GetType() + "-" + e.GetSubType();
                    }
                }
            }
        }
 public virtual void Display(bool verbose, PrintWriter pw)
 {
     if (unkWords.IsEmpty())
     {
         pw.Printf("UnknownWordPrinter: all words known by DVModel%n");
     }
     else
     {
         pw.Printf("UnknownWordPrinter: the following words are unknown%n");
         foreach (string word in unkWords)
         {
             pw.Printf("  %s%n", word);
         }
     }
 }
Ejemplo n.º 6
0
        private PlotLane NextFreeLane()
        {
            PlotLane p = CreateLane();

            if (freePositions.IsEmpty())
            {
                p.position = positionsAllocated++;
            }
            else
            {
                int min = freePositions.First();
                p.position = min;
                freePositions.Remove(min);
            }
            return(p);
        }
Ejemplo n.º 7
0
            /// <exception cref="SSLException"/>
            public virtual void Check(string[] hosts, string[] cns, string[] subjectAlts, bool
                                      ie6, bool strictWithSubDomains)
            {
                // Build up lists of allowed hosts For logging/debugging purposes.
                StringBuilder buf = new StringBuilder(32);

                buf.Append('<');
                for (int i = 0; i < hosts.Length; i++)
                {
                    string h = hosts[i];
                    h = h != null?StringUtils.ToLowerCase(h.Trim()) : string.Empty;

                    hosts[i] = h;
                    if (i > 0)
                    {
                        buf.Append('/');
                    }
                    buf.Append(h);
                }
                buf.Append('>');
                string hostnames = buf.ToString();
                // Build the list of names we're going to check.  Our DEFAULT and
                // STRICT implementations of the HostnameVerifier only use the
                // first CN provided.  All other CNs are ignored.
                // (Firefox, wget, curl, Sun Java 1.4, 5, 6 all work this way).
                ICollection <string> names = new TreeSet <string>();

                if (cns != null && cns.Length > 0 && cns[0] != null)
                {
                    names.AddItem(cns[0]);
                    if (ie6)
                    {
                        for (int i_1 = 1; i_1 < cns.Length; i_1++)
                        {
                            names.AddItem(cns[i_1]);
                        }
                    }
                }
                if (subjectAlts != null)
                {
                    for (int i_1 = 0; i_1 < subjectAlts.Length; i_1++)
                    {
                        if (subjectAlts[i_1] != null)
                        {
                            names.AddItem(subjectAlts[i_1]);
                        }
                    }
                }
                if (names.IsEmpty())
                {
                    string msg = "Certificate for " + hosts[0] + " doesn't contain CN or DNS subjectAlt";
                    throw new SSLException(msg);
                }
                // StringBuffer for building the error message.
                buf = new StringBuilder();
                bool match = false;

                for (IEnumerator <string> it = names.GetEnumerator(); it.HasNext();)
                {
                    // Don't trim the CN, though!
                    string cn = StringUtils.ToLowerCase(it.Next());
                    // Store CN in StringBuffer in case we need to report an error.
                    buf.Append(" <");
                    buf.Append(cn);
                    buf.Append('>');
                    if (it.HasNext())
                    {
                        buf.Append(" OR");
                    }
                    // The CN better have at least two dots if it wants wildcard
                    // action.  It also can't be [*.co.uk] or [*.co.jp] or
                    // [*.org.uk], etc...
                    bool doWildcard = cn.StartsWith("*.") && cn.LastIndexOf('.') >= 0 && !IsIP4Address
                                          (cn) && AcceptableCountryWildcard(cn);
                    for (int i_1 = 0; i_1 < hosts.Length; i_1++)
                    {
                        string hostName = StringUtils.ToLowerCase(hosts[i_1].Trim());
                        if (doWildcard)
                        {
                            match = hostName.EndsWith(Runtime.Substring(cn, 1));
                            if (match && strictWithSubDomains)
                            {
                                // If we're in strict mode, then [*.foo.com] is not
                                // allowed to match [a.b.foo.com]
                                match = CountDots(hostName) == CountDots(cn);
                            }
                        }
                        else
                        {
                            match = hostName.Equals(cn);
                        }
                        if (match)
                        {
                            goto out_break;
                        }
                    }
                    out_continue :;
                }
                out_break :;
                if (!match)
                {
                    throw new SSLException("hostname in certificate didn't match: " + hostnames + " !="
                                           + buf);
                }
            }