Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3.  
  4. import sys
  5. import re
  6. import os
  7.  
  8. def map(input):
  9. filename = os.path.basename(os.environ["map_input_file"])
  10. words = re.split('[\s,.]', input)
  11. return [(word, filename) for word in words if word]
  12.  
  13. def pipe(kv):
  14. for word, filename in kv:
  15. print('{0}\t{1}'.format(word,filename))
  16.  
  17. if __name__ == "__main__":
  18. for input in sys.stdin:
  19. kv = map(input)
  20. pipe(kv)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement