CountCoordStates() public method

public CountCoordStates ( int CoordID ) : int
CoordID int
return int
    public string GetContextPoint(SolarixGrammarEngineNET.GrammarEngine2 gren)
    {
        System.Text.StringBuilder b = new StringBuilder();

        if (!string.IsNullOrEmpty(lexem))
        {
            b.AppendFormat("\"{0}\"", lexem);
        }
        else
        {
            if (id_class != -1)
            {
                b.AppendFormat("{0}:*", gren.GetClassName(id_class));
            }
            else
            {
                int pos = gren.GetEntryClass(id_entry);
                b.AppendFormat("{0}:{1}", gren.GetClassName(pos), gren.GetEntryName(id_entry));
            }

            b.Append("{");

            // выводим список координатных пар
            foreach (SolarixGrammarEngineNET.CoordPair p in pairs)
            {
                string CoordName = gren.GetCoordName(p.CoordID);
                if (gren.CountCoordStates(p.CoordID) == 0)
                {
                    if (p.StateID == 1)
                    {
                        b.AppendFormat(" {0}", CoordName);
                    }
                    else
                    {
                        b.AppendFormat(" ~{0}", CoordName);
                    }
                }
                else
                {
                    string StateName = gren.GetCoordStateName(p.CoordID, p.StateID);
                    b.AppendFormat(" {0}:{1}", CoordName, StateName);
                }
            }

            b.Append(" }");
        }

        return(b.ToString());
    }
    public int MatchTags(SolarixGrammarEngineNET.SyntaxTreeNode proj, int iproj, SolarixGrammarEngineNET.GrammarEngine2 gren)
    {
        foreach (TagMatcher m in matchers)
        {
            if (m.Match(proj, iproj, gren))
            {
                // ---~~~~~ DEBUG ~~~---
#if DEBUG
                string matcher = m.ToString();
                string form    = "";

                int npair = SolarixGrammarEngineNET.GrammarEngine.sol_GetNodeVerPairsCount(proj.hNode, iproj);
                for (int j = 0; j < npair; ++j)
                {
                    int id_coord = SolarixGrammarEngineNET.GrammarEngine.sol_GetNodeVerPairCoord(proj.hNode, iproj, j);
                    int id_state = SolarixGrammarEngineNET.GrammarEngine.sol_GetNodeVerPairState(proj.hNode, iproj, j);

                    string coord_name = gren.GetCoordName(id_coord);

                    string state_name = null;
                    if (gren.CountCoordStates(id_coord) == 0)
                    {
                        state_name = id_state.ToString();
                    }
                    else
                    {
                        state_name = gren.GetCoordStateName(id_coord, id_state);
                    }

                    form += string.Format(" {0}:{1}", coord_name, state_name);
                }
#endif
                // ---~~~~~ ..... ~~~---

                return(m.GetId());
            }
        }

        return(-1);
    }
    public TagMatcher(string line, SolarixGrammarEngineNET.GrammarEngine2 gren)
    {
        source = line.Trim();
        id     = ++seq_id;

        string[] toks = source.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
        foreach (string tok in toks)
        {
            if (tok[0] == '\'' && tok[tok.Length - 1] == '\'')
            {
                lexeme = tok.Substring(1, tok.Length - 2);
            }
            else if (tok[0] == '"' && tok[tok.Length - 1] == '"')
            {
                lexeme = tok.Substring(1, tok.Length - 2);
            }
            else
            {
                if (tok.IndexOf(':') == -1)
                {
                    string pos_name = tok.Trim();
                    int    id_class = gren.FindPartOfSpeech(pos_name);
                    if (id_class != -1)
                    {
                        if (pos == null)
                        {
                            pos       = new List <int>();
                            pos_names = new List <string>();
                        }

                        pos.Add(id_class);
                        pos_names.Add(pos_name);
                    }
                    else
                    {
                        int state = 1;

                        string t = tok.Trim();

                        if (t.StartsWith("~"))
                        {
                            t     = t.Substring(1);
                            state = 0;
                        }

                        int id_coord = gren.FindCoord(t);
                        if (id_coord == -1)
                        {
                            throw new ApplicationException(string.Format("Can not find coord [{0}]", tok));
                        }

                        if (gren.CountCoordStates(id_coord) != 0)
                        {
                            throw new ApplicationException(string.Format("[{0}] is not bistable", tok));
                        }

                        if (pairs == null)
                        {
                            pairs = new List <SolarixGrammarEngineNET.CoordPair>();
                        }

                        SolarixGrammarEngineNET.CoordPair p;
                        p.CoordID = id_coord;
                        p.StateID = state;
                        pairs.Add(p);
                    }
                }
                else
                {
                    string[] t3         = tok.Split(':');
                    string   coord_name = t3[0].Trim();
                    string   state_name = t3[1].Trim();

                    int id_class = gren.FindPartOfSpeech(coord_name);
                    if (id_class != -1)
                    {
                        id_lemma    = new List <int>();
                        entry_names = new List <string>();
                        pos_names   = new List <string>();
                        pos_names.Add(coord_name);

                        int    ip    = state_name.IndexOf('{');
                        string ename = state_name.Substring(0, ip);
                        int    ekey  = gren.FindEntry(ename, id_class);

                        if (ekey == -1)
                        {
                            throw new ApplicationException(string.Format("Can not find word entry {0}:{1}", coord_name, ename));
                        }

                        id_lemma.Add(ekey);
                        entry_names.Add(ename);

                        if (entry_pos == null)
                        {
                            entry_pos = new List <int>();
                        }

                        if (!entry_pos.Contains(id_class))
                        {
                            entry_pos.Add(id_class);
                        }
                    }
                    else
                    {
                        int id_coord = gren.FindCoord(coord_name);
                        if (id_coord == -1)
                        {
                            throw new ApplicationException(string.Format("Can not find coord [{0}]", coord_name));
                        }

                        int id_state = -1;
                        if (gren.CountCoordStates(id_coord) == 0)
                        {
                            id_state = int.Parse(state_name);
                            if (id_state < 0 || id_state > 1)
                            {
                                throw new ApplicationException(string.Format("Invalid state name {0} for bistable coord {1}", state_name, coord_name));
                            }
                        }
                        else
                        {
                            id_state = gren.FindState(id_coord, state_name);
                            if (id_state == -1)
                            {
                                throw new ApplicationException(string.Format("Can not find state [{0}:{1}]", coord_name, state_name));
                            }
                        }

                        if (pairs == null)
                        {
                            pairs = new List <SolarixGrammarEngineNET.CoordPair>();
                        }

                        SolarixGrammarEngineNET.CoordPair p;
                        p.CoordID = id_coord;
                        p.StateID = id_state;
                        pairs.Add(p);
                    }
                }
            }
        }
    }