//Hacer Metodo recursivo que me devuelva la mayor profundidad por OWLClass

        /* private int getDepthClass(OWLClass _class, int level)
         * {
         *   java.util.Set subClass = _class.getSubClasses(ontology);
         *
         *   java.util.Iterator iterator = subClass.iterator();
         *
         *   level = level + 1;
         *
         *   int result = level;
         *
         *   while (iterator.hasNext())
         *   {
         *       int val = getDepthClass((OWLClass)iterator.next(), level);
         *
         *       if (val > result)
         *           result = val;
         *   }
         *
         *   return result;
         * }*/

        //Hacer Metodo recursivo que me devuelva la mayor profundidad por OWLClass
        private int getDepthClass(OWLClass _class)
        {
            int level = 1;

            java.util.Set supClass = _class.getSuperClasses(ontology);
            //java.util.Iterator iterator = supClass.iterator();

            //int result = level;
            while (supClass != null)
            {
                java.util.Iterator iterator = supClass.iterator();

                supClass = null;

                if (iterator.hasNext())
                {
                    object iteratorNext = iterator.next();
                    if (iteratorNext is OWLClass)
                    {
                        level    = level + 1;
                        supClass = (iteratorNext as OWLClass).getSuperClasses(ontology);
                    }
                }
            }

            return(level);
        }
Пример #2
0
        IEnumerator IEnumerable.GetEnumerator()
        {
            java.util.Iterator it = _collection.iterator();

            while (it.hasNext())
            {
                yield return(it.next());
            }
        }
Пример #3
0
        public IEnumerator <T> GetEnumerator()
        {
            java.util.Iterator it = _collection.iterator();

            while (it.hasNext())
            {
                yield return((T)it.next());
            }
        }
Пример #4
0
        public void CopyTo(Array array, int index)
        {
            java.util.Iterator it = _collection.iterator();
            int i = index;

            while (it.hasNext() && i < array.Length)
            {
                array.SetValue(it.next(), i++);
            }
        }
Пример #5
0
        public void CopyTo(T[] array, int arrayIndex)
        {
            java.util.Iterator it = _collection.iterator();
            int i = arrayIndex;

            while (it.hasNext() && i < array.Length)
            {
                array[i++] = (T)it.next();
            }
        }
Пример #6
0
    public static IEnumerable <T> ToIEnumerable <T>(this java.util.List list)
    {
        if (list != null)
        {
            java.util.Iterator itr = list.iterator();

            while (itr.hasNext())
            {
                yield return((T)itr.next());
            }
        }
    }
        private OWLClass getClass(java.util.Set _Class, string keyOwl)
        {
            java.util.Iterator iterator = _Class.iterator();
            OWLClass           _class;

            while (iterator.hasNext())
            {
                _class = (OWLClass)iterator.next();

                if (_class.getIRI().toString().Equals(keyOwl))
                {
                    return(_class);
                }
            }

            return(null);
        }
