
import fileinput
import json
import os.path

from dstruct import Sentence

## BASE_DIR denotes the application directory
BASE_DIR, throwaway = os.path.split(os.path.realpath(__file__))
BASE_DIR = os.path.realpath(BASE_DIR + "/../..")


## Return the start and end indexes of all subsets of words in the sentence
## sent, with size at most max_phrase_length
def get_all_phrases_in_sentence(sent, max_phrase_length):
    for start in range(len(sent.words)):
        for end in reversed(range(start + 1, min(len(sent.words), start + 1 + max_phrase_length))):
            yield (start, end)

## Return Sentence objects from input lines
def get_input_sentences(input_files=[]):
    for line in fileinput.input(input_files):
        sent_dict = json.loads(line)
        yield Sentence(sent_dict["doc_id"], sent_dict["sent_id"],
                sent_dict["wordidxs"], sent_dict["words"],
                sent_dict["poses"], sent_dict["ners"], sent_dict["lemmas"],
                sent_dict["dep_paths"], sent_dict["dep_parents"],
                sent_dict["bounding_boxes"])



import fileinput
import json
import os.path
import sys

from dstruct.Sentence import Sentence

## BASE_DIR denotes the application directory
BASE_DIR, throwaway = os.path.split(os.path.realpath(__file__))
BASE_DIR = os.path.realpath(BASE_DIR + "/../..")


## Return the start and end indexes of all subsets of words in the sentence
## sent, with size at most max_phrase_length
def get_all_phrases_in_sentence(sent, max_phrase_length):
    for start in range(len(sent.words)):
        for end in reversed(range(start + 1, min(len(sent.words), start + 1 + max_phrase_length))):
            yield (start, end)

## Return Sentence objects from input lines
def get_input_sentences(input_files=sys.argv[1:]):
    with fileinput.input(files=input_files) as f:
        for line in f:
            sent_dict = json.loads(line)
            yield Sentence(sent_dict["doc_id"], sent_dict["sent_id"],
                    sent_dict["wordidxs"], sent_dict["words"],
                    sent_dict["poses"], sent_dict["ners"], sent_dict["lemmas"],
                    sent_dict["dep_paths"], sent_dict["dep_parents"],
                    sent_dict["bounding_boxes"])


Fix import, use fileinput.iput as context, and fix its argument
Fix import, use fileinput.iput as context, and fix its argument

  
  import fileinput
  import json
  import os.path
+ import sys
  
- from dstruct import Sentence
+ from dstruct.Sentence import Sentence
  
  ## BASE_DIR denotes the application directory
  BASE_DIR, throwaway = os.path.split(os.path.realpath(__file__))
  BASE_DIR = os.path.realpath(BASE_DIR + "/../..")
  
  
  ## Return the start and end indexes of all subsets of words in the sentence
  ## sent, with size at most max_phrase_length
  def get_all_phrases_in_sentence(sent, max_phrase_length):
      for start in range(len(sent.words)):
          for end in reversed(range(start + 1, min(len(sent.words), start + 1 + max_phrase_length))):
              yield (start, end)
  
  ## Return Sentence objects from input lines
- def get_input_sentences(input_files=[]):
+ def get_input_sentences(input_files=sys.argv[1:]):
-     for line in fileinput.input(input_files):
+     with fileinput.input(files=input_files) as f:
+         for line in f:
-         sent_dict = json.loads(line)
+             sent_dict = json.loads(line)
-         yield Sentence(sent_dict["doc_id"], sent_dict["sent_id"],
+             yield Sentence(sent_dict["doc_id"], sent_dict["sent_id"],
-                 sent_dict["wordidxs"], sent_dict["words"],
+                     sent_dict["wordidxs"], sent_dict["words"],
-                 sent_dict["poses"], sent_dict["ners"], sent_dict["lemmas"],
+                     sent_dict["poses"], sent_dict["ners"], sent_dict["lemmas"],
-                 sent_dict["dep_paths"], sent_dict["dep_parents"],
+                     sent_dict["dep_paths"], sent_dict["dep_parents"],
-                 sent_dict["bounding_boxes"])
+                     sent_dict["bounding_boxes"])
  
  
Fix import, use fileinput.iput as context, and fix its argument
## Code Before:

import fileinput
import json
import os.path

from dstruct import Sentence

## BASE_DIR denotes the application directory
BASE_DIR, throwaway = os.path.split(os.path.realpath(__file__))
BASE_DIR = os.path.realpath(BASE_DIR + "/../..")


## Return the start and end indexes of all subsets of words in the sentence
## sent, with size at most max_phrase_length
def get_all_phrases_in_sentence(sent, max_phrase_length):
    for start in range(len(sent.words)):
        for end in reversed(range(start + 1, min(len(sent.words), start + 1 + max_phrase_length))):
            yield (start, end)

## Return Sentence objects from input lines
def get_input_sentences(input_files=[]):
    for line in fileinput.input(input_files):
        sent_dict = json.loads(line)
        yield Sentence(sent_dict["doc_id"], sent_dict["sent_id"],
                sent_dict["wordidxs"], sent_dict["words"],
                sent_dict["poses"], sent_dict["ners"], sent_dict["lemmas"],
                sent_dict["dep_paths"], sent_dict["dep_parents"],
                sent_dict["bounding_boxes"])


## Instruction:
Fix import, use fileinput.iput as context, and fix its argument
## Code After:

import fileinput
import json
import os.path
import sys

from dstruct.Sentence import Sentence

## BASE_DIR denotes the application directory
BASE_DIR, throwaway = os.path.split(os.path.realpath(__file__))
BASE_DIR = os.path.realpath(BASE_DIR + "/../..")


## Return the start and end indexes of all subsets of words in the sentence
## sent, with size at most max_phrase_length
def get_all_phrases_in_sentence(sent, max_phrase_length):
    for start in range(len(sent.words)):
        for end in reversed(range(start + 1, min(len(sent.words), start + 1 + max_phrase_length))):
            yield (start, end)

## Return Sentence objects from input lines
def get_input_sentences(input_files=sys.argv[1:]):
    with fileinput.input(files=input_files) as f:
        for line in f:
            sent_dict = json.loads(line)
            yield Sentence(sent_dict["doc_id"], sent_dict["sent_id"],
                    sent_dict["wordidxs"], sent_dict["words"],
                    sent_dict["poses"], sent_dict["ners"], sent_dict["lemmas"],
                    sent_dict["dep_paths"], sent_dict["dep_parents"],
                    sent_dict["bounding_boxes"])

