bonjour.

J'ai entrepris de migrer du code de Java vers VS; J'ai commencé avec le code std, et devant des difficulté d'allocation J'ai entrepris de passer ce code en managé.

J'avance doucement dans ma migration vers du code managé

Sur la première méthode j'ai des points durs que je vous soumet.

cette méthode s'appuie sur des fichiers que je vous détaille ci-dessous:

d'abord les déclarations de stUnivers et de ElementSemanticM
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 
stUnivers
 
public ref struct  stUnivers
{
      int idParagraph;
      System::String^ wsName;
};
 
ElementSemanticM
 
	ref class ElementSemanticM
	{
	public:
             stUnivers Univers;
             System::String^ wsText;
             System::String^ wsIdentifier;
             int siIdOccurence;
             int nuIdTypeElement;
             int siNbChunk;
             int nuIdParagraph;
             int nuIdChunk;
             int nuIdElemn;
             int nuIdChunkType;
             int siNbWord;
	     int ullLemmaID;
             int nuIdDrivingPos;
	     int nuIdWord;
             System::String^ wsWord;
	     System::String^ wsLemma;
	     System::String^ wsPronunciation;
             int iValWord;
	     int cExcluded;
             int iIdDoc;
             int iPOS;
	     int iGender;
	     int iPers;
	     int iNbr;
	     int iLength;
	     int iWordOccurence;
	     int indice;
	     System::String^ Sujet;
	     System::String^ ListParagraph;
             List<ElementLinksM^>^ pLink;
	};
la deuxième erreur nécessite l'énuméré enChunkType
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 
	public enum class enChunkType
	{
		CHUNKTYPE_NONE,                                       // 0 Undefined chunk type
		CHUNKTYPE_VERB,                                       // 1
		CHUNKTYPE_NOUN,                                       // 2
		CHUNKTYPE_FUNCT,                                      // 3
		CHUNKTYPE_DECLENCHEUR,                                // 4
		CHUNKTYPE_QUALIFICATEUR,                              // 5
		CHUNKTYPE_PASSIVE,                                    // 6
		CHUNKTYPE_OTHER,                                      // 7
		NUMBER_OF_CHUNKTYPE                                   // 8
	};
 
et la suivante référence la structure enPOS
 
	public enum class enPOS
	{
		POS_NONE,								//	Undefined                   0
		POS_PREP,								//	Preposition                 1
		POS_ART,								//	Article                     2
		POS_ADJ,								//	Adjective                   3
		POS_NOUN,								//	Noun                        4
		POS_NB,								//	Number                      5
		POS_MARK,								//	Mark                        6
		POS_SENT,								//	Sentence point              7
		POS_STOPMARK,							//	Mark of end of sentence     8
		POS_COMMA,							//	virgule                     9
		POS_CONJ,								//	Conjunction                 10
		POS_PRONOUN,							//	Pronoun                     11
		POS_VERB,								//	Verb                        12
		POS_AUX,								//	Auxiliary                   13
		POS_ADV,								//	Adverb                      14
		POS_PAST_PARTICIPLE,	                //	Participe passé             15
		POS_PRESENT_PARTICIPLE,               //  Participe présent           16
		POS_BLANK,							//	Blank                       17
		POS_ABREV,                            //  Abreviations                18
		POS_NAMED_ENTITY,                     //  Noms propre et Entitée nomée19
		POS_DECLENCHEUR,                      //  mots servant à repèrer les préconditions 20
		POS_DECLENCHEUR_MOT,                  //  noms déclanchant            21
		POS_PIVOT,                            //  mot continuant un syntagme  22
		POS_SEMI_COLUMN,                      //  deux points                 23
		POS_PASSIVE,                          //  mot introduisnat une forme passive 24
		POS_COLOR,                            //  couleurs normalisées        25
		POS_OTHER,							//	Other POS                   26
		NUMBER_OF_POS,
	};
