#!/usr/bin/env python3 """登记 200 条常见**口语语法错误**到 me/lang.db 的 grammar_fixes 表。 格式:category||issue||rule||examples(✗ 错 → ✓ 对) id = g-<5位数字>(不含 0);status = learning。 用法: python actions/import_grammar_errors.py """ from __future__ import annotations import datetime as _dt import sys from pathlib import Path ROOT = Path(__file__).resolve().parent.parent sys.path.insert(0, str(Path(__file__).resolve().parent)) import langdb # noqa: E402 from import_wordlists import no0_numbers # noqa: E402 RAW = """ 主谓一致||第三人称单数漏 -s||he/she/it + 动词加 -s;否定用 doesn't||✗ he don't know → ✓ he doesn't know 主谓一致||第三人称单数 have→has||he/she/it 用 has||✗ she have a car → ✓ she has a car 主谓一致||they/we/you was||复数主语用 were||✗ they was late → ✓ they were late 主谓一致||you was||you 一律用 were||✗ you was right → ✓ you were right 主谓一致||there is + 复数||复数名词用 there are||✗ there is many people → ✓ there are many people 主谓一致||each/every + 复数动词||each/every 后接单数动词||✗ every student have a book → ✓ every student has a book 主谓一致||neither of ... + 复数动词||neither of + 复数名词,动词用单数||✗ neither of them are here → ✓ neither of them is here 主谓一致||a number of ... + 单数动词||a number of + 复数名词,动词用复数||✗ a number of people is coming → ✓ are coming 主谓一致||the number of ... + 复数动词||the number of + 复数名词,动词用单数||✗ the number of cars are rising → ✓ is rising 主谓一致||one of the + 复数名词 + 单数动词||one of the Xs + 单数动词||✗ one of my friends are here → ✓ is here 主谓一致||主语后插入语不影响动词||with/along with 不改变动词数||✗ the teacher with the students are → ✓ is 主谓一致||either ... or 就近原则||either A or B 由 B 决定动词||✗ either you or he are wrong → ✓ is wrong 时态||一般过去误用原形||过去时间用过去式||✗ yesterday I go there → ✓ went there 时态||不规则动词过去式||eat→ate, go→went, take→took||✗ I goed → ✓ I went 时态||since + 一般过去||since 引导用现在完成||✗ I live here since 2010 → ✓ I have lived 时态||for + 时间段误用过去||for + 时间段常配完成时||✗ I know him for ten years → ✓ have known 时态||already/just 与完成时||already/just 常配完成时||✗ I already ate → ✓ I have already eaten 时态||yet 用于否定/疑问||yet 配完成时||✗ I didn't finish yet → ✓ haven't finished yet 时态||过去完成漏用||先发生的过去动作用 had + 过去分词||✗ he leave before I came → ✓ had left 时态||现在完成 + 过去时间||完成时不能配明确过去时间||✗ I have seen him yesterday → ✓ saw him yesterday 时态||静态动词用进行时||know/like/believe 一般不用进行时||✗ I am knowing the answer → ✓ I know 时态||时间从句误用将来||when/after/before 从句用现在时||✗ when I will arrive → ✓ when I arrive 时态||条件从句误用将来||if 从句用现在时||✗ if it will rain → ✓ if it rains 时态||主将从现||主句将来,从句现在||✗ I will call you when I will get home → ✓ when I get home 时态||进行时漏 be||进行时 be + doing||✗ I going now → ✓ I am going now 时态||完成时漏 have||完成时 have + 过去分词||✗ I finished already → ✓ I have finished 时态||过去分词误用过去式||have + 过去分词||✗ I have went → ✓ I have gone 时态||was/were + 过去分词||被动/完成用过去分词||✗ it was wrote → ✓ it was written 时态||进行时误用原形||be + 现在分词||✗ he is go → ✓ he is going 冠词||单数可数名词漏冠词||单数可数名词前加 a/the||✗ I have car → ✓ I have a car 冠词||泛指误用 the||首次泛指用 a/an||✗ I saw the dog in the park (泛指) → ✓ a dog 冠词||特指漏 the||特指/再次提到用 the||✗ open door → ✓ open the door 冠词||不可数名词加 a||不可数名词不加 a/an||✗ a information → ✓ information 冠词||a/an 按音素选择||元音音素用 an||✗ a hour → ✓ an hour 冠词||a 后接元音音素||辅音音素用 a||✗ an university → ✓ a university 冠词||三餐/球类/学科前不加 the||have breakfast / play football||✗ play the football → ✓ play football 冠词||乐器前加 the||play the piano||✗ play piano → ✓ play the piano 冠词||独一无二事物加 the||the sun / the moon||✗ sun is bright → ✓ the sun 冠词||固定短语的冠词||go to school / at night / by bus||✗ by the bus → ✓ by bus 冠词||the + 形容词表一类||the rich / the young||✗ rich should help poor → ✓ the rich … the poor 名词数||不可数名词加 s||information/advice/furniture 不加 s||✗ informations → ✓ information 名词数||advice 不可数||a piece of advice||✗ an advice → ✓ a piece of advice 名词数||furniture 不可数||a piece of furniture||✗ furnitures → ✓ furniture 名词数||equipment 不可数||a piece of equipment||✗ equipments → ✓ equipment 名词数||news 不可数||a piece of news||✗ a news → ✓ a piece of news 名词数||homework 不可数||homework 不加 s||✗ homeworks → ✓ homework 名词数||bread 不可数||two pieces/loaves of bread||✗ two breads → ✓ two pieces of bread 名词数||money 不可数||much money||✗ many money → ✓ much money 名词数||people 复数||people 本身是复数||✗ much people → ✓ many people 名词数||复合名词复数||mothers-in-law||✗ mother-in-laws → ✓ mothers-in-law 名词数||fish/sheep 单复同形||two fish / two sheep||✗ two fishes(种类除外)→ ✓ two fish 名词数||this/these 单复一致||this + 单数,these + 复数||✗ these book → ✓ these books 名词数||a pair of 后接复数||a pair of shoes||✗ a pair of shoe → ✓ a pair of shoes 代词||主格宾格误用||主语用主格||✗ me and him went → ✓ he and I went 代词||between you and I||介词后用宾格||✗ between you and I → ✓ between you and me 代词||it's 与 its 混用||it's = it is;its 所有格||✗ the dog lost it's bone → ✓ its bone 代词||your 与 you're 混用||your 所有格;you're = you are||✗ your welcome → ✓ you're welcome 代词||their/there/they're 混用||their 所有格;there 那里;they're = they are||✗ there going → ✓ they're going 代词||反身代词误用||I/me 误用 myself||✗ my friend and myself went → ✓ my friend and I went 代词||each other 与 oneself||each other 互相||✗ they help themselves(互相)→ ✓ each other 代词||who 与 whom||whom 作宾语||✗ who did you see → ✓ whom did you see 代词||指代不明||代词要有明确先行词||✗ when I met John, he said …(he 指谁?) → ✓ 明确 代词||everyone 后接单数动词||everyone/everybody + 单数||✗ everyone are here → ✓ everyone is here 比较||双重比较||more + 比较级不叠用||✗ more better → ✓ better 比较||双重最高级||most + 最高级不叠用||✗ the most easiest → ✓ the easiest 比较||as ... as 结构||as + 原级 + as||✗ as taller as → ✓ as tall as 比较||比较级 + than||比较级配 than||✗ taller then him → ✓ taller than he is 比较||less 与 fewer||可数用 fewer||✗ less people → ✓ fewer people 比较||much 修饰比较级||much/a lot + 比较级||✗ very better → ✓ much better 比较||the more ... the more||越…越…||✗ more you practice, more better → ✓ the more you practice, the better 比较||最高级加 the||最高级前 the||✗ he is best student → ✓ the best student 语序||疑问句语序||疑问句助动词提前||✗ where you are going → ✓ where are you going 语序||宾语从句用陈述语序||从句用陈述语序||✗ I don't know where is he → ✓ where he is 语序||副词位置||频度副词在实义动词前||✗ I like very much it → ✓ I like it very much 语序||always/never 位置||在 be 后、实义动词前||✗ he always is late → ✓ he is always late 语序||enough 位置||形容词/副词后、名词前||✗ enough good → ✓ good enough 语序||only 位置影响句意||only 修饰谁放谁前||✗ I only have one dollar(歧义)→ ✓ 明确 语序||too ... to 结构||too + 形容词 + to do||✗ too much tired to go → ✓ too tired to go 语序||疑问词+不定式||how to do 作宾语||✗ I don't know how can I do → ✓ how to do it 情态||should/would + 原形||情态动词后接原形||✗ I should to go → ✓ I should go 情态||must 与 have to||must 主观;have to 客观||✗ I must to work tomorrow(客观)→ ✓ have to 情态||can 与 be able to||将来用 will be able to||✗ I will can do it → ✓ will be able to 情态||would like to||would like + to do||✗ I would like go → ✓ I would like to go 情态||need not 与 don't need to||needn't do = don't need to do||✗ you needn't to go → ✓ needn't go 情态||used to 与 be used to||used to do 过去常常;be used to doing 习惯于||✗ I used to getting up early(过去常常)→ ✓ used to get 情态||had better + 原形||had better do||✗ you had better to rest → ✓ had better rest 情态||may/might 表可能||might 更不确定||✗ he may be there(弱)→ 视语气选 might 情态||mustn't 与 needn't||mustn't 禁止;needn't 不必||✗ you mustn't hurry(不必)→ ✓ needn't 情态||shall 的用法||shall I/we 提议||✗ Shall you help me → ✓ Will you help me 虚拟||if I were you||虚拟用 were||✗ if I was you → ✓ if I were you 虚拟||wish + 过去式||wish 后虚拟||✗ I wish I am rich → ✓ I wish I were rich 虚拟||suggest + (should) 原形||suggest that sb (should) do||✗ I suggest him to go → ✓ suggest that he (should) go 虚拟||insist/demand + 原形||insist/demand that sb do||✗ he insisted me to stay → ✓ insisted that I (should) stay 虚拟||it's time + 过去式||It's time sb did||✗ it's time we go → ✓ it's time we went 虚拟||would rather + 过去式||would rather sb did||✗ I'd rather you come → ✓ came 虚拟||as if + 过去式||as if 虚拟||✗ he talks as if he is boss → ✓ as if he were boss 虚拟||if 虚拟三段||过去→had done/would have done||✗ if I had known, I will tell you → ✓ would have told 非谓语||enjoy + doing||enjoy 后接动名词||✗ I enjoy to read → ✓ enjoy reading 非谓语||finish + doing||finish 后接动名词||✗ I finished to work → ✓ finished working 非谓语||avoid + doing||avoid 后接动名词||✗ avoid to make mistakes → ✓ avoid making 非谓语||mind + doing||mind 后接动名词||✗ do you mind to open → ✓ mind opening 非谓语||look forward to + doing||to 是介词||✗ I look forward to see you → ✓ to seeing you 非谓语||want + to do||want 后接不定式||✗ I want going → ✓ want to go 非谓语||suggest + doing||suggest doing(或 that 从句)||✗ I suggest to go → ✓ suggest going 非谓语||make/let + 原形||使役动词后省 to||✗ he made me to cry → ✓ made me cry 非谓语||help + (to) do||help 后 to 可省||✗ he helped me doing → ✓ (to) do 非谓语||介词后接动名词||介词 + doing||✗ I'm interested in learn → ✓ in learning 非谓语||stop 后 to do/doing 义异||stop to do 停下来去做;stop doing 停止||✗ I stopped to smoke(戒烟)→ ✓ stopped smoking 非谓语||remember 后 to do/doing 义异||remember to do 记得去做;remember doing 记得做过||✗ remember to lock(已锁)→ ✓ remember locking 非谓语||forget 后 to do/doing 义异||forget to do 忘记去做;forget doing 忘记做过||✗ I forgot to see him(见过)→ ✓ forgot seeing 非谓语||need + doing 表被动||need doing = need to be done||✗ the car needs to repair → ✓ needs repairing 形容词副词||副词修饰动词||动作方式用副词||✗ he runs quick → ✓ runs quickly 形容词副词||系动词后接形容词||feel/look/sound + 形容词||✗ I feel badly → ✓ feel bad 形容词副词||good 与 well||well 作副词/健康||✗ he sings good → ✓ sings well 形容词副词||hard 与 hardly||hardly 几乎不||✗ he works hardly → ✓ works hard 形容词副词||late 与 lately||lately 最近||✗ he came lately → ✓ came late 形容词副词||so 与 such||such + 名词;so + 形容词||✗ so beautiful day → ✓ such a beautiful day 形容词副词||too 与 very||too 表过分||✗ he is too kind(很)→ ✓ very kind 形容词副词||interesting 与 interested||物 interesting;人 interested||✗ I'm boring → ✓ I'm bored 形容词副词||a few 与 few||a few 有几个;few 几乎没有||✗ few friends came(有几个)→ ✓ a few 形容词副词||a little 与 little||a little 有一点;little 几乎没有||✗ little money left(还有一点)→ ✓ a little 形容词副词||-ed 与 -ing 形容词||✗ the news is excited → ✓ exciting 形容词副词||比较级修饰||much/far/even + 比较级||✗ more easier → ✓ much easier 连词||although 与 but 不并用||although ... , 不用 but||✗ although he is old, but he works → ✓ although he is old, he works 连词||because 与 so 不并用||because ... , 不用 so||✗ because it rained, so we stayed → ✓ because it rained, we stayed 连词||关联连词成对||both ... and / either ... or||✗ both A as well as B → ✓ both A and B 连词||not only ... but also||结构一致||✗ not only he sings but also dances → ✓ not only does he sing but he also dances 连词||并列结构一致||并列成分同形||✗ I like swimming and to run → ✓ swimming and running 连词||while 表对比/同时||表对比用 while||✗ while I like tea, she likes coffee(对比 ok)→ ✓ 连词||and 连接时态一致||✗ he came and sit down → ✓ sat down 从句||关系代词 who/which||人用 who,物用 which/that||✗ the man which called → ✓ who called 从句||关系代词漏掉||定语从句需关系词||✗ the book I bought it is good → ✓ the book I bought is good 从句||关系副词 where/when||先行词是地点/时间||✗ the place which I live → ✓ where I live 从句||whose 所有格||whose + 名词||✗ the man who his car was stolen → ✓ whose car 从句||if 与 whether||介词后/不定式用 whether||✗ it depends on if → ✓ on whether 从句||that 从句不缺成分||that 作宾语可省||✗ the thing that I need it → ✓ that I need 从句||宾语从句时态呼应||主过去从过去(真理除外)||✗ he said he is busy → ✓ he was busy 从句||客观真理用现在||主过去但从现在||✗ he said the earth moved → ✓ moves 否定||否定转移||I don't think + 肯定从句||✗ I think he isn't right → ✓ I don't think he is right 否定||no 与 not||no + 名词;not + 动词/形容词||✗ I have not money → ✓ no money 否定||none 与 no one||none of + 复数;no one 无人||✗ none of them is here(人)→ ✓ no one is here 否定||neither 与 nor||neither ... nor||✗ neither he or I → ✓ neither he nor I 否定||hardly ... when||hardly had ... when||✗ hardly I arrived when → ✓ hardly had I arrived when 否定||all/both 的部分否定||not all / not both||✗ all is not gold(歧义)→ ✓ not all that glitters is gold 中式||open/close the light||开/关灯用 turn on/off||✗ open the light → ✓ turn on the light 中式||how to say||问说法用 How do you say||✗ how to say this in English → ✓ how do you say 中式||very like||like ... very much||✗ I very like it → ✓ I like it very much 中式||I'm agree||agree 是动词||✗ I'm agree with you → ✓ I agree with you 中式||borrow me||借出用 lend||✗ can you borrow me money → ✓ lend me 中式||learn knowledge||获得知识用 gain||✗ learn knowledge → ✓ gain knowledge 中式||very thank you||thank you very much||✗ very thank you → ✓ thank you very much 中式||do a mistake||make a mistake||✗ do a mistake → ✓ make a mistake 中式||do a decision||make a decision||✗ do a decision → ✓ make a decision 中式||take a rest||take a break/rest||✗ take a rest(可)→ ✓ take a break 中式||say me||tell me||✗ say me the truth → ✓ tell me 中式||discuss about||discuss 及物||✗ discuss about it → ✓ discuss it 中式||enter into the room||enter 及物||✗ enter into the room → ✓ enter the room 中式||marry with||marry sb||✗ she married with him → ✓ married him 中式||reply my email||reply to||✗ reply my email → ✓ reply to my email 中式||explain me||explain to me||✗ explain me this → ✓ explain this to me 中式||go to home||go home||✗ go to home → ✓ go home 中式||go to abroad||go abroad||✗ go to abroad → ✓ go abroad 中式||in the same time||at the same time||✗ in the same time → ✓ at the same time 中式||in the other hand||on the other hand||✗ in the other hand → ✓ on the other hand 中式||on the phone||on the phone(对)||✗ by the phone → ✓ on the phone 中式||use the phone||对||✗ play the phone → ✓ use the phone 介词||arrive to||arrive at/in||✗ arrive to the station → ✓ arrive at 介词||depend of||depend on||✗ it depends of you → ✓ depends on 介词||listen music||listen to music||✗ listen music → ✓ listen to music 介词||in Monday||星期用 on||✗ in Monday → ✓ on Monday 介词||on the morning||早晨用 in||✗ on the morning → ✓ in the morning 介词||interested of||interested in||✗ interested of music → ✓ in music 介词||good in||good at||✗ good in math → ✓ good at 介词||different than||different from||✗ different than → ✓ different from 介词||afraid of||afraid of doing||✗ afraid to dogs → ✓ afraid of dogs 介词||angry with people||对人生气用 with||✗ angry on him → ✓ angry with him 介词||married to||married to sb||✗ married with → ✓ married to 介词||contact with||contact sb(及物)||✗ contact with me → ✓ contact me 介词||ask to me||ask me||✗ he asked to me → ✓ asked me 介词||apologize to sb for sth||搭配||✗ apologize him → ✓ apologize to him 介词||provide sb with sth||搭配||✗ provide sb sth(口语可)→ ✓ provide sb with 介词||congratulate sb on||搭配||✗ congratulate you for → ✓ on 介词||spend time on/in||搭配||✗ spend time to → ✓ on/in 介词||on the internet||对||✗ in the internet → ✓ on the internet 介词||at night / at noon||固定搭配||✗ in the night → ✓ at night 介词||by car / on foot||交通方式||✗ by foot → ✓ on foot 介词||between 与 among||两者 between;多者 among||✗ between the three → ✓ among the three 介词||because 与 because of||because + 从句;because of + 名词||✗ because of it rained → ✓ because it rained 时态||be going to 与 will||计划用 be going to;临时决定用 will||✗ I will visit my aunt next week(已计划)→ ✓ am going to 时态||间接引语时态后移||will→would, can→could||✗ he said he will come → ✓ he would come 时态||would 与 used to||would 表过去习惯(非状态)||✗ I would have a dog(过去拥有)→ ✓ used to have 时态||现在完成进行时||动作持续到现在||✗ I am reading since morning → ✓ I have been reading 时态||过去完成与一般过去顺序||先发生用过去完成||✗ when I arrived, he left → ✓ had left 冠词||a 与 one||one 强调数量||✗ I need one pen(泛指)→ ✓ a pen 冠词||再次提及用 the||首次 a,再次 the||✗ I bought a book. A book is good → ✓ The book 语序||also 位置||also 在 be 后、实义动词前||✗ I also am tired → ✓ I am also tired 语序||never 置首倒装||Never have I …||✗ Never I have seen → ✓ Never have I seen 语序||not until 倒装||Not until … did …||✗ Not until then I realized → ✓ did I realize 代词||one/ones 代替||避免重复名词||✗ the blue car → ✓ the blue one 代词||whose 与 who's||whose 所有格;who's = who is||✗ who's book is this → ✓ whose book 名词||police 复数||police 作复数||✗ the police is coming → ✓ are coming 名词||clothes 复数||clothes 作复数||✗ this clothes is new → ✓ these clothes are 名词||people 与 peoples||peoples 指民族||✗ many peoples(人)→ ✓ many people 连词||so that 与 so||目的用 so that||✗ I left early so I catch the bus → ✓ so that I could 连词||unless 与 if not||unless = if not||✗ unless you don't hurry → ✓ unless you hurry 从句||the reason is that||不用 because 作表语从句||✗ the reason is because → ✓ the reason is that 拼写混||then 与 than||than 比较;then 然后||✗ better then that → ✓ better than that 拼写混||to/too/two||too 也/太;two 二||✗ me to → ✓ me too 拼写混||lose 与 loose||lose 丢失;loose 松||✗ don't loose it → ✓ lose 拼写混||advise 与 advice||advise 动词;advice 名词||✗ give me some advise → ✓ advice 拼写混||affect 与 effect||affect 动词;effect 名词||✗ it effected me → ✓ affected 拼写混||lie 与 lay||lie 躺(lie-lay-lain);lay 放(lay-laid-laid)||✗ lay down on the bed → ✓ lie down 拼写混||rise 与 raise||rise 不及物;raise 及物||✗ raise up early → ✓ rise early """ def main() -> int: for st in (sys.stdout, sys.stderr): try: st.reconfigure(encoding="utf-8") except (AttributeError, ValueError): pass rows = [] for ln in RAW.strip().splitlines(): ln = ln.strip() if not ln or "||" not in ln: continue parts = ln.split("||") if len(parts) != 4: continue cat, issue, rule, ex = [p.strip() for p in parts] rows.append({"category": cat, "issue": issue, "rule": rule, "examples": ex}) today = _dt.date.today().isoformat() nums = no0_numbers() grammar = [] for r in rows: grammar.append({ "id": "g-" + next(nums), "category": r["category"], "issue": r["issue"], "rule": r["rule"], "examples": r["examples"], "status": "learning", "count": 0, "first": today, "last": today, "next_review": None, }) conn = langdb.connect() n = langdb.ingest(conn, {"grammar": grammar}) total = conn.execute("SELECT COUNT(*) FROM grammar_fixes").fetchone()[0] conn.close() print(f"登记语法错误 {n['grammar']} 条;grammar_fixes 现有 {total} 条") print("id:", grammar[0]["id"], "→", grammar[-1]["id"]) return 0 if __name__ == "__main__": sys.exit(main())