Пример #8
0
 private static void DumpAllJavaThreads()
 {
     Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
     java.util.Map traces = java.lang.Thread.getAllStackTraces();
     Console.WriteLine("Full thread dump IKVM.NET {0} ({1} bit):", JVM.SafeGetAssemblyVersion(Assembly.GetExecutingAssembly()), IntPtr.Size * 8);
     java.util.Iterator entries = traces.entrySet().iterator();
     while (entries.hasNext())
     {
         java.util.Map.Entry entry  = (java.util.Map.Entry)entries.next();
         java.lang.Thread    thread = (java.lang.Thread)entry.getKey();
         Console.WriteLine("\n\"{0}\"{1} prio={2} tid=0x{3:X8}", thread.getName(), thread.isDaemon() ? " daemon" : "", thread.getPriority(), thread.getId());
         Console.WriteLine("   java.lang.Thread.State: " + thread.getState());
         java.lang.StackTraceElement[] trace = (java.lang.StackTraceElement[])entry.getValue();
         for (int i = 0; i < trace.Length; i++)
         {
             Console.WriteLine("\tat {0}", trace[i]);
         }
     }
     Console.WriteLine();
 }
        /// <summary>
        /// proceso para cargar las clases, subclases y axiomas de la ontologia
        /// </summary>
        private void LoadOWLAPI()
        {
            //Inicializamos variables
            OntologyConcept ontologyConcept = null;

            int    weigth     = 1;
            string claseKey   = string.Empty;
            string claseValor = string.Empty;

            //OWLClass _class;
            //Se carga la ontologia
            string path = url;

            java.io.File file = new java.io.File(path);
            //Aseguramos una ontologia en el managet
            ontology = ontologyManager.loadOntologyFromOntologyDocument(file);

            //Creamos el datafactory para obtener los labels de las clases
            OWLDataFactory        df    = ontologyManager.getOWLDataFactory();
            OWLAnnotationProperty label = df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI());

            //Obtenemos las clases de la ontologia y las recorremos para obtener las anotaciones
            java.util.Set clases = ontology.getClassesInSignature();
            for (java.util.Iterator iteratorClases = clases.iterator(); iteratorClases.hasNext();)
            {
                OWLClass         clase       = (OWLClass)iteratorClases.next();
                List <Anotacion> Anotaciones = new List <Anotacion>();
                java.util.Set    lit         = clase.getAnnotations(ontology, label);
                //Se recorren las anotaciones tipo Label
                for (java.util.Iterator iteratorAnno = lit.iterator(); iteratorAnno.hasNext();)
                {
                    OWLAnnotation anno           = (OWLAnnotation)iteratorAnno.next();
                    OWLLiteral    val            = (OWLLiteral)anno.getValue();
                    string        valorAnotacion = string.Empty;
                    if (val.hasLang("es"))
                    {
                        //Se debe hacer un tratamiento a la cadena por los acentos
                        valorAnotacion = ToAscii(val.getLiteral()).Trim();
                    }
                    else
                    {
                        valorAnotacion = val.getLiteral().Trim();
                    }
                    //Agregar la anotacion a la lista
                    Anotacion annotemp = new Anotacion(anno.getSignature().ToString(), valorAnotacion, val.getLang());
                    Anotaciones.Add(annotemp);
                    //Añadimos la anotacion a la lista de valores a consultar verificando que no este repetido
                    if (!valores.Contains(valorAnotacion) && !string.IsNullOrEmpty(valorAnotacion))
                    {
                        valores.Add(valorAnotacion);
                    }

                    //Reportar la anotacion encontrada
                    Trace.WriteLine(clase.getSignature().ToString() + " -> " + valorAnotacion);
                    //Almacenamos todas anotaciones en un string para el valor de la clase
                    claseValor = claseValor + " " + valorAnotacion;

                    //En caso de tener individuos se almacena en la lista de valores para su búsqueda
                    Trace.WriteLine("Obteniendo conceptos de los individuos");
                    string        individuoKey = string.Empty;
                    java.util.Set individuos   = clase.getIndividuals(ontology);
                    for (java.util.Iterator iteratorIndividuos = individuos.iterator(); iteratorIndividuos.hasNext();)
                    {
                        OWLIndividual individuo = (OWLIndividual)iteratorIndividuos.next();
                        java.util.Set litind    = individuo.asOWLNamedIndividual().getAnnotations(ontology, df.getRDFSLabel());

                        //Se recorre las anotaciones tipo Label individuo
                        for (java.util.Iterator iteratorAnnoind = litind.iterator(); iteratorAnnoind.hasNext();)
                        {
                            OWLAnnotation annoind           = (OWLAnnotation)iteratorAnnoind.next();
                            OWLLiteral    valind            = (OWLLiteral)annoind.getValue();
                            string        valorAnotacionind = string.Empty;
                            if (valind.hasLang("es"))
                            {
                                //Se debe hacer un tratamiento a la cadena por los acentos
                                valorAnotacionind = ToAscii(valind.getLiteral()).Trim();
                            }
                            else
                            {
                                valorAnotacionind = valind.getLiteral().Trim();
                            }
                            //Agregar la anotacion a la lista
                            Anotacion annotempind = new Anotacion(annoind.getSignature().ToString(), valorAnotacionind, valind.getLang());
                            Anotaciones.Add(annotempind);
                            //Añadimos la anotacion a la lista de valores a consultar verificando que no este repetido
                            if (!valores.Contains(valorAnotacionind) && !string.IsNullOrEmpty(valorAnotacionind))
                            {
                                valores.Add(valorAnotacionind);
                            }
                            //Reportar la anotacion encontrada
                            Trace.WriteLine(clase.getSignature().ToString() + ":" + individuo.getSignature().ToString() + " -> " + valorAnotacionind);
                            //Almacenamos todas anotaciones en un string para el valor de la clase
                            claseValor = claseValor + " " + valorAnotacionind;
                        }
                    }

                    //Agregar el concepto a la lista
                    claseKey                    = clase.getSignature().ToString();
                    ontologyConcept             = new OntologyConcept(claseKey, claseValor, weigth, clase, clase.getSuperClasses(ontology), clase.getSubClasses(ontology));
                    ontologyConcept.Anotaciones = Anotaciones;
                    //Reinicializamos el valor para la nueva clase
                    claseValor = "";
                    //Verificar que se obtengan conceptos diferentes. Las claseKey se repiten siempre que aporten anotaciones diferentes
                    if (!this.concepts.ContainsKey(claseKey) && !this.concepts.ContainsValue(ontologyConcept) && !valores.Contains(ontologyConcept.ConceptValue) && !string.IsNullOrEmpty(ontologyConcept.ConceptValue))
                    {
                        this.concepts.Add(claseKey, ontologyConcept);
                    }
                }
            }
        }
