private List<String> extractQuestionPatternFromQuestion(String question, PatternMatchStrategy patternMatchStrategy) {
        List<String> questionPatterns = new ArrayList<>();
        //去除问题中的前后空白字符
        question = question.trim();
        LOG.info("问题：" + question);
        if (patternMatchStrategy.enableQuestionPattern(QuestionPattern.Question)) {
            questionPatterns.add(question);
        }
        if (patternMatchStrategy.enableQuestionPattern(QuestionPattern.TermWithNatures)
                || patternMatchStrategy.enableQuestionPattern(QuestionPattern.Natures)) {
            String termWithNature = questionPatternCache.get(question + "termWithNature");
            String nature = questionPatternCache.get(question + "nature");

            if (termWithNature == null || nature == null) {
                //提取问题词性以便和模式进行匹配
                List<Word> words = WordParser.parse(question);
                //APDPlat的发起人是谁？
                //apdplat/en 的/uj 发起人/n 是/v 谁/RW.RWPersonSingle ？/w 
                StringBuilder termWithNatureStrs = new StringBuilder();
                //APDPlat的发起人是谁？
                //en/uj/n/v/RW.RWPersonSingle/w		
                StringBuilder natureStrs = new StringBuilder();
                int i = 0;
                for (Word word : words) {
                    termWithNatureStrs.append(word.getText()).append("/").append(word.getPartOfSpeech().getPos()).append(" ");
                    if ((i++) > 0) {
                        natureStrs.append("/");
                    }
                    natureStrs.append(word.getPartOfSpeech().getPos());
                }
                termWithNature = termWithNatureStrs.toString();
                nature = natureStrs.toString();
                questionPatternCache.put(question + "termWithNature", termWithNature);
                questionPatternCache.put(question + "nature", nature);
            }

            if (patternMatchStrategy.enableQuestionPattern(QuestionPattern.TermWithNatures)) {
                questionPatterns.add(termWithNature);
                LOG.info("词和词性序列：" + termWithNature);
            }
            if (patternMatchStrategy.enableQuestionPattern(QuestionPattern.Natures)) {
                questionPatterns.add(nature);
                LOG.info("词性序列：" + nature);
            }
        }
        if (patternMatchStrategy.enableQuestionPattern(QuestionPattern.MainPartPattern)
                || patternMatchStrategy.enableQuestionPattern(QuestionPattern.MainPartNaturePattern)) {
            String mainPart = questionPatternCache.get(question + "mainPart");
            if (mainPart == null) {
                //提取主谓宾及词性以便和模式进行匹配
                QuestionStructure questionStructure = mainPartExtracter.getMainPart(question);
                if(questionStructure != null){
                    mainPart = questionStructure.getMainPart();
                    questionPatternCache.put(question + "mainPart", mainPart);
                }
            }
            if (mainPart != null) {
                if (patternMatchStrategy.enableQuestionPattern(QuestionPattern.MainPartPattern)) {
                    String questionMainPartPattern = questionPatternCache.get(question + "questionMainPartPattern");
                    if (questionMainPartPattern == null) {
                        questionMainPartPattern = mainPartExtracter.getQuestionMainPartPattern(question, mainPart);
                        questionPatternCache.put(question + "questionMainPartPattern", questionMainPartPattern);
                    }
                    questionPatterns.add(questionMainPartPattern);
                    LOG.info("主谓宾词和词性序列：" + questionMainPartPattern);
                }
                if (patternMatchStrategy.enableQuestionPattern(QuestionPattern.MainPartNaturePattern)) {
                    String questionMainPartNaturePattern = questionPatternCache.get(question + "questionMainPartNaturePattern");
                    if (questionMainPartNaturePattern == null) {
                        questionMainPartNaturePattern = mainPartExtracter.getQuestionMainPartNaturePattern(question, mainPart);
                        questionPatternCache.put(question + "mainPartPattern", questionMainPartNaturePattern);
                    }
                    questionPatterns.add(questionMainPartNaturePattern);
                    LOG.info("主谓宾词性序列：" + questionMainPartNaturePattern);
                }
            }
        }
        return questionPatterns;
    }