les erreur suivantes nécessitent les types pSegment et pLinguisicSegment
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
	public ref class CLinguisticSegmentM
	{
	public:
		List<CAnalysedWordM^>  ListWord;                 //  Liste de pointeurs sur les Mots qui constituent le Segment
		List<CVirtualEquationM^> ListEquation;           //  Liste de pointeurs sur les Equations
		List<CElementSemantiqueM^> ListProposition;      //  Liste de pointeurs sur les Ngrams qui sont dans le Segment
		List<CAnalysedChunkM^> ListChunk;                //  Liste de pointeurs sur les Chunks qui sont dans le Segment
		List<ElementSemanticM^> ListPredicat;
		List<ElementSemanticM^> ListPrecondition;
		List<ElementSemanticM^> ListQualificatif;
		List<ElementSemanticM^> ListUnivers;
		List<QualificateurNormalizedM^> listQualificateurNormalized;
		List<PropositionNormalizedM^> ListPredicatNormalized;
		List<PropositionNormalizedM^> ListPreconditionNormalized;
		List<CObjetM^> listObjectsNormalized;
 
		CLinguisticSegmentM()
		  {;}
		~CLinguisticSegmentM()
		  {;}
	};
 
	public ref class CAnalysedSegmentM
	{
	public:
	#ifdef CXELDA_MANAGER_H
		unsigned __int64	        ullSegmentID;             //  Identifiant du Segment dans la base de données
	#else
		unsigned long long          ullSegmentID;             //  Identifiant du Segment dans la base de données
	#endif
		CLinguisticSegmentM^        pLinguisticSegment;       //  Segment decomposition
		CLayoutM^					pSegmentLayout;           //  Segment layout at the segment level only
		short                       shSegmentCharLength;      //  Number of character in sentence
		short                       shSegmentWordLength;      //  Number of words in sentence
		enLanguage                  Language;                 //  Langue du segment
		unsigned long               ulDocPosition;            //  Segment position into the Document
 
		CAnalysedSegmentM();
		~CAnalysedSegmentM();
	};
la méthode trie les éléments d'une liste en entrée et les répartit dans 4 listes
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
 
