predictivesearch/PcsAlgorithm/Algorithm2/inc/FindUtilChineseECE.h
branchRCL_3
changeset 18 d4f567ce2e7c
parent 7 b3431bff8c19
equal deleted inserted replaced
17:2666d9724c76 18:d4f567ce2e7c
    34 /**
    34 /**
    35 
    35 
    36 Defines flags that can be used to indicate what is the default search method for each language.
    36 Defines flags that can be used to indicate what is the default search method for each language.
    37 */
    37 */
    38 
    38 
    39 enum TDefaultAdaptiveSearchMethod
    39 enum TChineseSearchMethod
    40     {
    40     {
    41     EAdptSearchPinyin =0,
    41     EAdptSearchPinyin =0,
    42     EAdptSearchStroke,
    42     EAdptSearchStroke,
    43     EAdptSearchZhuyin,
    43     EAdptSearchZhuyin,
    44     EAdptSearchNormalCangjie,
    44     EAdptSearchNormalCangjie,
    46     EAdptSearchAdvCangjie
    46     EAdptSearchAdvCangjie
    47     };
    47     };
    48 /**
    48 /**
    49  *  STRINGINFO struct
    49  *  STRINGINFO struct
    50  *
    50  *
    51  *  This data struct is for splited taxt in find pane. 
    51  *  This data struct is for splited text in find pane. 
    52  *  It includes two type word, which is Chinese or no-Chinese 
    52  *  It includes two type word, which is Chinese or no-Chinese 
    53  *
    53  *
    54  *  @lib FindUtil.dll
    54  *  @lib FindUtil.dll
    55  *  @since S60 v3.2
    55  *  @since S60 v3.2
    56  */
    56  */
    57 struct STRINGINFO
    57 struct STRINGINFO
    58     {
    58     {
    59     TBuf<KMaxWordLength> segmentString;
    59     TBuf<KMaxWordLength> segmentString;
    60     TBool isChinese;
    60     TBool isChinese;
       
    61     TInt segmentPos;
    61     };
    62     };
    62 
    63 
    63 /**
    64 /**
    64  *  CFindUtilChineseECE utils class
    65  *  CFindUtilChineseECE utils class
    65  *
    66  *
    86     /**
    87     /**
    87      * Match arithmetic for accurate search 
    88      * Match arithmetic for accurate search 
    88      *
    89      *
    89      * @since S60 v3.2
    90      * @since S60 v3.2
    90      * @param aItemString Reference to the searching target
    91      * @param aItemString Reference to the searching target
    91      * @param aWord Reference to text in find pane
    92      * @param aPsQuery Reference to the search query
    92      * @return ETrue for the text are matched; otherwise EFalse
    93      * @return ETrue for the text are matched; otherwise EFalse
    93      */
    94      */
    94     virtual TBool MatchRefineL(const TDesC& aItemString, CPsQuery& aPsQuery);
    95     virtual TBool MatchRefineL(const TDesC& aItemString, CPsQuery& aPsQuery);
       
    96 
       
    97     /**
       
    98      * Match arithmetic for accurate search 
       
    99      *
       
   100      * @since S60 v5.2
       
   101      * @param aItemString Reference to the searching target
       
   102      * @param aPsQuery Reference to the search query
       
   103      * @param aMatchPos On return, contain positions of matching parts within aItemString
       
   104      * @param aMatchLength On return, contains lenghts of matching parts within aItemString
       
   105      * @param aHighLight  If highlight or underline position of matched contact is enabled
       
   106      * @return ETrue for the text are matched; otherwise EFalse
       
   107      */
       
   108     TBool MatchRefineL(const TDesC& aItemString, CPsQuery& aPsQuery, 
       
   109         RArray<TInt>& aMatchPos, RArray<TInt>& aMatchLength, TBool aHighLight );
    95 
   110 
    96     /**
   111     /**
    97      * Current input text is handled by this model 
   112      * Current input text is handled by this model 
    98      *
   113      *
    99      * @since S60 v3.2
   114      * @since S60 v3.2
   168     ~CFindUtilChineseECE();
   183     ~CFindUtilChineseECE();
   169 
   184 
   170 public:
   185 public:
   171 
   186 
   172     /**
   187     /**
   173      * Do translate for Chinese word
       
   174      *
       
   175      * @since S60 v3.2
       
   176      * @param aHZUnicode For translate word
       
   177      * @param aSpellList Reference to spelling list for polyphonic word
       
   178      * @return ETrue for it can be translated; otherwise EFalse
       
   179      */
       
   180     TBool T9ChineseTranslationL(TInt16 aHZUnicode, RPointerArray<HBufC>& aSpellList);
       
   181 
       
   182     /**
       
   183      * Find pane text is including Chinese word
       
   184      *
       
   185      * @since S60 v3.2
       
   186      * @param aWord Reference to text for analyse
       
   187      * @return ETrue it includes Chinese; otherwise EFalse
       
   188      */
       
   189     TBool IsChineseWord(const TDesC& aWord);
       
   190 
       
   191     /*
       
   192      * 
       
   193      */
       
   194     void SetKeyboardMode(TInt aMode);
       
   195     
       
   196     /**
       
   197      * Translate Chinese word to its spelling
   188      * Translate Chinese word to its spelling
   198      *
   189      *
   199      * @since S60 v3.2
   190      * @since S60 v3.2
   200      * @param aHZUnicode For translate word
   191      * @param aHZUnicode For translate word
   201      * @param aSpellList Reference to spelling list for polyphonic word
   192      * @param aSpellList Reference to spelling list for polyphonic word
   202      * @return ETrue for this word can be translated; otherwise EFalse
   193      * @return ETrue for this word can be translated; otherwise EFalse
   203      */
   194      */
   204     TBool DoTranslationL(TInt16 aHZUnicode, RPointerArray<HBufC>& aSpellList);
   195     TBool DoTranslationL(TInt16 aHZUnicode, RPointerArray<HBufC>& aSpellList);
       
   196 
       
   197     /**
       
   198      * Find pane text is including Chinese word
       
   199      *
       
   200      * @since S60 v3.2
       
   201      * @param aWord Reference to text for analyse
       
   202      * @return ETrue it includes Chinese; otherwise EFalse
       
   203      */
       
   204     TBool IsChineseWordIncluded(const TDesC& aWord);
   205 
   205 
   206     /*
   206     /*
   207      * 
   207      * 
   208      */
   208      */
   209     inline TLanguage CurrentInputLanguage()
   209     inline TLanguage CurrentInputLanguage()
   210         {
   210         {
   211         return iLanguage;
   211         return iLanguage;
   212         }
   212         }
   213 
   213 
       
   214     inline TChineseSearchMethod CurrentSearchMethod()
       
   215         {
       
   216         return iSearchMethod;
       
   217         }
       
   218     
   214 private:
   219 private:
   215 
   220 
   216     /**
   221     /**
   217      * Symbian second-phase constructor
   222      * Symbian second-phase constructor
   218      *
   223      *
   236      * @since S60 v3.2
   241      * @since S60 v3.2
   237      * @return none
   242      * @return none
   238      */
   243      */
   239     void CloseT9InterfaceL();
   244     void CloseT9InterfaceL();
   240 
   245 
   241     TInt CategoryOfLang(TLanguage aLanguage);
       
   242 
       
   243 
       
   244     /**
   246     /**
   245      * This letter is stroke symbol
   247      * This letter is stroke symbol
   246      *
   248      *
   247      * @since S60 v3.2
   249      * @since S60 v3.2
   248      * @param aFindWord For analyse
   250      * @param aFindWord For analyse
   249      * @return ETrue for it is stroke symbol; otherwise EFalse
   251      * @return ETrue for it is stroke symbol; otherwise EFalse
   250      */
   252      */
   251     TInt IsStrokeSymbol(const TInt aFindWord);
   253     TInt IsStrokeSymbol(const TUint16 aFindWord);
   252     
   254     
   253     // The below code is commented out because current CFindUtilChineseECE is used
   255     /**
   254     // on 3.2.3 which is not supported adaptive search. It will be easy to keep these code 
   256      * Do translate for Chinese word
   255     // for the further merging work (merge from FindUtil 5.0)
   257      *
   256 #if 0
   258      * @since S60 v3.2
       
   259      * @param aHZUnicode For translate word
       
   260      * @param aSpellList Reference to spelling list for polyphonic word
       
   261      * @return ETrue for it can be translated; otherwise EFalse
       
   262      */
       
   263     TBool T9ChineseTranslationL(TInt16 aHZUnicode, RPointerArray<HBufC>& aSpellList);
       
   264 
   257     /**
   265     /**
   258      * Do translate for Chinese word
   266      * Do translate for Chinese word
   259      *
   267      *
   260      * @since S60 v5.0.1
   268      * @since S60 v5.0.1
   261      * @param aHZUnicode For translate word
   269      * @param aHZUnicode For translate word
   262      * @param aSpellList Reference to spelling list for polyphonic word
   270      * @param aSpellList Reference to spelling list for polyphonic word
   263      * @return ETrue for it can be translated; otherwise EFalse
   271      * @return ETrue for it can be translated; otherwise EFalse
   264      */
   272      */
   265     TBool T9ChineseTranslationAdaptiveL(TInt16 aHZUnicode, RPointerArray<HBufC>& aSpellList);
   273     TBool T9ChineseTranslationAdaptiveL(TInt16 aHZUnicode, RPointerArray<HBufC>& aSpellList);
   266 #endif
       
   267     
   274     
   268     /**
   275     /**
   269      * Find pane text is including separator
   276      * Find pane text is including separator
   270      *
   277      *
   271      * @since S60 v3.2
   278      * @since S60 v3.2
   281      * @param aWord Reference to text for analyse
   288      * @param aWord Reference to text for analyse
   282      * @return ETrue it is stroke symbol; otherwise EFalse
   289      * @return ETrue it is stroke symbol; otherwise EFalse
   283      */
   290      */
   284     TBool IsStrokeSymbolInString(const TDesC& aWord);
   291     TBool IsStrokeSymbolInString(const TDesC& aWord);
   285 
   292 
       
   293     /**
       
   294      * Find pane text is just Chinese word
       
   295      * 
       
   296      * @param aWord Reference to text for analyse
       
   297      * @return ETrue it is all Chinese word(s); otherwise EFalse
       
   298      */
       
   299     TBool IsAllChineseWord(const TDesC& aWord);
       
   300     
   286     /**
   301     /**
   287      * Find pane text is including zhuyin symbol
   302      * Find pane text is including zhuyin symbol
   288      *
   303      *
   289      * @since S60 v3.2
   304      * @since S60 v3.2
   290      * @param aWord Reference to text for analyse
   305      * @param aWord Reference to text for analyse
   325      *
   340      *
   326      * @since S60 v3.2
   341      * @since S60 v3.2
   327      * @param aStringInfoArr Reference to segment list
   342      * @param aStringInfoArr Reference to segment list
   328      * @param aSegmentStr Reference to segment text
   343      * @param aSegmentStr Reference to segment text
   329      * @param aChinese The segment is Chinese
   344      * @param aChinese The segment is Chinese
       
   345      * @param aIndexAfterStr The first index in the source string after the aSegmentStr.
       
   346      *                       The indices of characters of aSegmentStr are 
       
   347      *                       [aIndexAfterStr-aSegmementStr.Length(), aIndexAfterStr-1]
   330      * @return none
   348      * @return none
   331      */
   349      */
   332     void InsertStrInforArrayL(RPointerArray<STRINGINFO>& aStringInfoArr,
   350     void InsertStrInforArrayL(RPointerArray<STRINGINFO>& aStringInfoArr,
   333                               TDes &aSegmentStr, const TBool aChinese);
   351                               TDes &aSegmentStr, TBool aChinese, TInt aIndexAfterStr);
   334 
   352 
   335     /**
   353     /**
   336      * This segment is matched by search text
   354      * This segment is matched by search text
   337      *
   355      *
   338      * @since S60 v3.2
   356      * @since S60 v3.2
   339      * @param aStringInfoArr Reference to segment list
   357      * @param aStringInfoArr Reference to segment list
   340      * @param aSearchText Reference to searching text
   358      * @param aSearchText Reference to searching text
       
   359      * @param aMatchPos On return, contain positions of matching parts within the original searcg target text
       
   360      * @param aMatchLength On return, contains lenghts of matching parts within the original search target text
       
   361      * @param aHighLight  If highlight or underline position of matched contact is enabled
   341      * @return ETrue it is matched; otherwise EFalse
   362      * @return ETrue it is matched; otherwise EFalse
   342      */
   363      */
   343     TBool MatchSegmentL(RPointerArray<STRINGINFO>& aStringInfoArr, CPsQuery& aQuery);
   364     TBool MatchSegmentL(RPointerArray<STRINGINFO>& aStringInfoArr, 
       
   365         CPsQuery& aQuery, RArray<TInt>& aMatchPos, RArray<TInt>& aMatchLength, TBool aHighLight );
   344 
   366 
   345     /**
   367     /**
   346      * Search text by reverse
   368      * Search text by reverse
   347      *
   369      *
   348      * @since S60 v3.2
   370      * @since S60 v3.2
   349      * @param aFirst Reference to matched text
   371      * @param aFirst Reference to matched text
   350      * @param aSecond Reference to matched text
   372      * @param aSecond Reference to matched text
       
   373 	 * @param aFullQuery Reference to the FullQuery
   351      * @return Matched count
   374      * @return Matched count
   352      */
   375      */
   353     TInt ReverseMatchString(const TDesC& aFirst, const TDesC& aSecond);
   376     TInt ReverseMatchStringL(const TDesC& aFirst, const TDesC& aSecond, CPsQuery& aFullQuery );
   354 
   377 
   355     /**
   378     /**
   356      * Search text in other text 
   379      * Search text in other text 
   357      *
   380      *
   358      * @since S60 v3.2
   381      * @since S60 v3.2
   359      * @param aFirst Reference to matched text
   382      * @param aFirst Reference to matched text
   360      * @param aSecond Reference to matched text
   383      * @param aSecond Reference to matched text
       
   384 	 * @param aFullQuery Reference to the FullQuery
   361      * @return Matched count
   385      * @return Matched count
   362      */
   386      */
   363     TInt MatchString(const TDesC& aFirst, const TDesC& aSecond);
   387     TInt MatchStringL(const TDesC& aFirst, const TDesC& aSecond, CPsQuery& aFullQuery);
   364     
   388     
   365     /**
   389     /**
   366      * Search text in other text 
   390      * Search text in other text 
   367      *
   391      *
   368      * @since S60 v3.2
   392      * @since S60 v3.2
   369      * @param aSearhTargetStr Reference to the target text to be queried
   393      * @param aSearchTargetString Data to be searched through
   370      * @param CPsQuery maintain the matched text from user 
   394      * @param aQuery Text to be searched from aSearchTargetString
   371      * @return Matched count
   395      * @return Number of matched characters from the begining of aQuery
   372      */
   396      */
   373     TInt MatchString(const TDesC& aSearhTargetStr, CPsQuery& aQuery);
   397     TInt MatchStringL(const TDesC& aSearhTargetString, CPsQuery& aQuery);
   374 
   398 
   375     /**
   399     /**
   376      * Search Chinese word in input text 
   400      * Search Chinese word in input text 
   377      *
   401      *
   378      * @since S60 v3.2
   402      * @since S60 v3.2
   379      * @param aFirst Reference to matched text
   403      * @param aSearchTargetString Data to be searched through
   380      * @param aSecond Reference to matched text
   404      * @param aQuery Text to be searched from aSearchTargetString
   381      * @return Matched count
   405      * @param aMatchStrtIdx On return, will contain the start index 
   382      */
   406      *                      of the matching part within aSearchTargetString
   383     TInt MatchChineseStringL(const TDesC& aSearchTargetString, CPsQuery& aQuery, TInt& aIndex);
   407      * @param aMatchEndIdx On return, will contain the end index 
       
   408      *                     of the matching part within aSearchTargetString
       
   409      * @return Number of matched characters from the begining of aQuery
       
   410      */
       
   411     TInt MatchChineseStringL(const TDesC& aSearchTargetString, CPsQuery& aQuery, TInt& aMatchStartIdx, TInt& aMatchEndIdx);
   384 
   412 
   385     /**
   413     /**
   386      * Initial character search 
   414      * Initial character search 
   387      *
   415      *
   388      * @since S60 v3.2
   416      * @since S60 v3.2
   395 
   423 
   396     /**
   424     /**
   397      * Maximal matched count in spelling list  
   425      * Maximal matched count in spelling list  
   398      *
   426      *
   399      * @since S60 v3.2
   427      * @since S60 v3.2
   400      * @param spellList Reference to spelling list
   428      * @param aSpellList Reference to spelling list
   401      * @param aSearchStr Reference to search text
   429      * @param aSearchStr Reference to search text
   402      * @param aPreviouStr Reference to previous matched word
   430      * @param aPreviouStr Reference to previous matched word
   403      * @param aMatchIndex Reference to match index in Search text
   431      * @param aMatchIndex Reference to match index in Search text
   404      * @param aFullMatched Previous word is fully matched
   432      * @param aFullMatched Previous word is fully matched
   405      * @param aMatchedCount Previous word matched count
   433      * @param aMatchedCount Previous word matched count
   406      * @param aAgain Search again
   434      * @param aAgain Search again
       
   435 	 * @param aFullQuery Reference to the FullQuery
   407      * @return Matched count
   436      * @return Matched count
   408      */
   437      */
   409     TInt MaxMatchInList(RPointerArray<HBufC> &spellList, CPsQuery& aQuery,
   438     TInt MaxMatchInListL(RPointerArray<HBufC>& aSpellList, CPsQuery& aQuery,
   410                         TDesC& aPreviouStr, TInt& aMatchIndex, const TBool aFullMatched,
   439                         TDesC& aPreviouStr, TInt& aMatchIndex, const TBool aFullMatched,
   411                         const TInt aMatchedCount, TBool& aAgain);
   440                         const TInt aMatchedCount, TBool& aAgain, TBool& aPrevReplaced, CPsQuery& aFullQuery);
   412 
   441 
   413     /**
   442     /**
   414      * Search the taxt is include the input text 
   443      * Search the taxt is include the input text 
   415      *
   444      *
   416      * @since S60 v3.2
   445      * @since S60 v3.2
   525     void AddNextIfOverlapL(const RPointerArray<STRINGINFO>& astringInfoArr ,
   554     void AddNextIfOverlapL(const RPointerArray<STRINGINFO>& astringInfoArr ,
   526                 const TInt aindex,const TInt aindexforfind ,
   555                 const TInt aindex,const TInt aindexforfind ,
   527                 const TDes& aCurrentBuf,HBufC*& aNextChars );
   556                 const TDes& aCurrentBuf,HBufC*& aNextChars );
   528 #endif
   557 #endif
   529 
   558 
   530     /**
       
   531      * Converts the input data to the key board mode specified by the query.
       
   532      * Mode is referred in the CPsQuery.
       
   533      * If the mode is ITU-T, data is converted to numeric.
       
   534      * If the mode is Qwerty, data is retained as is.
       
   535      * If the mode is Mix, data is conerted according to the keyboard mode 
       
   536      * of the corresponding query chararter 
       
   537      */
       
   538     void ConvertdDataToKeyBoardModeL(CPsQuery& aQuery, 
       
   539                                      const TDesC& aSearchTargetStr,
       
   540                                      TBuf<KMaxWordInterpretationLen>& aOutputNumInterpretationStr);
       
   541     
       
   542     // help function for using CPsQuery
   559     // help function for using CPsQuery
   543 public:
   560 public:
   544     void GetPartOfQueryL(CPsQuery& aSrcQuery, TInt aStartIndex, 
   561     void GetPartOfQueryL(CPsQuery& aSrcQuery, TInt aStartIndex, 
   545                          TInt aEndIndex, CPsQuery& aDestQuery);
   562                          TInt aEndIndex, CPsQuery& aDestQuery);
   546 private:
   563 private:
   553      * Ptiengine for Chinese translation (Own)
   570      * Ptiengine for Chinese translation (Own)
   554      */
   571      */
   555     CPtiEngine* iPtiEngine;
   572     CPtiEngine* iPtiEngine;
   556 
   573 
   557     /**
   574     /**
   558      * Ptiengine for Chinese translation in English language (Own)
       
   559      */
       
   560     CPtiEngine* iPtiEnginePrc;
       
   561 
       
   562     /**
       
   563      * Current text input language 
   575      * Current text input language 
   564      */
   576      */
   565     TLanguage iLanguage;
   577     TLanguage iLanguage;
   566 
       
   567     /**
       
   568      * It is support Chinese Language
       
   569      */
       
   570     TBool iSupportPRCChinese;
       
   571 
   578 
   572     /**
   579     /**
   573      * Current input mode
   580      * Current input mode
   574      */
   581      */
   575     TInt iCurInputMode;
   582     TInt iCurInputMode;
   582     /**
   589     /**
   583      * The repository watcher(Own);
   590      * The repository watcher(Own);
   584      */
   591      */
   585     CFindRepositoryWatcher* iWatcher;
   592     CFindRepositoryWatcher* iWatcher;
   586    
   593    
   587     // The below code is commented out because current CFindUtilChineseECE is used
       
   588     // on 3.2.3 which is not supported adaptive search. It will be easy to keep these code 
       
   589     // for the further merging work (merge from FindUtil 5.0)
       
   590 #if 0
       
   591     /**
   594     /**
   592      * Repository for input mode (Own)
   595      * Repository for input mode (Own)
   593      */     
   596      */     
   594     CRepository* iRepositoryFindAdaptive;	 
   597     CRepository* iRepositoryFindAdaptive;
   595 
   598 
   596     /**
   599     /**
   597      * The repository watcher(Own);
   600      * The repository watcher(Own);
   598      */
   601      */
   599     CFindRepositoryWatcher* iWatcherAdaptive;
   602     CFindRepositoryWatcher* iWatcherAdaptive;
   600     
   603     
   601    
   604    
   602     /**
   605     /**
   603      * The default adaptive search method;
   606      * The default adaptive search method;
   604      */
   607      */
   605     TDefaultAdaptiveSearchMethod iSearchMethodPRC;
   608     TChineseSearchMethod iSearchMethod;
   606     
       
   607     /**
       
   608      * The default adaptive search method;
       
   609      */
       
   610     TDefaultAdaptiveSearchMethod iSearchMethodTaiWan;
       
   611     
       
   612     /**
       
   613      * The default adaptive search method;
       
   614      */
       
   615     TDefaultAdaptiveSearchMethod iSearchMethodHongKong;
       
   616     
   609     
   617     /**
   610     /**
   618      * The search method;
   611      * The search method;
   619      */
   612      */
   620     TBool iSearchMethodAdaptive;
   613     TBool iSearchMethodAdaptive;
   621 #endif
       
   622 
   614 
   623     CPcsAlgorithm2* iAlgorithm;
   615     CPcsAlgorithm2* iAlgorithm;
   624 
       
   625     /*
       
   626      * The keyboard Mode
       
   627      */
       
   628     TInt iKeyboardMode;
       
   629 
   616 
   630     };
   617     };
   631 
   618 
   632 #endif // __FINDUTILCHINESE_ECE__
   619 #endif // __FINDUTILCHINESE_ECE__
   633 // End of File
   620 // End of File