Esempio n. 1
0
        public ArrayList <KeyDat <double, LanguageProfile> > DetectLanguageAll(NGramProfile p, int cutOff)
        {
            Utils.ThrowException(mLanguageProfiles.Count == 0 ? new InvalidOperationException() : null);
            Utils.ThrowException(p == null ? new ArgumentNullException("p") : null);
            Utils.ThrowException((!p.IsRanked) ? new ArgumentValueException("p") : null);
            Utils.ThrowException(cutOff < 1 ? new ArgumentOutOfRangeException("cutOff") : null);
            ArrayList <KeyDat <double, LanguageProfile> > result = new ArrayList <KeyDat <double, LanguageProfile> >();

            foreach (LanguageProfile l in mLanguageProfiles)
            {
                double dist = p.CalcOutOfPlace(l, cutOff);
                result.Add(new KeyDat <double, LanguageProfile>(dist, l));
            }
            return(result);
        }
Esempio n. 2
0
        public LanguageProfile DetectLanguage(NGramProfile p, int cutOff)
        {
            Utils.ThrowException(mLanguageProfiles.Count == 0 ? new InvalidOperationException() : null);
            Utils.ThrowException(p == null ? new ArgumentNullException("p") : null);
            Utils.ThrowException((!p.IsRanked) ? new ArgumentValueException("p") : null);
            Utils.ThrowException(cutOff < 1 ? new ArgumentOutOfRangeException("cutOff") : null);
            LanguageProfile matchingLang = null;
            double          minDist      = Double.MaxValue;

            foreach (LanguageProfile l in mLanguageProfiles)
            {
                double dist = p.CalcOutOfPlace(l, cutOff);
                if (dist < minDist)
                {
                    matchingLang = l;
                    minDist      = dist;
                }
            }
            return(matchingLang);
        }
Esempio n. 3
0
 public ArrayList<KeyDat<double, LanguageProfile>> DetectLanguageAll(NGramProfile p, int cutOff)
 {
     Utils.ThrowException(mLanguageProfiles.Count == 0 ? new InvalidOperationException() : null);
     Utils.ThrowException(p == null ? new ArgumentNullException("p") : null);
     Utils.ThrowException((!p.IsRanked) ? new ArgumentValueException("p") : null);
     Utils.ThrowException(cutOff < 1 ? new ArgumentOutOfRangeException("cutOff") : null);
     ArrayList<KeyDat<double, LanguageProfile>> result = new ArrayList<KeyDat<double, LanguageProfile>>();
     foreach (LanguageProfile l in mLanguageProfiles)
     {
         double dist = p.CalcOutOfPlace(l, cutOff);
         result.Add(new KeyDat<double, LanguageProfile>(dist, l));
     }
     return result;
 }
Esempio n. 4
0
 public LanguageProfile DetectLanguage(NGramProfile p, int cutOff)
 {
     Utils.ThrowException(mLanguageProfiles.Count == 0 ? new InvalidOperationException() : null);
     Utils.ThrowException(p == null ? new ArgumentNullException("p") : null);
     Utils.ThrowException((!p.IsRanked) ? new ArgumentValueException("p") : null);
     Utils.ThrowException(cutOff < 1 ? new ArgumentOutOfRangeException("cutOff") : null);
     LanguageProfile matchingLang = null;
     double minDist = Double.MaxValue;
     foreach (LanguageProfile l in mLanguageProfiles)
     {
         double dist = p.CalcOutOfPlace(l, cutOff);
         if (dist < minDist)
         {
             matchingLang = l;
             minDist = dist;
         }
     }
     return matchingLang;
 }