Пример #10
0
    // note Awake, Start, Update, etc. made public virtual so can override in extensions

    public virtual void Awake()      // do non-primitive initializations for MonoBehavior's here
    {
        taskHandle    = new EventWaitHandle(false, EventResetMode.ManualReset);
        menuHandle    = new EventWaitHandle(false, EventResetMode.ManualReset);
        sensingHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
        w32Classes    = new W32ClassBatchUnregisterer();
        program       = new Program();
        player        = new Player("Player");
        npc           = new NPC(this, "NPC");
        interaction   = new Interaction(npc, player);
        interaction.setOk(false);          // suppress default Ok's
        // support calling Debug.Log from scripts
        getDisco().eval(
            "Debug = { Log : function (obj) { TextWindow.Program.Log(obj); }}", "DiscoUnity");

        discoThread = new Thread((ThreadStart) delegate {
            try {
                while (discoRunning)
                {
                    // start console if requested
                    if (Console && !formStarted)
                    {
                        formStarted = true;
                        //second parameter is called when the console Form is loaded
                        program.StartWindow(formThread, (sender, evt) => {
                            if (onWindows)
                            {
                                w32Classes.AddWindowClassesRecursively((Control)sender);
                            }
                            formLoaded = true;
                            form.Writer.WriteLine("    DiscoUnity " + VERSION);
                            console = new edu.wpi.disco.Console(null, interaction);
                            interaction.setConsole(console);
                            console.init(getDisco());
                            console.setReader(new Program.ConsoleReader(form));
                            form.shell.shellTextBox.GotFocus += (s, e) => {                             // improve window readability
                                if (!firstPrompt && form.shell.shellTextBox.IsCaretJustBeforePrompt())
                                {
                                    firstPrompt = false;
                                    form.Writer.Write(console.getPrompt());
                                }
                            };
                            interaction.start(true);                             // start console thread
                        });
                    }
                    // do Sensing on Unity thread
                    sensing = true;
                    sensingHandle.WaitOne();
                    sensingHandle.Reset();
                    UpdateDisco(getDisco());               // manage toplevel goals
                    getDisco().tick();                     // update conditions
                    // process player menu choice, if any
                    if (chosen != null)
                    {
                        getDisco().doneUtterance(chosen.task, formatted);
                        done(true, chosen.task, chosen.contributes);
                        chosen    = null;
                        formatted = null;
                    }
                    // process NPC response, if any
                    Agenda.Plugin.Item item = npc.respondIf(interaction, true);
                    if (item != null && !item.task.Equals(npc.getLastUtterance()))
                    {
                        npc.done(interaction, item);
                    }
                    if (Menu)
                    {
                        // update player menu options (including empty)
                        java.util.List newItems = player.generate(interaction);
                        if (!newItems.equals(items))
                        {
                            String [] choices = null;
                            if (!newItems.isEmpty())
                            {
                                choices = new String[newItems.size()];
                                int i   = 0;
                                java.util.Iterator l = newItems.iterator();
                                while (l.hasNext())
                                {
                                    choices[i++] = translate(((Agenda.Plugin.Item)l.next()).task);
                                }
                            }
                            lastMenu = null;                             // block choosing from old menu
                            menu     = choices;
                            items    = newItems;
                            newMenu  = true;
                            menuHandle.WaitOne();                             // execute on Unity thread
                            menuHandle.Reset();
                            lastMenu = choices;
                        }
                    }
                    // sleep for a while
                    Thread.Sleep(Sleep);
                }
            } catch (Exception e) {
                Debug.Log("Disco thread terminating: " + e);
                if (Tracing)
                {
                    Debug.Log(e.ToString());
                }
            }
        });
        discoThread.IsBackground = true;
        discoThread.Priority     = Priority;

        formThread = new Thread((ThreadStart) delegate {
            try {
                /*
                 *      while (true) { // for testing
                 *              program.WriteLine("Echo: " + program.ReadLine());
                 *      }
                 */
                form = program.GetForm();
                java.lang.System.setOut(new java.io.PrintStream(new Program.ConsoleOut(form.Writer), true));
                java.lang.System.setErr(java.lang.System.@out);
            } catch (Exception e) { Debug.Log("Console form thread terminating: " + e); }
        });
        formThread.IsBackground = true;
    }
Пример #11
0
 public RDFList createList(java.util.Iterator i)
 {
     throw new NotImplementedException();
 }