五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

Obsidian 英語(yǔ)生詞自動(dòng)引用自單詞庫(kù)

2023-06-11 09:11 作者:Pascalt  | 我要投稿
  1. from nltk.tokenize import word_tokenize
  2. from nltk.stem import WordNetLemmatizer
  3. from nltk.corpus import wordnet
  4. from nltk import pos_tag
  5. from pathlib import Path
  6. import pandas as pd
  7. import re


  8. def get_wordnet_pos(treebank_tag):
  9. if treebank_tag.startswith('J'):
  10. return wordnet.ADJ
  11. elif treebank_tag.startswith('V'):
  12. return wordnet.VERB
  13. elif treebank_tag.startswith('N'):
  14. return wordnet.NOUN
  15. elif treebank_tag.startswith('R'):
  16. return wordnet.ADV
  17. else:
  18. return None

  19. def main():
  20. obsidian_path = Path("C:/Users/insil/Desktop/英語(yǔ)") # obsidian倉(cāng)庫(kù)
  21. idx = obsidian_path / '首字母索引'
  22. article = obsidian_path / '閱讀理解 1.md'
  23. lemmatizer = WordNetLemmatizer()

  24. study_words = set()
  25. for i in idx.glob('*.md'):
  26. with open(i, encoding='utf-8') as f:
  27. words = f.readlines()
  28. words = pd.Series(words)
  29. words_df = words.str.extract(r' \[(?P<flag>\s)\] \[\[(?P<word>\w+)\]\]')
  30. words_df.dropna(inplace=True)
  31. words_set = set(words_df['word'])
  32. study_words = study_words.union(words_set)

  33. with open(article, 'r', encoding='utf-8') as f:
  34. txt = f.readlines()
  35. for p in range(len(txt)):
  36. if txt[p] != '\n':
  37. txt[p] = re.sub(r'\]\]', '', txt[p])
  38. txt[p] = re.sub(r'\[\[(\w+)\|', '', txt[p])
  39. txt_words2 = word_tokenize(txt[p])
  40. txt_words = word_tokenize(txt[p].lower())
  41. txt_words = pos_tag(txt_words)
  42. for word in range(len(txt_words)):
  43. if get_wordnet_pos(txt_words[word][1]):
  44. w = lemmatizer.lemmatize(txt_words[word][0], get_wordnet_pos(txt_words[word][1]))
  45. else:
  46. w = txt_words[word][1]
  47. if w in study_words:
  48. txt_words2[word] = f'[[{w}|{txt_words2[word]}]]'
  49. res = ' '.join(txt_words2)
  50. res += '\n'
  51. txt[p] = res
  52. with open(article, 'w', encoding='utf-8') as f:
  53. f.write(''.join(txt))


  54. if __name__ == '__main__':
  55. main()

Obsidian 英語(yǔ)生詞自動(dòng)引用自單詞庫(kù)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
禹城市| 泌阳县| 南靖县| 涡阳县| 沈阳市| 临高县| 达尔| 枞阳县| 麟游县| 秭归县| 漳州市| 合作市| 台山市| 荣成市| 鸡东县| 沈丘县| 绥滨县| 蕉岭县| 安庆市| 上杭县| 永安市| 光泽县| 岢岚县| 张掖市| 上饶县| 东方市| 宾川县| 滁州市| 正镶白旗| 永嘉县| 常山县| 巴彦淖尔市| 武宁县| 桦川县| 江华| 松溪县| 舞钢市| 萝北县| 林州市| 左贡县| 宽甸|