//
/*----------------------------------------------------------------------------*/
    /*Name          GetElementSemantic                                            */
    /*Role          la méthode trie les éléments d'une liste en entrée            */
    /*              et les répartit dans 4 listes                                 */
    /*Interface                                                                   */
    /*In            pListeElements                                                */
    /*In/Out        None                                                          */
    /*Result        pSegment                                                      */
    /*----------------------------------------------------------------------------*/
    //
    CAnalysedSegmentM^ BuildComponents::GetElementsSemantics( List<ElementSemanticM^>^ plisteElement)
    {
        List<ElementSemanticM^>^ plisteQualificatif;
        List<ElementSemanticM^>^ plistePredicat;
        List<ElementSemanticM^>^ plistePrecondition;
        List<ElementSemanticM^>^ plisteUnivers;
 
        ElementSemanticM^ pEnreg;
        ElementSemanticM^ pNewElemnt;
        ElementSemanticM^ pOldElemnt;
        CAnalysedSegmentM^ pSegment;
 
        int i = 0;
        int j = 0;
        int k = 0;
        int l = 0;
        int m = 0;
        int n = 0;
        int x = 0;
        int y = 0;
        int TempId = 0;
        int OldId = 0;
        int len = 0;
        int nElement = 0;
        int iPos = 0;
        int iVal;
        int iOccur;
        System::String^ wsText = L"";
        System::String^ wsWord = L"";
 
        bool bIsCompleted = false;
        bool bIsQualificateur = false;
        bool bIsPredicat = false;
 
        try
        {
            iSize = 0;
            pOldElemnt = gcnew ElementSemanticM();
            pSegment = gcnew CAnalysedSegmentM();
            pSegment->pLinguisticSegment = gcnew CLinguisticSegmentM();
            for each( pEnreg in plisteElement)
            { // 1
                wsWord = pEnreg->wsWord;
                wsText = pEnreg->wsText;
                iPOS = pEnreg->iPOS;
                iVal = pEnreg->iValWord;
                nElement = pEnreg->nuIdElemn;
                iOccur = pEnreg->siIdOccurence;
146             wsNextUnivers = pEnreg->Univers.wsName;
                nParagraph = pEnreg->Univers.idParagraph;
                iNbPredicat = plistePredicat->Count;
                iNbQualificateurs = plisteQualificatif->Count;
                iNbPrecondition = plistePrecondition->Count;
                pNewElemnt = pEnreg;
                switch (pEnreg->nuIdTypeElement)
                {
                    case ELEMENT_PREDICAT:
                        wsText = pNewElemnt->wsText;
                        wsWord = pNewElemnt->wsWord;
                        if( pNewElemnt->nuIdElemn != OldId)
                        {
                            bIsQualificateur = false;
                        }
                        plistePredicat->Add( pNewElemnt);
162                     if( pEnreg->nuIdChunkType == CHUNKTYPE_QUALIFICATEUR)
                        {
                            if( OldId != pNewElemnt->nuIdElemn)
                            {
                                bIsQualificateur = true;
167                             if( pEnreg->iPOS == POS_ART || pEnreg->iPOS == POS_PREP || pEnreg->iPOS == POS_VERB || pEnreg->iPOS == POS_AUX|| pEnreg->iPOS == POS_NB)//il faut rappeler tout ce qui a le même identifiant dans la liste des prédicats
                                {
                                    for each( pEnreg in plistePredicat)
                                    {
                                        TempId = pNewElemnt->nuIdElemn;
                                        if( pEnreg->nuIdElemn == pNewElemnt->nuIdElemn)
                                        {
                                            wsText = pEnreg->wsText;
                                            wsWord = pEnreg->wsWord;
                                            plisteQualificatif->Add( pEnreg);
                                            bIsCompleted = true;
                                        }
                                        n++;
                                    }
                                }
                            }
                        }
                        if( bIsQualificateur == true && bIsCompleted == false)
                        {
                            wsText = pEnreg->wsText;
                            wsWord = pEnreg->wsWord;
                            plisteQualificatif->Add( pEnreg);
                        }
                        bIsCompleted = false;
                        iNbQualificateurs = plisteQualificatif->Count;
                        iNbPredicat = plistePredicat->Count;
                        OldId = TempId;
                        break;
                    case ELEMENT_PREDICAT_QUALIFIANT:
                        pNewElemnt = pEnreg;
                        wsText = pNewElemnt->wsText;
                        wsWord = pNewElemnt->wsWord;
                        plistePredicat->Add( pNewElemnt);
                        plisteQualificatif->Add( pNewElemnt);
                        break;
                    case ELEMENT_PRECONDITION:
                        if( bIsPredicat == true)
                            bIsPredicat = false;
                        if( pOldElemnt->wsWord != pEnreg->wsWord)
                        {
                            plistePrecondition->Add( pNewElemnt);
                        }
                        break;
                    case ELEMENT_QUALIFICATEUR:
                        if( bIsPredicat == true)
                        {
                            plistePredicat->Add( pNewElemnt);
                            if(wsWord == L".")
                            {
                                bIsPredicat = false;
                            }
                        }
                        else if( wsWord == L"then")
                        {
                            bIsPredicat = true;
                            plistePredicat->Add( pNewElemnt);
                        }
                        else
                        {
                            plisteQualificatif->Add( pNewElemnt);
                            iNbQualificateurs = plisteQualificatif->Count;
                        }
                        break;
                    case ELEMENT_TITLE:
                        plisteUnivers->Add( pNewElemnt);
                        break;
                }
                pOldElemnt = pEnreg;
                iSize++;
            } // end while nbElement
        }
        catch (...)
        { // 1
           throw Doc_exception( "Exception NullReference" , iSize);
        } // 1
        try
        {
244         pSegment->pLinguisticSegment->ListPredicat = plistePredicat;
245         pSegment->pLinguisticSegment->ListPrecondition = plistePrecondition;
246         pSegment->pLinguisticSegment->ListQualificatif = plisteQualificatif;
247         pSegment->pLinguisticSegment->ListUnivers = plisteUnivers;
        }
        catch (...)
        { // 1
           throw Doc_exception( "Exception NullReference" , iSize);
        } // 1
        return ( pSegment);
    }
