2014-05-10 27 views
-3

因此,我發現this code來自here由Nigel Garvey,我想添加一個類似於set wordsToIgnore to {"and", "the", "a", "for", "in", "is"}類似的忽略列表。問題是我在這些事情上通常無能。能不能容忍的權力,並告訴我如何添加一個忽略列表?我已經試過各種型號頻率計數的,但是這一次給出了文本編輯正確風格的輸出,並能輸出的話砍倒在一個給定的數字,但缺乏忽略某些單詞的能力。最好的祝福。Noob茫然無望

編輯:我做了類似的標籤後較早,但因爲我是用不同的腳本工作,我想最好還是開始一個新的職位。如果我錯了我的道歉。

+0

爲什麼要添加另一組?爲什麼不擴展現有的? – Dair

+0

我沒有看到哪裏有電流忽略列表,但是這可能是因爲我不知道我在看你。我已經看了幾個小時,但這些都是我不知道的。建議? – DrLulz

+2

引述如何提問智能路:卑躬屈膝是不是做功課的替代品(http://www.catb.org/esr/faqs/smart-questions.html#idp54052224)。 –

回答

0

我沒有測試這一點,但快看這裏以後就是我的想法。將「on main(pdfFile)」處理程序中的此部分更改爲以下內容...

-- Go through the sorted list, counting the instances of each word. Store each word and its score in a list in the 'scores' list in the script object above. 
set wordsToIgnore to {"and", "the", "a", "for", "in", "is"} 
set currentWord to item 1 of o's wrds 
set c to 1 
repeat with i from 2 to (count o's wrds) 
    set thisWord to item i of o's wrds 
    if thisWord is not in wordsToIgnore then 
     if (thisWord is currentWord) then 
      set c to c + 1 
     else 
      set end of o's scores to {currentWord, c} 
      set currentWord to thisWord 
      set c to 1 
     end if 
    end if 
end repeat 
set end of o's scores to {currentWord, c} 
+0

先生,你是一個紳士和學者。多謝。 – DrLulz

+0

我剛剛注意到你是上面的macscripter線程中的原始海報之一。挺酷的。再次感謝。 – DrLulz

+0

是的,不幸的是,該線程中腳本中的「調用方法」代碼不再有效。因此,您需要使用第三方應用程序(Skim)從pdf中提取文本。但它的工作。樂意效勞。祝你好運。 – regulus6633