Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在C语言的N个最佳句子中选择最佳句子_C#_Regex_Streamreader - Fatal编程技术网

C# 在C语言的N个最佳句子中选择最佳句子

C# 在C语言的N个最佳句子中选择最佳句子,c#,regex,streamreader,C#,Regex,Streamreader,我有一个文本文件,文本按句子排列。 每个句子连续重复3次。每组句子之间的唯一区别是标记出现次数。标记为[loc]、[Time]和[PER]。考虑下面的例子。 Match between [Loc]India[/Loc] and [Loc]Seri Lanka[/Loc] will start at [Time]12 o'clock[/TIME] Match between [Loc]India[/Loc] and [Loc]Seri Lanka[/Loc] will start at 12

我有一个文本文件,文本按句子排列。 每个句子连续重复3次。每组句子之间的唯一区别是标记出现次数。标记为[loc]、[Time]和[PER]。考虑下面的例子。
Match between [Loc]India[/Loc] and [Loc]Seri Lanka[/Loc] will start at [Time]12 o'clock[/TIME]  
Match between [Loc]India[/Loc] and [Loc]Seri Lanka[/Loc] will start at 12 o'clock   
Match between [Loc]India[/Loc] and Seri Lanka will start at [Time]12 o'clock[/TIME]  
[PER]Dhoni[/PER] will lead Indian Team  
[PER]Dhoni[/PER] will lead [PER]Indian Team[/PER]  
Dhoni  will lead Indian Team  
我的目标是在每组句子中选择那些标签数量最多的句子。e、 g在第1组第1句中,共有 第二组中的三个标记[Loc]、[Loc]和[Time]类似于句子2。
我尝试使用StreamReader,但我无法跳过句子。

如果标记确实出现在句子中,那么只需进行计数

我是用VB.net写的,但是语法基本上是一样的

Dim sen1 as String = between [Loc]India[/Loc] and [Loc]Seri Lanka[/Loc] will start at [Time]12 o'clock[/TIME] 
Dim split as String() = sen1.split("/"c)
Dim senCount as Integer = split.count
现在你知道句子1有3个标签了

你甚至可以把它变成这样的函数-

Private function tagCount(byval thisSentence As String)
     Dim split as String() = thisSentence.split("/"c)
     Dim senCount as Integer = split.count
     Return senCount
End Function

然后循环浏览你的句子,确定哪个句子的标签最多。

请使用代码格式编辑你的问题。它是不可读的。所有已发布内容的可能副本是程序描述。然而,我们需要你去。我们不能确定你想从我们这里得到什么。请在您的帖子中加入我们可以回答的有效问题。提醒:确保您知道,要求我们为您编写程序和建议是离题的。