<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          我發(fā)起的第一個 Python 小項(xiàng)目,歡迎參與!

          共 2134字,需瀏覽 5分鐘

           ·

          2021-04-29 21:09

          你好,我是zhenguo

          把所學(xué)知識應(yīng)用于實(shí)際問題,才能真正加深對它的認(rèn)識和理解,這就是實(shí)踐出真知。從此最基本點(diǎn)出發(fā),我設(shè)計(jì)了一個小項(xiàng)目,蠻有意思,也有一定實(shí)際應(yīng)用價值。

          此小項(xiàng)目我會同步在github庫 python-small-examples中,目前近6100個star,歡迎提交pull request,有機(jī)會成為此庫的第13位貢獻(xiàn)者。

          https://github.com/jackzhenguo/python-small-examples

          進(jìn)行中Python小項(xiàng)目

          上下文關(guān)鍵字(KWIC, Key Word In Context)是最常見的多行協(xié)調(diào)顯示格式。

          此小項(xiàng)目描述:輸入一系列句子,給定一個給定單詞,每個句子中至少會出現(xiàn)一次給定單詞。目標(biāo)輸出,給定單詞按照KWIC顯示,KWIC顯示的基本要求:待查詢單詞居中,前面pre序列右對齊,后面post序列左對齊,待查詢單詞前和后長度相等,若輸入句子無法滿足要求,用空格填充。

          輸入?yún)?shù):輸入句子sentences, 待查詢單詞selword, 滑動窗口長度window_len

          舉例,輸入如下六個句子,給定單詞secure,輸出如下字符串:

                         pre keyword    post 

               welfare , and secure  the blessings of
               nations , and secured immortal glory with 
                 , and shall secure  to you the 
              cherished . To secure  us against these 
               defense as to secure  our cities and 
                    I can to secure  economy and fidelity 

          請補(bǔ)充實(shí)現(xiàn)下面函數(shù):

          def kwic(sentences: List[str], selword: str, window_len: int) -> str:
              """
              :type: sentences: input sentences
              :type: selword: selected word
              :type: window_len: window length
              """

          更多KWIC顯示參考如下:

          http://dep.chs.nihon-u.ac.jp/english_lang/tukamoto/kwic_e.html

          歡迎提交和互評解決方案

          這個小項(xiàng)目今天正式啟動,歡迎各位粉絲踴躍參加,fork我的python-small-examples庫,提交一個解,然后pull request,我會及時回復(fù),有機(jī)會成為此庫的貢獻(xiàn)者。

          參與討論,可以在這里留言:https://github.com/jackzhenguo/python-small-examples/issues

          也歡迎在我的知識星球里討論此小項(xiàng)目的解決方案,我也會同步并在星球里回復(fù)大家。

          此項(xiàng)目的至少一個解決方案,會在兩周內(nèi)公眾號里發(fā)布。


          掃碼加入

          瀏覽 75
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  免费日韩毛片 | 99精产秘 18 在线观看 | 精品内射一区 | 99精品视频网站 | 色色色色色色五月婷婷 |