需要代码进行字符串匹配 [英] Need a code for String matching

查看:99
本文介绍了需要代码进行字符串匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,(电子学习工具)我将问题和正确答案存储在SQL数据库表中(在空间中多个单词分开).一次一次将问题放在一个文本框中.如果我要下一个问题,请单击下一步"按钮.那么下一个问题是主文本框.然后,学生可以在另一个文本框中键入相关的答案.然后,我必须将给定的答案与数据库中的正确答案进行匹配.请您给我一个ASP.net中的示例代码.C#

In my project,(e-learning tool) I stored questions and correct answers in SQL data base table(More than one word separate in space). Questions are lorded in a text box once at a time.If i want go for next question need click next button. then the next question is lord the same text box .Then student can type relevant answer in another text box. Then I have to match that given answer with the correct answer in data base.could you please give me a sample code for that in ASP.net C#

推荐答案

这是这不是我们可以回答的问题:它变得非常复杂,具体取决于您个人认为是正确"的答案.

假设您数据库中的问题和答案是:
This is not a question we can answer: it gets horribly complicated, depending on what you personally consider to be a "right" answer.

Suppose the question and answer in your DB are:
"What car is that?"
"Mercedes CLK550"


您允许什么作为正确"答案?


What do you allow as a "correct" answer?

"mercedes clk550"
"Mercedes CLK 550"
"clk550"
"MERCEDES"
"CLK 550 mercedes"

在技术上它们全部五个都是正确答案.
怎么样:

All five of them are technically correct answers.
How about:

"Mmercedes clk550"
"Merkedes CLK 550"
"clk-550"
"MERC 550"
"CLK%%) mercedes"

哪个距离很近?
那只是一个简单的,直接的问题,以事实为答案.

一旦开始允许基于文本的答案,就会打开一个让用户感到沮丧的世界,因为您对正确"的定义太狭窄,并且要求他准确输入数据库中的内容,尽管他不知道您的数据库中有什么,必须猜测,或者您的软件必须非常聪明,并且要弄清楚他的回答是什么意思,而不是他写的是什么.

可能-谷歌一直都在做-但对于这里的简单答案来说,问题太大了!

Which are pretty close?
And that is only with a simple, direct question with a fact as an answer.

As soon as you start allowing text based answers, you open up a world where the user is going to get frustrated because either your definition of "correct" is too narrow, and requires him to enter exactly what you have in the database, although he doesn''t know what you have in the database and must guess, or you software has to be extremely clever and work out what he meant by his answer rather than exactly what he wrote.

It''s possible - google does it all the time - but it is far, far too big a question for a simple answer here!


开放式问题真的很难自动评估.首先,因为在大多数情况下,有几个正确答案-在极少数情况下,测试作者能够想到所有可能的公式,这在当时是可以接受的.当然,在某些情况下,如某些语法评估那样,只有一个确切的答案是好的.但是通常,此类测试项目由教师评估,或者,如果没有这种可能性,则使用其他类型的测试.
但是,如果您坚持问题的内容,则会发布以下内容:
Open ended questions are really hard to evaluate automatically. First of all because in most cases there are several correct answers - in rare cases is the test writer able to think of all possible formulations, that could be acceptable at that point. Of course, there are cases, where only one exact answer is good, like with some grammatical assessments. But in general these kind of test items are evaluated by the instructor or, if there is no such possibility, other kind of tests are used.
But if you stick to what''s in the question you posted:
string CorrectAnswers=...; // load the spcae separated list
string AnswerGiven =...; // the answer you got

if(CorrectAnswers.Split(' ').Any(x => x == AnswerGiven))
{
  // the answer given is one of the acceptable answers
}


对带有模糊答案的问题做出多项选择.
电子学习工具中的开放式问题很痛苦:您可能希望得到字面准确的答案(例如给出数字=完全匹配的问题),或者您需要发明某种启发式方法来解释"输入的短语.

文本相关算法不起作用,因为您首先必须过滤掉填充"词,然后通过相关性"将其余词与正确答案进行比较.如果要覆盖不具有语义相关性的错别字,则必须非常聪明(顺便说一句:哪些错别字在语义上相关而哪些错别字?).

那么,为什么由于试探法的固有特性而导致的所有痛苦甚至可能导致错误的评分(它们大多数时候都起作用,但并非总是如此...)?

摘要:
-如果答案是准确的(例如确切的数字),则仅允许输入文本用户.
-如果您提出可能导致模糊答案的问题,请选择题.

干杯
安迪
Make multiple-choice for questions with fuzzy answers.
Open questions in e-learning tools is a pain: either you expect literally exact answers (like giving a number = no problem to exactly match) or you need to invent some kind of heuristics to "interprete" the entered phrase.

Text correlation algorithms do not work since you first had to filter out "filler" words and compare the rest by *correlation* to the correct answer. If you want to cover typos that have no semantic relevance, you must be very smart (BTW: which typos are semantically relevant and which are not?).

So, why all that pain that may even lead to wrong rating due to the inherent character of heuristics (they work most of the time but not not always...)?

Summary:
- Allow only textual user entry if it is an exact answer (e.g. exact number).
- Go for multiple-choice if you aske questions that may lead to fuzzy answers.

Cheers
Andi


这篇关于需要代码进行字符串匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