Exemple #1
0
 public void Add(string name, Concept value)
 {
     concepts.Add(name, value);
 }
Exemple #2
0
        public void LoadInherited()
        {
            if (isFull)
            {
                return;
            }
            if (properties.Count == 0)
            {
                LoadLocal();
            }
            //////
            string file = Ontology.PathOf(name);


            //////
            StreamReader sr           = new StreamReader(file);
            string       line         = null;
            Concept      inherited    = null;
            Property     currProperty = null;
            Modifier     currMod      = Modifier.UNKNOWN;

            while ((line = sr.ReadLine()) != null)
            {
                line = line.Trim();
                if (line == "")
                {
                    continue;
                }
                if (line.StartsWith("Concept:"))
                {
                    continue;
                }
                else if (line.StartsWith("Inherited from:"))
                {
                    string inhname = line.Substring(15).Trim();
                    inherited = Ontology[inhname];
                }
                else if (inherited != null)
                {
                    string[]  tokens = line.Split('\t');
                    ArrayList parts  = new ArrayList();
                    foreach (string token in tokens)
                    {
                        if (token.Trim() != "")
                        {
                            parts.Add(token.Trim());
                        }
                    }
                    if (parts.Count == 3)
                    {
                        currProperty = new Property(this, (string)parts[0], inherited);
                        if (currProperty.Name == "DEFINITION" ||
                            //	////currProperty.Name=="ENGLISH1" ||
                            currProperty.Name == "NOTES" ||
                            currProperty.Name == "TIMESTAMP")
                        {
                            continue;
                        }
                        properties.Add(currProperty.Key, currProperty);
                        currMod = GetModifier((string)parts[1]);
                        string  strfiller = (string)parts[2];
                        Concept confiller = Ontology[strfiller];
                        if (confiller == null)
                        {
                            currProperty.Fillers.Add(
                                new Filler(currProperty, currMod, strfiller, null, true));
                        }
                        else
                        {
                            currProperty.Fillers.Add(
                                new Filler(currProperty, currMod, confiller, null, false));
                        }
                    }
                    else if (parts.Count == 2)
                    {
                        if (currProperty.Name == "DEFINITION" ||
                            //	////currProperty.Name=="ENGLISH1" ||
                            currProperty.Name == "NOTES" ||
                            currProperty.Name == "TIMESTAMP")
                        {
                            continue;
                        }
                        currMod = GetModifier((string)parts[0]);
                        string  strfiller = (string)parts[1];
                        Concept confiller = Ontology[strfiller];
                        if (confiller == null)
                        {
                            currProperty.Fillers.Add(
                                new Filler(currProperty, currMod, strfiller, null, true));
                        }
                        else
                        {
                            currProperty.Fillers.Add(
                                new Filler(currProperty, currMod, confiller, null, false));
                        }
                    }
                    else
                    {
                        if (currProperty.Name == "DEFINITION" ||
                            //	////currProperty.Name=="ENGLISH1" ||
                            currProperty.Name == "NOTES" ||
                            currProperty.Name == "TIMESTAMP")
                        {
                            continue;
                        }
                        string  strfiller = (string)parts[0];
                        Concept confiller = Ontology[strfiller];
                        if (confiller == null)
                        {
                            currProperty.Fillers.Add(
                                new Filler(currProperty, currMod, strfiller, null, true));
                        }
                        else
                        {
                            currProperty.Fillers.Add(
                                new Filler(currProperty, currMod, confiller, null, false));
                        }
                    }
                }
            }
            isFull = true;
            sr.Close();
        }