在我拥有的文本文件中,每个句子都用特定类型表示,比如:对比句。对比句可以用“CONTRAST”、“CONTR”或“WEAKCONTR”标记来表示。例如:
IMPSENT_CONTRAST_VIS(Studying networks in this way can help to identify the people from whom an individual learns, where conflicts_MD:+ in understanding_MD:+ may originate, and which contextual factors influence learning.)
因此,我使用以下表达式进行计数:/(\_(WEAK))|(\_CONTRAST)|(\_CONTR(\_|\())/g,这个表达式完美地解决了问题。
现在的问题是,有些句子用了多个对比标签,例如:CONTR和WEAKCONTR一起使用。例如:
IMPSENT_CONTRAST_EMPH_WEAKCONTR_VIS(Studying_MD:+ networks in this way can help to identify_MD:+ the people from whom an individual learns, where conflicts_MD:+ in understanding_MD:+ may originate, and which contextual factors influence learning.)
此时,我必须将其视为1而不是2进行计数。您有没有想法如何使用RegExp实现这一点?
IMPSENT_CONTRAST_VIS(Studying networks in this way can help to identify the people from whom an individual learns, where conflicts_MD:+ in understanding_MD:+ may originate, and which contextual factors influence learning.)
因此,我使用以下表达式进行计数:/(\_(WEAK))|(\_CONTRAST)|(\_CONTR(\_|\())/g,这个表达式完美地解决了问题。
现在的问题是,有些句子用了多个对比标签,例如:CONTR和WEAKCONTR一起使用。例如:
IMPSENT_CONTRAST_EMPH_WEAKCONTR_VIS(Studying_MD:+ networks in this way can help to identify_MD:+ the people from whom an individual learns, where conflicts_MD:+ in understanding_MD:+ may originate, and which contextual factors influence learning.)
此时,我必须将其视为1而不是2进行计数。您有没有想法如何使用RegExp实现这一点?