<commit_before>" MIT License. Copyright (c) 2013-2018 <NAME> et al.
" vim: et ts=2 sts=2 sw=2 fdm=marker

scriptencoding utf-8

" get wordcount {{{1
if exists('*wordcount')
  function! s:get_wordcount(visual_mode_active)
    let query = a:visual_mode_active ? 'visual_words' : 'words'
    return get(wordcount(), query, 0)
  endfunction
else  " Pull wordcount from the g_ctrl-g stats
  function! s:get_wordcount(visual_mode_active)
    let pattern = a:visual_mode_active
          \ ? 'Lines; \zs\d\+\ze of \d\+ Words;'
          \ : 'Word \d\+ of \zs\d\+'

    let save_status = v:statusmsg
    if !a:visual_mode_active && col('.') == col('$')
      let save_pos = getpos('.')
      execute "silent normal! g\<c-g>"
      call setpos('.', save_pos)
    else
      execute "silent normal! g\<c-g>"
    endif
    let stats = v:statusmsg
    let v:statusmsg = save_status

    return str2nr(matchstr(stats, pattern))
  endfunction
endif

" format {{{1
let s:formatter = get(g:, 'airline#extensions#wordcount#formatter', 'default')

" wrapper function for compatibility; redefined below for old-style formatters
function! s:format_wordcount(wordcount)<commit_msg>wordcount: do not rely on english in old versions<commit_after>" MIT License. Copyright (c) 2013-2018 <NAME>.
" vim: et ts=2 sts=2 sw=2 fdm=marker

scriptencoding utf-8

" get wordcount {{{1
if exists('*wordcount')
  function! s:get_wordcount(visual_mode_active)
    let query = a:visual_mode_active ? 'visual_words' : 'words'
    return get(wordcount(), query, 0)
  endfunction
else  " Pull wordcount from the g_ctrl-g stats
  function! s:get_wordcount(visual_mode_active)
    let pattern = a:visual_mode_active
          \ ? '^.\D*\d\+\D\+\d\+\D\+\zs\d\+'
          \ : '^.\D*\%(\d\+\D\+\)\{5}\zs\d\+'

    let save_status = v:statusmsg
    if !a:visual_mode_active && col('.') == col('$')
      let save_pos = getpos('.')
      execute "silent normal! g\<c-g>"
      call setpos('.', save_pos)
    else
      execute "silent normal! g\<c-g>"
    endif
    let stats = v:statusmsg
    let v:statusmsg = save_status

    return str2nr(matchstr(stats, pattern))
  endfunction
endif

" format {{{1
let s:formatter = get(g:, 'airline#extensions#wordcount#formatter', 'default')

" wrapper function for compatibility; redefined below for old-style formatters
function! s:format_wordcount(wordcount)
{'fraction_non_alphanumeric': 0.1435244161358811, 'fraction_numerical': 0.014012738853503185, 'mean_word_length': 3.565891472868217, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5924460', 'n_tokens_mistral': 853, 'n_tokens_neox': 815, 'n_words': 212}