private List < String > extractQuestionPatternFromQuestion ( String question , PatternMatchStrategy patternMatchStrategy ) { List < String > questionPatterns = new ArrayList < > ( ) ; question = question . trim ( ) ; LOG . info ( "问题：" + question ) ; if ( patternMatchStrategy . enableQuestionPattern ( QuestionPattern . Question ) ) { questionPatterns . add ( question ) ; } if ( patternMatchStrategy . enableQuestionPattern ( QuestionPattern . TermWithNatures ) || patternMatchStrategy . enableQuestionPattern ( QuestionPattern . Natures ) ) { String termWithNature = questionPatternCache . get ( question + "termWithNature" ) ; String nature = questionPatternCache . get ( question + "nature" ) ; if ( termWithNature == null || nature == null ) { List < Word > words = WordParser . parse ( question ) ; StringBuilder termWithNatureStrs = new StringBuilder ( ) ; StringBuilder natureStrs = new StringBuilder ( ) ; int i = 0 ; for ( Word word : words ) { termWithNatureStrs . append ( word . getText ( ) ) . append ( "/" ) . append ( word . getPartOfSpeech ( ) . getPos ( ) ) . append ( " " ) ; if ( ( i ++ ) > 0 ) { natureStrs . append ( "/" ) ; } natureStrs . append ( word . getPartOfSpeech ( ) . getPos ( ) ) ; } termWithNature = termWithNatureStrs . toString ( ) ; nature = natureStrs . toString ( ) ; questionPatternCache . put ( question + "termWithNature" , termWithNature ) ; questionPatternCache . put ( question + "nature" , nature ) ; } if ( patternMatchStrategy . enableQuestionPattern ( QuestionPattern . TermWithNatures ) ) { questionPatterns . add ( termWithNature ) ; LOG . info ( "词和词性序列：" + termWithNature ) ; } if ( patternMatchStrategy . enableQuestionPattern ( QuestionPattern . Natures ) ) { questionPatterns . add ( nature ) ; LOG . info ( "词性序列：" + nature ) ; } } if ( patternMatchStrategy . enableQuestionPattern ( QuestionPattern . MainPartPattern ) || patternMatchStrategy . enableQuestionPattern ( QuestionPattern . MainPartNaturePattern ) ) { String mainPart = questionPatternCache . get ( question + "mainPart" ) ; if ( mainPart == null ) { QuestionStructure questionStructure = mainPartExtracter . getMainPart ( question ) ; if ( questionStructure != null ) { mainPart = questionStructure . getMainPart ( ) ; questionPatternCache . put ( question + "mainPart" , mainPart ) ; } } if ( mainPart != null ) { if ( patternMatchStrategy . enableQuestionPattern ( QuestionPattern . MainPartPattern ) ) { String questionMainPartPattern = questionPatternCache . get ( question + "questionMainPartPattern" ) ; if ( questionMainPartPattern == null ) { questionMainPartPattern = mainPartExtracter . getQuestionMainPartPattern ( question , mainPart ) ; questionPatternCache . put ( question + "questionMainPartPattern" , questionMainPartPattern ) ; } questionPatterns . add ( questionMainPartPattern ) ; LOG . info ( "主谓宾词和词性序列：" + questionMainPartPattern ) ; } if ( patternMatchStrategy . enableQuestionPattern ( QuestionPattern . MainPartNaturePattern ) ) { String questionMainPartNaturePattern = questionPatternCache . get ( question + "questionMainPartNaturePattern" ) ; if ( questionMainPartNaturePattern == null ) { questionMainPartNaturePattern = mainPartExtracter . getQuestionMainPartNaturePattern ( question , mainPart ) ; questionPatternCache . put ( question + "mainPartPattern" , questionMainPartNaturePattern ) ; } questionPatterns . add ( questionMainPartNaturePattern ) ; LOG . info ( "主谓宾词性序列：" + questionMainPartNaturePattern ) ; } } } return questionPatterns ; }
从问题中提取问题模式

@param question 问题
@return 问题模式