
from subprocess import Popen, PIPE
import subprocess as subp
import json
import re

regex = re.compile('}\s*{')

def parse (sentence, lang):
    '''Calls the freeling process to obtain the dependency parse of a text.'''
    config = "grafeno/freeling_deps_"+lang+".cfg"
    proc = Popen(["analyze", "--flush", "-f", config], stdin=PIPE, stdout=PIPE, stderr=PIPE)
    data, err = proc.communicate(sentence.encode('UTF-8'))
    return json.loads('['+regex.sub('},{',data.decode('UTF-8'))+']')


from subprocess import Popen, PIPE
import subprocess as subp
import os
import json
import re

regex = re.compile('}\s*{')

def parse (sentence, lang):
    '''Calls the freeling process to obtain the dependency parse of a text.'''
    config = os.path.dirname(__file__)+"/freeling_deps_"+lang+".cfg"
    proc = Popen(["analyze", "--flush", "-f", config], stdin=PIPE, stdout=PIPE, stderr=PIPE)
    data, err = proc.communicate(sentence.encode('UTF-8'))
    return json.loads('['+regex.sub('},{',data.decode('UTF-8'))+']')

Make freeling configuration available independent of execution path
Make freeling configuration available independent of execution path

  
  from subprocess import Popen, PIPE
  import subprocess as subp
+ import os
  import json
  import re
  
  regex = re.compile('}\s*{')
  
  def parse (sentence, lang):
      '''Calls the freeling process to obtain the dependency parse of a text.'''
-     config = "grafeno/freeling_deps_"+lang+".cfg"
+     config = os.path.dirname(__file__)+"/freeling_deps_"+lang+".cfg"
      proc = Popen(["analyze", "--flush", "-f", config], stdin=PIPE, stdout=PIPE, stderr=PIPE)
      data, err = proc.communicate(sentence.encode('UTF-8'))
      return json.loads('['+regex.sub('},{',data.decode('UTF-8'))+']')
  
Make freeling configuration available independent of execution path
## Code Before:

from subprocess import Popen, PIPE
import subprocess as subp
import json
import re

regex = re.compile('}\s*{')

def parse (sentence, lang):
    '''Calls the freeling process to obtain the dependency parse of a text.'''
    config = "grafeno/freeling_deps_"+lang+".cfg"
    proc = Popen(["analyze", "--flush", "-f", config], stdin=PIPE, stdout=PIPE, stderr=PIPE)
    data, err = proc.communicate(sentence.encode('UTF-8'))
    return json.loads('['+regex.sub('},{',data.decode('UTF-8'))+']')

## Instruction:
Make freeling configuration available independent of execution path
## Code After:

from subprocess import Popen, PIPE
import subprocess as subp
import os
import json
import re

regex = re.compile('}\s*{')

def parse (sentence, lang):
    '''Calls the freeling process to obtain the dependency parse of a text.'''
    config = os.path.dirname(__file__)+"/freeling_deps_"+lang+".cfg"
    proc = Popen(["analyze", "--flush", "-f", config], stdin=PIPE, stdout=PIPE, stderr=PIPE)
    data, err = proc.communicate(sentence.encode('UTF-8'))
    return json.loads('['+regex.sub('},{',data.decode('UTF-8'))+']')