cette méthode est assortie d'une liste d'erreurs
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 
1>..\..\..\..\Linguistic\Coherence\src\BuildComponents.cpp(146): error C2679: '=' binaire : aucun opérateur trouvé qui accepte un opérande de partie droite de type 'System::String ^' (ou il n'existe pas de conversion acceptable)
1>          E:\Program Files\Microsoft Visual Studio 10.0\VC\include\xstring(707): peut être 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(std::basic_string<_Elem,_Traits,_Ax> &&)'
1>          with
1>          [
1>              _Elem=wchar_t,
1>              _Traits=std::char_traits<wchar_t>,
1>              _Ax=std::allocator<wchar_t>
1>          ]
1>          E:\Program Files\Microsoft Visual Studio 10.0\VC\include\xstring(762): ou       'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(const std::basic_string<_Elem,_Traits,_Ax> &)'
1>          with
1>          [
1>              _Elem=wchar_t,
1>              _Traits=std::char_traits<wchar_t>,
1>              _Ax=std::allocator<wchar_t>
1>          ]
1>          E:\Program Files\Microsoft Visual Studio 10.0\VC\include\xstring(767): ou       'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(const _Elem *)'
1>          with
1>          [
1>              _Elem=wchar_t,
1>              _Traits=std::char_traits<wchar_t>,
1>              _Ax=std::allocator<wchar_t>
1>          ]
1>          E:\Program Files\Microsoft Visual Studio 10.0\VC\include\xstring(772): ou       'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(_Elem)'
1>          with
1>          [
1>              _Elem=wchar_t,
1>              _Traits=std::char_traits<wchar_t>,
1>              _Ax=std::allocator<wchar_t>
1>          ]
1>          lors de la tentative de mise en correspondance de la liste des arguments '(std::wstring, System::String ^)'
1>..\..\..\..\Linguistic\Coherence\src\BuildComponents.cpp(162): error C2065: 'CHUNKTYPE_QUALIFICATEUR' : identificateur non déclaré
1>..\..\..\..\Linguistic\Coherence\src\BuildComponents.cpp(167): error C2065: 'POS_ART' : identificateur non déclaré
1>..\..\..\..\Linguistic\Coherence\src\BuildComponents.cpp(167): error C2065: 'POS_PREP' : identificateur non déclaré
1>..\..\..\..\Linguistic\Coherence\src\BuildComponents.cpp(167): error C2065: 'POS_VERB' : identificateur non déclaré
1>..\..\..\..\Linguistic\Coherence\src\BuildComponents.cpp(167): error C2065: 'POS_AUX' : identificateur non déclaré
1>..\..\..\..\Linguistic\Coherence\src\BuildComponents.cpp(167): error C2065: 'POS_NB' : identificateur non déclaré
1>..\..\..\..\Linguistic\Coherence\src\BuildComponents.cpp(244): error C2582: 'operator =' fonction non disponible dans 'System::Collections::Generic::List<T>'
1>          with
1>          [
1>              T=SpecificationLoader::ElementSemanticM ^
1>          ]
1>..\..\..\..\Linguistic\Coherence\src\BuildComponents.cpp(245): error C2582: 'operator =' fonction non disponible dans 'System::Collections::Generic::List<T>'
1>          with
1>          [
1>              T=SpecificationLoader::ElementSemanticM ^
1>          ]
1>..\..\..\..\Linguistic\Coherence\src\BuildComponents.cpp(246): error C2582: 'operator =' fonction non disponible dans 'System::Collections::Generic::List<T>'
1>          with
1>          [
1>              T=SpecificationLoader::ElementSemanticM ^
1>          ]
1>..\..\..\..\Linguistic\Coherence\src\BuildComponents.cpp(247): error C2582: 'operator =' fonction non disponible dans 'System::Collections::Generic::List<T>'
1>          with
1>          [
1>              T=SpecificationLoader::ElementSemanticM ^
1>          ]
Comment traiter ces classes d'erreurs?

elles sont aux nombre de trois:

la première touche à l'utilisation du type stUnivers.

la deuxième touche aux identifiants déclarés dans POSM.

la troisième concerne l'affectation des listes de sortie à pSegment.