|
@@ -32,9 +32,10 @@ namespace HTEXLib.Translator
|
|
|
public const string Filed = "Filed";
|
|
|
public const string Level = "Level";
|
|
|
public const string Count = "Count";
|
|
|
+ public const string Taxonomy = "Taxonomy";
|
|
|
// public LangConfig langConfig { get; set; }
|
|
|
// public HtmlDocument doc { get; set; } = new HtmlDocument();
|
|
|
- public string[] optionsKeys { get; set; }
|
|
|
+ public List<List<string>> optionsKeys { get; set; } = new List<List<string>>();
|
|
|
public Dictionary<string, string[]> dict { get; set; }
|
|
|
// public string[] Fileds { get; set; }
|
|
|
public TagConfig _TagConfig { get; set; }
|
|
@@ -67,6 +68,8 @@ namespace HTEXLib.Translator
|
|
|
}
|
|
|
dict[_langConfig.Item.Answer] = new string[] { _langConfig.Lang, Answer };
|
|
|
dict[_langConfig.Item.Analysis] = new string[] { _langConfig.Lang, Analysis };
|
|
|
+ dict[_langConfig.Item.Taxonomy] = new string[] { _langConfig.Lang, Taxonomy };
|
|
|
+
|
|
|
dict[_langConfig.Item.Ended] = new string[] { _langConfig.Lang, Ended };
|
|
|
dict[_langConfig.Item.Point] = new string[] { _langConfig.Lang, Point };
|
|
|
dict[_langConfig.Item.Score] = new string[] { _langConfig.Lang, Score };
|
|
@@ -77,7 +80,16 @@ namespace HTEXLib.Translator
|
|
|
dict[_langConfig.Item.Type[key]] = new string[] { _langConfig.Lang, Summary, key };
|
|
|
}
|
|
|
}
|
|
|
- optionsKeys = _TagConfig.Options.Select(s => s.ToString()).ToArray();
|
|
|
+ string [] ops= _TagConfig.Options.Split('-');
|
|
|
+ foreach (string op in ops)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrWhiteSpace(op))
|
|
|
+ {
|
|
|
+ var data = op.Select(z => z.ToString()).ToList();
|
|
|
+ optionsKeys.Add(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // optionsKeys = .Select(s => s.ToString()).ToArray();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -91,6 +103,7 @@ namespace HTEXLib.Translator
|
|
|
foreach (var _langConfig in _TagConfig.LangConfig) {
|
|
|
string ans = _TagConfig.Start + _langConfig.Item.Answer + _TagConfig.End;
|
|
|
string als = _TagConfig.Start + _langConfig.Item.Analysis + _TagConfig.End;
|
|
|
+ string tax = _TagConfig.Start + _langConfig.Item.Taxonomy + _TagConfig.End;
|
|
|
string end = _TagConfig.Start + _langConfig.Item.Ended + _TagConfig.End;
|
|
|
string pot = _TagConfig.Start + _langConfig.Item.Point + _TagConfig.End;
|
|
|
string scr = _TagConfig.Start + _langConfig.Item.Score + _TagConfig.End;
|
|
@@ -106,6 +119,7 @@ namespace HTEXLib.Translator
|
|
|
}
|
|
|
string[] ansarry = ans.Select(s => s.ToString()).ToArray();
|
|
|
string[] alsarry = als.Select(s => s.ToString()).ToArray();
|
|
|
+ string[] taxarry = tax.Select(s => s.ToString()).ToArray();
|
|
|
string[] endarry = end.Select(s => s.ToString()).ToArray();
|
|
|
string[] potarry = pot.Select(s => s.ToString()).ToArray();
|
|
|
string[] scrarry = scr.Select(s => s.ToString()).ToArray();
|
|
@@ -113,6 +127,7 @@ namespace HTEXLib.Translator
|
|
|
string[] cutarry = cut.Select(s => s.ToString()).ToArray();
|
|
|
string ansReg = string.Join("\\s*", ansarry);
|
|
|
string alsReg = string.Join("\\s*", alsarry);
|
|
|
+ string taxReg = string.Join("\\s*", taxarry);
|
|
|
string endReg = string.Join("\\s*", endarry);
|
|
|
string potReg = string.Join("\\s*", potarry);
|
|
|
string scrReg = string.Join("\\s*", scrarry);
|
|
@@ -120,6 +135,7 @@ namespace HTEXLib.Translator
|
|
|
string cutReg = string.Join("\\s*", cutarry);
|
|
|
html = Regex.Replace(html, ansReg, ans);
|
|
|
html = Regex.Replace(html, alsReg, als);
|
|
|
+ html = Regex.Replace(html, taxReg, tax);
|
|
|
html = Regex.Replace(html, endReg, end);
|
|
|
html = Regex.Replace(html, potReg, pot);
|
|
|
html = Regex.Replace(html, scrReg, scr);
|
|
@@ -370,6 +386,18 @@ namespace HTEXLib.Translator
|
|
|
openFlag = true;
|
|
|
openTagLang = keyInfo[0];
|
|
|
break;
|
|
|
+ case Taxonomy:
|
|
|
+ //下列代码不能调整顺序
|
|
|
+ if (!string.IsNullOrEmpty(openTag) && openFlag)
|
|
|
+ {
|
|
|
+ DoOpenTag(openTag, openTagVal, openFlag, openTagLang, content, test);
|
|
|
+ content = new StringBuilder();
|
|
|
+ }
|
|
|
+ openTag = Taxonomy;
|
|
|
+ openTagVal = tagValue;
|
|
|
+ openFlag = true;
|
|
|
+ openTagLang = keyInfo[0];
|
|
|
+ break;
|
|
|
case Ended:
|
|
|
break;
|
|
|
case Point:
|
|
@@ -465,25 +493,39 @@ namespace HTEXLib.Translator
|
|
|
question = question.Replace(aza[idx], azh[idx]);
|
|
|
}
|
|
|
List<CodeValue> options = new List<CodeValue>();
|
|
|
- string optsRgex = optionsKeys[0] + "\\s*(\\.|\\.|\\、|\\:|\\:)([\\s\\S]*?).*"; ;
|
|
|
+ int index = 0;
|
|
|
+ string optsRgex = optionsKeys[0][0] + "\\s*(\\.|\\.|\\、|\\:|\\:)([\\s\\S]*?).*";
|
|
|
string optsHtml = Regex.Match(question, optsRgex).Value;
|
|
|
+ if (string.IsNullOrWhiteSpace(optsHtml) && optionsKeys.Count>1) {
|
|
|
+ optsRgex = optionsKeys[1][0] + "\\s*(\\.|\\.|\\、|\\:|\\:)([\\s\\S]*?).*";
|
|
|
+ index=1;
|
|
|
+ optsHtml = Regex.Match(question, optsRgex).Value;
|
|
|
+ }
|
|
|
// StringBuilder textImg = new StringBuilder();
|
|
|
- for (int i = 0; i < optionsKeys.Length - 1; i++)
|
|
|
+ for (int i = 0; i < optionsKeys[index].Count - 1; i++)
|
|
|
{
|
|
|
- string optRgex = optionsKeys[i] + "\\s*(\\.|\\.|\\、|\\:|\\:)([\\s\\S]*?)" + optionsKeys[i + 1] + "\\s*(\\.|\\.|\\、|\\:|\\:)";
|
|
|
+ string optRgex = optionsKeys[index][i] + "\\s*(\\.|\\.|\\、|\\:|\\:)([\\s\\S]*?)" + optionsKeys[index][i + 1] + "\\s*(\\.|\\.|\\、|\\:|\\:)";
|
|
|
string optHtml = Regex.Match(optsHtml, optRgex).Value;
|
|
|
if (string.IsNullOrWhiteSpace(optHtml)) {
|
|
|
- optRgex = optionsKeys[i] + "\\s*(\\.|\\.|\\、|\\:|\\:).*";
|
|
|
+ optRgex = optionsKeys[index][i] + "\\s*(\\.|\\.|\\、|\\:|\\:).*";
|
|
|
optHtml = Regex.Match(optsHtml, optRgex).Value;
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(optHtml))
|
|
|
{
|
|
|
- optHtml = Regex.Replace(optHtml, optionsKeys[i + 1] + "\\s*(\\.|\\.|\\、|\\:|\\:)", "");
|
|
|
+ optHtml = Regex.Replace(optHtml, optionsKeys[index][i + 1] + "\\s*(\\.|\\.|\\、|\\:|\\:)", "");
|
|
|
optHtml = optHtml.Substring(2, optHtml.Length - 2);
|
|
|
optHtml = HtmlHelper.DoUselessTag(optHtml);
|
|
|
optHtml = optHtml.TrimStart().TrimEnd();
|
|
|
- // textImg.Append(HtmlHelper.DoTextImg(optHtml));
|
|
|
- options.Add(new CodeValue { code = optionsKeys[i], value = optHtml });
|
|
|
+ // textImg.Append(HtmlHelper.DoTextImg(optHtml));
|
|
|
+ if (index==1)
|
|
|
+ {
|
|
|
+ var code = optionsKeys[0][int.Parse(optionsKeys[index][i])-1];
|
|
|
+ options.Add(new CodeValue { code = code, value = optHtml });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ options.Add(new CodeValue { code = optionsKeys[index][i], value = optHtml });
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(optsHtml))
|
|
@@ -534,6 +576,15 @@ namespace HTEXLib.Translator
|
|
|
var notin = ans.Except(codes).ToList();
|
|
|
List<string> ansd= ans.ToList();
|
|
|
ansd.RemoveAll(x => notin.Contains(x));
|
|
|
+ if (!ansd.IsNotEmpty()) {
|
|
|
+ ansd=new List<string>();
|
|
|
+ foreach (var an in ans) {
|
|
|
+ if (int.TryParse(an, out int op) && op>=1) {
|
|
|
+ ansd.Add(optionsKeys[0][op-1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ansd.RemoveAll(x => notin.Contains(x));
|
|
|
+ }
|
|
|
test.answer = ansd;
|
|
|
}
|
|
|
else {
|
|
@@ -573,6 +624,22 @@ namespace HTEXLib.Translator
|
|
|
case Analysis:
|
|
|
test.explain = HtmlHelper.DoUselessTag(content.ToString());
|
|
|
break;
|
|
|
+ case Taxonomy:
|
|
|
+ {
|
|
|
+ string taxonomy = HtmlHelper.DoUselessTag(content.ToString());
|
|
|
+ taxonomy= BlankTag(taxonomy);
|
|
|
+ if ( !string.IsNullOrWhiteSpace(taxonomy) && dict.TryGetValue(taxonomy, out string[] keyInfo))
|
|
|
+ {
|
|
|
+
|
|
|
+ var LangConfigfd = _TagConfig.LangConfig.Where(x => x.Lang ==keyInfo[0]).FirstOrDefault();
|
|
|
+ var Fileds = LangConfigfd.Item.Filed.Split('|');
|
|
|
+ int fld = Array.IndexOf(Fileds, taxonomy) + 1;
|
|
|
+ if (fld>0) {
|
|
|
+ test.field =fld;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
case Ended: break;
|
|
|
case Point:
|
|
|
string Points = BlankPointTag(content.ToString());
|
|
@@ -604,12 +671,19 @@ namespace HTEXLib.Translator
|
|
|
test.level = lvl;
|
|
|
break;
|
|
|
case Filed:
|
|
|
- if (dict.TryGetValue(openTagVal, out string[] keyInfo)) {
|
|
|
- var LangConfigfd = _TagConfig.LangConfig.Where(x => x.Lang == keyInfo[0]).FirstOrDefault();
|
|
|
- var Fileds= LangConfigfd.Item.Filed.Split('|');
|
|
|
- test.field = Array.IndexOf(Fileds, openTagVal) + 1;
|
|
|
+ {
|
|
|
+ if (dict.TryGetValue(openTagVal, out string[] keyInfo))
|
|
|
+ {
|
|
|
+ var LangConfigfd = _TagConfig.LangConfig.Where(x => x.Lang == keyInfo[0]).FirstOrDefault();
|
|
|
+ var Fileds = LangConfigfd.Item.Filed.Split('|');
|
|
|
+ int fld = Array.IndexOf(Fileds, openTagVal) + 1;
|
|
|
+ if (fld>0)
|
|
|
+ {
|
|
|
+ test.field =fld;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
- break;
|
|
|
case Count:
|
|
|
//只有填空题才配置填空数量
|
|
|
if (test.type.Equals("complete")) {
|