|
| 1 | +using System.Linq; |
| 2 | +using SignsOfAI.Core; |
| 3 | +using Xunit; |
| 4 | + |
| 5 | +namespace SignsOfAI.Core.Tests; |
| 6 | + |
| 7 | +/// <summary> |
| 8 | +/// The half of the conversation that was never meant to be in the document. |
| 9 | +/// |
| 10 | +/// Every other rule in this project is a judgement about style, and a formal writer can lose to any |
| 11 | +/// of them. These are not that. "I hope this helps" at the foot of an essay is not a register the |
| 12 | +/// student chose; it is an assistant's closing line, pasted in with the answer — the same kind of |
| 13 | +/// claim the character scanner makes, about where the file has been rather than about who is |
| 14 | +/// talented. |
| 15 | +/// |
| 16 | +/// That is also why this batch was admissible when most of the pattern set it came from was not. |
| 17 | +/// The rules were screened against the calibration corpus first — 249,455 words of English and |
| 18 | +/// 39,712 of Spanish, all published before generative models existed — and every one of them scored |
| 19 | +/// zero. Re-running the calibration afterwards left the published false-positive rate untouched, |
| 20 | +/// which is the point: they cost nothing to carry. |
| 21 | +/// |
| 22 | +/// The mine they came from is amanmaqsood/prose-humanizer (MIT). Twelve of its other candidates |
| 23 | +/// were rejected here by the same screen: underpin, optimize, elucidate, paradigm, exemplify and |
| 24 | +/// illuminate are ordinary research English, and each appears in three to six of those ninety texts. |
| 25 | +/// </summary> |
| 26 | +public class ChatResidueTests |
| 27 | +{ |
| 28 | + private readonly AiWritingAnalyzer _a = new(); |
| 29 | + |
| 30 | + private bool Has(string text, string lang, string ruleId) => |
| 31 | + _a.Analyze(text, lang).Findings.Any(f => f.RuleId == ruleId); |
| 32 | + |
| 33 | + [Theory] |
| 34 | + [InlineData("As an AI language model, I should note that the figures are indicative.", "chat.model-self-reference")] |
| 35 | + [InlineData("As of my last training update, the tidal survey had not been repeated.", "chat.training-cutoff")] |
| 36 | + [InlineData("The wall was built in 1971. I hope this helps.", "chat.signoff")] |
| 37 | + [InlineData("Would you like me to expand the section on sediment transport?", "chat.signoff")] |
| 38 | + [InlineData("I cannot browse the internet, so the citation below is from memory.", "chat.capability-disclaimer")] |
| 39 | + [InlineData("Here is the revised version of your essay on coastal erosion.", "chat.answer-preamble")] |
| 40 | + [InlineData("Certainly! The coastline retreated by nine metres.", "chat.eager-opener")] |
| 41 | + public void Flags_the_assistants_own_turn_en(string text, string ruleId) => |
| 42 | + Assert.True(Has(text, "en", ruleId), ruleId); |
| 43 | + |
| 44 | + [Theory] |
| 45 | + [InlineData("Como modelo de lenguaje, debo señalar que las cifras son indicativas.", "chat.model-self-reference")] |
| 46 | + [InlineData("Hasta mi última actualización, el estudio no se había repetido.", "chat.training-cutoff")] |
| 47 | + [InlineData("El muro se construyó en 1971. Espero que esto te ayude.", "chat.signoff")] |
| 48 | + [InlineData("¿Quieres que amplíe el apartado sobre el transporte de sedimentos?", "chat.signoff")] |
| 49 | + [InlineData("No tengo acceso a información en tiempo real sobre las mareas.", "chat.capability-disclaimer")] |
| 50 | + [InlineData("Aquí tienes la versión reescrita de tu ensayo sobre la erosión costera.", "chat.answer-preamble")] |
| 51 | + [InlineData("¡Por supuesto! La costa retrocedió nueve metros.", "chat.eager-opener")] |
| 52 | + public void Flags_the_assistants_own_turn_es(string text, string ruleId) => |
| 53 | + Assert.True(Has(text, "es", ruleId), ruleId); |
| 54 | + |
| 55 | + /// <summary> |
| 56 | + /// The regexes have to leave ordinary writing alone, and two of them are close to sentences a |
| 57 | + /// person really writes. A tutor's own feedback says "let me know" and a historian writes "of |
| 58 | + /// course" mid-sentence; neither is an assistant handing back an answer. |
| 59 | + /// </summary> |
| 60 | + [Theory] |
| 61 | + [InlineData("Let me know when the survey is finished and I will read it.", "chat.signoff")] |
| 62 | + [InlineData("The wall was, of course, built long before the survey began.", "chat.eager-opener")] |
| 63 | + [InlineData("I hope the council publishes the survey before the winter.", "chat.signoff")] |
| 64 | + [InlineData("Here is the revised timetable the committee agreed on Tuesday.", "chat.answer-preamble")] |
| 65 | + public void Leaves_a_person_writing_to_a_person_alone_en(string text, string ruleId) => |
| 66 | + Assert.False(Has(text, "en", ruleId), ruleId); |
| 67 | + |
| 68 | + [Theory] |
| 69 | + [InlineData("Avísame cuando termine el estudio y lo leo.", "chat.signoff")] |
| 70 | + [InlineData("El muro, por supuesto, se construyó mucho antes del estudio.", "chat.eager-opener")] |
| 71 | + [InlineData("Aquí tienes el calendario que acordó la comisión el martes.", "chat.answer-preamble")] |
| 72 | + public void Leaves_a_person_writing_to_a_person_alone_es(string text, string ruleId) => |
| 73 | + Assert.False(Has(text, "es", ruleId), ruleId); |
| 74 | + |
| 75 | + /// <summary> |
| 76 | + /// A rule that fires on nothing measured is a rule with no measured human rate, and the pack |
| 77 | + /// must keep saying so rather than inventing one. See <c>PatternRule.HumanRatePer1000</c>: an |
| 78 | + /// absent rate means "never observed", which is what these are, and a rate of zero would be a |
| 79 | + /// different and much stronger claim. |
| 80 | + /// </summary> |
| 81 | + [Theory] |
| 82 | + [InlineData("en")] |
| 83 | + [InlineData("es")] |
| 84 | + public void The_new_rules_claim_no_human_rate(string lang) |
| 85 | + { |
| 86 | + var pack = SignsOfAI.Core.Rules.RulePackLoader.Load(lang); |
| 87 | + var chat = pack.Patterns.Where(p => p.Id.StartsWith("chat.")).ToList(); |
| 88 | + |
| 89 | + Assert.Equal(6, chat.Count); |
| 90 | + Assert.All(chat, rule => Assert.Null(rule.HumanRatePer1000)); |
| 91 | + Assert.All(chat, rule => Assert.False(string.IsNullOrWhiteSpace(rule.Evidence), rule.Id)); |
| 92 | + } |
| 93 | +} |
0 commit comments