示例#1
0
        public static Morpho load(string fname)
        {
            global::System.IntPtr cPtr = morphodita_csharpPINVOKE.Morpho_load(fname);
            Morpho ret = (cPtr == global::System.IntPtr.Zero) ? null : new Morpho(cPtr, true);

            return(ret);
        }
示例#2
0
        public virtual Morpho getMorpho()
        {
            global::System.IntPtr cPtr = morphodita_csharpPINVOKE.Tagger_getMorpho(swigCPtr);
            Morpho ret = (cPtr == global::System.IntPtr.Zero) ? null : new Morpho(cPtr, false);

            return(ret);
        }
        public override XElement ToXElement()
        {
            XElement result = base.ToXElement();

            if ((Morpho != null) && Morpho.Any())
            {
                AddMorphoInfoAttribute(result);
            }
            return(result);
        }
示例#4
0
        public static TagsetConverter newStripLemmaCommentConverter(Morpho dictionary)
        {
            global::System.IntPtr cPtr = morphodita_csharpPINVOKE.TagsetConverter_newStripLemmaCommentConverter(Morpho.getCPtr(dictionary));
            TagsetConverter       ret  = (cPtr == global::System.IntPtr.Zero) ? null : new TagsetConverter(cPtr, true);

            if (morphodita_csharpPINVOKE.SWIGPendingException.Pending)
            {
                throw morphodita_csharpPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#5
0
    public static int Main(string[] args)
    {
        if (args.Length < 1)
        {
            Console.Error.WriteLine("Usage: RunMorphoCli dict_file");
            return(1);
        }

        Console.Error.Write("Loading dictionary: ");
        Morpho morpho = Morpho.load(args[0]);

        if (morpho == null)
        {
            Console.Error.WriteLine("Cannot load dictionary from file '{0}'", args[0]);
            return(1);
        }
        Console.Error.WriteLine("done");

        TaggedLemmas      lemmas      = new TaggedLemmas();
        TaggedLemmasForms lemmasForms = new TaggedLemmasForms();

        for (string line; (line = Console.In.ReadLine()) != null;)
        {
            string[] tokens = line.Split('\t');

            if (tokens.Length == 1) /* analyze */
            {
                int result = morpho.analyze(tokens[0], Morpho.GUESSER, lemmas);

                string guesser = result == Morpho.GUESSER ? "Guesser " : "";
                foreach (TaggedLemma lemma in lemmas)
                {
                    Console.WriteLine("{0}Lemma: {1} {2}", guesser, lemma.lemma, lemma.tag);
                }
            }
            else if (tokens.Length == 2)   /* generate */
            {
                int    result  = morpho.generate(tokens[0], tokens[1], Morpho.GUESSER, lemmasForms);
                String guesser = result == Morpho.GUESSER ? "Guesser " : "";
                foreach (TaggedLemmaForms lemmaForms in lemmasForms)
                {
                    Console.WriteLine("{0}Lemma: {1}", guesser, lemmaForms.lemma);
                    foreach (TaggedForm form in lemmaForms.forms)
                    {
                        Console.WriteLine("  {0} {1}", form.form, form.tag);
                    }
                }
            }
        }

        return(0);
    }
示例#6
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Morpho obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }